winapi

UI Automation switch window

六月ゝ 毕业季﹏ 提交于 2021-02-08 14:06:33
问题 I've noticed that setforegroundwindow can be very flaky - no matter how you do it. I've noticed that using UIAutomation, where possible, seems to improve things. For example: Getting the WindowPattern and using something like: windowPattern.SetWindowVisualState( WindowVisualState.Normal ); windowPattern.SetWindowVisualState( WindowVisualState.Maximized ); Now my questions is: How do I know whether I should make it maximized or normal. The task manager, and dragon naturally speaking both seem

Why the irrelevant code made a difference?

送分小仙女□ 提交于 2021-02-08 13:59:14
问题 I am thinking to make a progress bar with python in terminal. First, I have to get the width(columns) of terminal window. In python 2.7, there is no standard library can do this on Windows. I know maybe I have to call Windows Console API manually. According to MSDN and Python Documentation, I wrote the following code: import ctypes import ctypes.wintypes class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): _fields_ = [ ('dwSize', ctypes.wintypes._COORD), ('dwCursorPosition', ctypes.wintypes.

Who is owner of GWLP_USERDATA cell?

眉间皱痕 提交于 2021-02-08 13:43:07
问题 good known that GWLP_USERDATA can be used to associate some pointer size data with the specified window. but who has the right do it ? obviously if two piece of code independently do this - one piece is overwrite data of another - so there must only be one owner. but it must be clear determined a general rule - who is owner of GWLP_USERDATA cell ? whom it belong ? can be two internally consistent agreements: code that created the window is owner. belong to the creator of the window code which

How to access information in Windows Device Manager from Java?

时光总嘲笑我的痴心妄想 提交于 2021-02-08 12:41:26
问题 I have a serial to USB device and more than one of those can be connected to the computer. I need to query and retrieve a list of COM ports that the devices are connected to. In Windows Device Manager you can get the COM port + friendly name of devices that are connected at the present time. This list is dynamic. Reading from the registry did not work because the information stored is stale and static, not dynamic. Devcon (from Microsoft) does list the ports that devices are connected to, but

Can't center my console window by using the following code

杀马特。学长 韩版系。学妹 提交于 2021-02-08 12:01:50
问题 void Initialize_Window(void) { RECT rConsole; GetWindowRect(GetConsoleWindow(), &rConsole); SetWindowPos(GetConsoleWindow(), NULL, 0, 0, 800, 700, 0); SetWindowLong(GetConsoleWindow(), GWL_STYLE, GetWindowLong(GetConsoleWindow(), GWL_STYLE) & ~(WS_SIZEBOX | WS_MAXIMIZEBOX)); SetWindowPos(GetConsoleWindow(), NULL, (GetSystemMetrics(SM_CXSCREEN) - rConsole.right - rConsole.left) / 2, (GetSystemMetrics(SM_CYSCREEN) - rConsole.bottom - rConsole.top) / 2, 0, 0, SWP_NOSIZE); } I'm trying to center

Can't center my console window by using the following code

倾然丶 夕夏残阳落幕 提交于 2021-02-08 12:01:19
问题 void Initialize_Window(void) { RECT rConsole; GetWindowRect(GetConsoleWindow(), &rConsole); SetWindowPos(GetConsoleWindow(), NULL, 0, 0, 800, 700, 0); SetWindowLong(GetConsoleWindow(), GWL_STYLE, GetWindowLong(GetConsoleWindow(), GWL_STYLE) & ~(WS_SIZEBOX | WS_MAXIMIZEBOX)); SetWindowPos(GetConsoleWindow(), NULL, (GetSystemMetrics(SM_CXSCREEN) - rConsole.right - rConsole.left) / 2, (GetSystemMetrics(SM_CYSCREEN) - rConsole.bottom - rConsole.top) / 2, 0, 0, SWP_NOSIZE); } I'm trying to center

C# very simple keyboard hook

纵饮孤独 提交于 2021-02-08 11:47:43
问题 im trying to create a custom macro program in C# and I want to know how I can create a low level keyboard hook. I have looked around and have found some but i do not understand how they work or how i can customise it :/ can anyone show me how I can create a keyboard hook that basically does: once any key is pressed, the int keycode is set to a method (i think the VK code is what i need?) the exampels i find online seem too complicated for that :/ Thanks :) 回答1: A Simple C# Global Low Level

How to stop DLL Hijacking for secondary IMPLICITLY loaded DLLs

◇◆丶佛笑我妖孽 提交于 2021-02-08 11:46:42
问题 For example, COMDLG32.DLL implicitly links against the following system DLLs (among others): xmllite.dll msftedit.dll srvcli.dll wkscli.dll linkinfo.dll netutils.dll msi.dll Since these are implicitly loaded by the operating system, not explicitly loaded using LoadLibrary call, the hijack vulnerability workaround using SetDllDirectory does not affect these loads being done when COMDLG32.DLL is loaded. Hence, after my application is loaded, and I hit Ctrl+O to use the File Open dialog, these

Bringing a window to foreground from a background process

只愿长相守 提交于 2021-02-08 10:37:17
问题 My situation: A browser displays a webpage served by a locally running webserver. When the user clicks a button on the page, I would like to jump to another, possibly already running, application. Working on Windows, I thought about processing the button-click in my locally running webserver and just look for the respective HWND to call SetForegroundWindow on it. However, as it stands, the locally running webserver is not sufficiently privileged to SetForegroundWindow. Those restrictions make

win32file.createFile “The System cannot find the specified path”

廉价感情. 提交于 2021-02-08 09:16:14
问题 I'm using win32file.CreateFile() to open up "file" that I see in process explorer. The file in question is (as seen in proc explorer's handles and dlls view) : "\Device\ccSet_{}" Q1. Can anyone shed light on what is \Device\<file name> . I believe these are obviously not files stored on the hard-disks somewhere. Unless I am wrong, what are they ? Q2. When I try to use the path AS IS, in win32file.CreateFile() , it gives me an error "The system cannot find the specified path or file". Where am