user32

Send WM_SETTINGCHANGE message to refresh desktop

让人想犯罪 __ 提交于 2019-12-11 04:20:09
问题 I managed to programmatically change my desktop background via this one-liner: DllCall("user32.dll", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $CmdLine[1], "int", 0) … by drag and drop of the desired wallpaper onto the compiled script. I have another program that changes the desktop but for some reason fails to send the WM_SETTINGCHANGE message (I can see the key HKCU\Control Panel\Desktop\Wallpaper getting updated). How can I send this message to trigger a wallpaper refresh?

An unhandled exception of type 'System.ExecutionEngineException' occurring When trying to read window from GetWindowText() of user32.dll

流过昼夜 提交于 2019-12-11 02:52:31
问题 In my application, I am reading the text of a window for the same process. I am using GetWindowText of User32.dll. But when it tries to call the method, I am getting the exception "An unhandled exception of type 'System.ExecutionEngineException' occurred in aaaa.exe". Where can I see the exact error. And why I am getting this exception. My code is as below. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern int GetWindowText(IntPtr hWnd, [Out]

SetWindowPos returns Access Denied

╄→гoц情女王★ 提交于 2019-12-11 02:48:56
问题 I'am building app that helps taking screenshots of selected windows. I'am displaying semi-transparent form over selected window. I'am using winapi in this case. [DllImport("user32.dll", SetLastError = true)] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); First parameter is handle to transparent form, to second I'am passing handle to selected window. Everything working just fine except one thing. When selected window is

How to determine if the Caps Lock is toggled in a Silverlight Application?

非 Y 不嫁゛ 提交于 2019-12-10 13:54:44
问题 In a Silverlight application's log in screen, i need to determine if Caps Lock is toggled. This is easy enough by handling the KeyUp or KeyDown event, however how does one determine if it is toggled on or off even if a key hasn't been pressed? The reason I want todo this is what if the user doesn't press Caps Lock while the Silverlight application is running, but rather they toggled it before they even got to the login screen? I need to still warn them that caps Lock is on. Apparently

C# How to wait for a pop up window and select it for input

Deadly 提交于 2019-12-08 10:06:58
问题 I am basically writing a specialized macro player/recorder in C#. One thing I need to be able to do is wait for a pop up window (something like a Save As... dialog box) that I can then select to continue playing macro input into. Ideally, I would like to be able to poll for open windows and search through their titles for a matching window title. Obviously I can't use Processes.GetProcesses() because a dialog most likely will not show up as a new process. Where do I look to get open windows

EnumDisplayDevices return value is Generic PnP Monitor - c#

依然范特西╮ 提交于 2019-12-08 07:51:06
问题 I have several monitors connected, when I want to return their actual names - for example : LEN L192p, IBM 190p. I've looked here at this question : How do I get the actual Monitor name? as seen in the resolution dialog but when I run it, I get wrong identification. It detects my laptop, but the other two screens (LEN L192p, IBM 190p )that I'm using are not detected and it writes Generic PnP Monitor instead. anyone knows what can be the issue? here is the output : and the code: using System;

Correct logic for interpreting SetWindowsHookEx / WH_KEYBOARD_LL

﹥>﹥吖頭↗ 提交于 2019-12-08 04:17:59
问题 What's the correct way to convert a message from SetWindowsHookEx with WH_KEYBOARD_LL into a useful representation of the key pressed? I'm aware this will most likely involve understanding the mappings of the local keyboard. (NB: I'm only considering when a key is pressed, not when it's released for simplicity) Broadly speaking there seem to be three scenarios: Special key pressed (Ctrl/Escape/Shift/Alt) Standard key pressed ( A-Z , 0-9 , etc... Note that a and A both read as A ) Some hard to

Java JNA sendMessage() not found

[亡魂溺海] 提交于 2019-12-07 18:10:39
问题 I'm trying to use JNA (Overview) to send messages to an application when minimized or not on top (mouse click for example), and the I found that people are using com.sun.jna.platform.win32.User32.SendMessageA( hW, 0x0201, 0, 0); But i can't found this function in this class. Can someone give me an example of how to implement it if I'm doing it wrong? CODE: User32 user32; Pointer hW = user32.GetForegroundWindow().getPointer(); user32.SendMessageA( hW, 0x0201, 0, 0 ); 回答1: public interface

WinForms equivalent of WPF WindowInteropHelper, HwndSource, HwndSourceHook

对着背影说爱祢 提交于 2019-12-07 09:45:56
问题 I have a block of code like: IntPtr hWnd = new WindowInteropHelper(this).Handle; HwndSource source = HwndSource.FromHwnd(hWnd); source.AddHook(new HwndSourceHook(WndProc)); NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST, NativeMethods.WM_CALL, IntPtr.Zero, IntPtr.Zero); This was originally in a WPF application. However, I need to replicate the functionality in a WinForms application. Also, NativeMethods.PostMessage just maps to user32.dll PostMessage: [DllImport("user32")]

How to locate the window using findwindow function in windowapi using vba?

对着背影说爱祢 提交于 2019-12-07 04:00:47
问题 I am currently trying to find a way to check whether a window is open or not using Findwindow Function. I am able to find the window if i know the entire name of the window. In the below code i know that the name of the window is "win32api - Notepad" so i can easily find the window however i want to know whether it is possible to identify the window if i know only part name like "win32*". Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal