user32

Capture Highlighted Text from any window using C#

浪子不回头ぞ 提交于 2019-11-30 05:31:12
问题 How to read the highlighted/Selected Text from any window using c#. i tried 2 approaches. Send "^c" whenever user selects some thing. But in this case my clipboard is flooded with lots of unnecessary data. Sometime it copied passwords also. so i switched my approach to 2nd method, send message method. see this sample code [DllImport("user32.dll")] static extern int GetFocus(); [DllImport("user32.dll")] static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);

How can I determine the current focused process name and version in C#

こ雲淡風輕ζ 提交于 2019-11-29 23:46:26
问题 For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9. The version number is very important... 回答1: This is going to be PInvoke city... You'll need to PInvoke the following API's in User32.dll Win32::GetForegroundWindow() in returns the HWND of the currently active window. /// <summary> /// The GetForegroundWindow function returns a handle to the foreground window. /// </summary> [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); Win32:

How do you disable system hotkeys in user32.dll?

让人想犯罪 __ 提交于 2019-11-29 17:43:59
I am coding in C#, if it is relevant. I am trying to disable system hotkeys for a kiosk application. The code used here has come from: https://www.codeproject.com/kb/cs/kiosk_cs.aspx?display=print This individual: How to disable the pressing/holding down of the Alt key, Control Key, and Shift Key when the left mouse button is clicked has appeared to have successfully used this method to disable Alt + F4 on Windows. However she didn't explicitly specify which version of Windows she was using other than saying one of the commands didn't work in W8. Tutorial for those who don't understand the

unable to read another application's caption

泪湿孤枕 提交于 2019-11-29 17:15:34
Jumping of how i will find windows handle in my main program... in C# I run notepad.exe then type something in it,then find the main window handle using SPY++ (0x111111) ,and [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount); . . . GetWindowText((IntPtr)(0x111111), str, 1024); this code works fine and return me the caption of the main window. : : but when i do the same to find caption of the child of notepad.exe it just set str to nothing. the spy++ told me that the child's

C# PInvoking user32.dll on a 64 bit system

守給你的承諾、 提交于 2019-11-29 10:54:27
问题 Is it wrong to pinvoke user32.dll on 64 bit Windows, from a 64 bit app? I've done this successfully a number of times and never had an error, but it seems contradictory. Should I look for user64.dll instead? 回答1: The name user32.dll is misleading. It's the 64 bit version of user32.dll you're calling. The 64 bit version is located at %windir%\System32\user32.dll . A 32-bit version is included for compatibility with 32-bit applications. It's located at %windir%\SysWOW64\user32.dll . You can

Swapping left and right mouse button in .NET

廉价感情. 提交于 2019-11-28 21:59:36
How do I swap left and right mouse buttons in .NET (preferably C#)? Basically the result should be the same as if the user checked the "Switch primary and secondary buttons" checkbox in the Mouse Properties through the control panel. I'm dealing with Windows XP, in case that makes a difference. You can use a Windows API call to SwapMouseButton : using System.Runtime.InteropServices; // ... [DllImport("user32.dll")] public static extern Int32 SwapMouseButton(Int32 bSwap); // ... // Swap it. SwapMouseButton(1); // Back to normal. SwapMouseButton(0); Something like this: using Microsoft.Win32;

Directing mouse events [DllImport(“user32.dll”)] click, double click

好久不见. 提交于 2019-11-28 19:46:08
I tried [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); and it works pretty fine to move the cursor to the desired point. I have never tried such kind of a DLL import before but it works :). However I want more what else can I extract? Mainly I want to make double click, click or use wheel options without any mouse input, just the code how can I do that? and how can I check what else is included in user32dll? Thanx Burimi [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern void mouse_event(uint dwFlags,

How to get the text of a MessageBox when it has an icon?

安稳与你 提交于 2019-11-28 13:50:56
I am working on trying to close a specific MessageBox if it shows up based on the caption and text. I have it working when the MessageBox doesn't have an icon. IntPtr handle = FindWindowByCaption(IntPtr.Zero, "Caption"); if (handle == IntPtr.Zero) return; //Get the Text window handle IntPtr txtHandle = FindWindowEx(handle, IntPtr.Zero, "Static", null); int len = GetWindowTextLength(txtHandle); //Get the text StringBuilder sb = new StringBuilder(len + 1); GetWindowText(txtHandle, sb, len + 1); //close the messagebox if (sb.ToString() == "Original message") { SendMessage(new HandleRef(null,

How do you disable system hotkeys in user32.dll?

别来无恙 提交于 2019-11-28 12:44:44
问题 I am coding in C#, if it is relevant. I am trying to disable system hotkeys for a kiosk application. The code used here has come from: https://www.codeproject.com/kb/cs/kiosk_cs.aspx?display=print This individual: How to disable the pressing/holding down of the Alt key, Control Key, and Shift Key when the left mouse button is clicked has appeared to have successfully used this method to disable Alt + F4 on Windows. However she didn't explicitly specify which version of Windows she was using

unable to read another application's caption

我怕爱的太早我们不能终老 提交于 2019-11-28 11:34:52
问题 Jumping of how i will find windows handle in my main program... in C# I run notepad.exe then type something in it,then find the main window handle using SPY++ (0x111111) ,and [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount); . . . GetWindowText((IntPtr)(0x111111), str, 1024); this code works fine and return me the caption of the main window. : : but when i do the same to