window-handles

How to convert IntPtr to int

ぐ巨炮叔叔 提交于 2019-12-10 02:02:14
问题 A window handle sometimes of type int and other times of type IntPtr int example: [DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(int hWnd, int ProcessId); IntPtr example: [DllImport("user32.dll", CharSet = CharSet.Auto)] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam); I don't seem to be able to convert/cast from one to the other. When I try this.ProcessID = GetWindowThreadProcessId(windowHandle.ToInt32(),0) I get an error

How to get count of opened handles that belongs to a certain process?

╄→гoц情女王★ 提交于 2019-12-08 21:08:43
问题 You can use the program Process Explorer to see how many handles running applications have. Is there a way with Delphi code to get this number? I am interested in tracking the number for the application itself; not to find the number of handles used by other applications as Process Explorer is doing. My intention is for the application to track/detect possible resource leaks. 回答1: Use the GetProcessHandleCount function. This API function is in recent versions of Delphi imported by the Winapi

how do I close window with handle using win32gui in Python

谁都会走 提交于 2019-12-07 09:16:41
问题 I have obtained the handle of a window I want to target, with win32gui library in Python How do I close the window? I have the following code, the second line did what I intended to do but the last line seems to be wrong. handle = win32gui.FindWindow(None, r'Notepad++') win32gui.SetForegroundWindow(handle) win32gui.CloseWindow(handle) I also want to know if I just want to close the window, is the second line necessary? Besides that, I notice a minor thing, and I am curious about it: If I try

Are window handles (HWND) unique, or do they ever get reused?

馋奶兔 提交于 2019-12-07 02:56:41
问题 I am thinking if there are handles of the same value ? To clarify my question, let's say I open Notepad, type in some text, save it and then close Notepad. If I repeat this a thousand times (or even more), will I ever have a chance to see the same window handle (HWND) value being used for the Notepad main window that was used the first time? If so, why? 回答1: By the pigeonhole principal, yes, they can't be unique. In fact, Microsoft still maintains compatibility with 16-bit Windows, and as a

Selenium Python does not close the child window

◇◆丶佛笑我妖孽 提交于 2019-12-06 14:10:50
I have webpage which open new browser window on click. I am able to get 2 handles however driver.close() always closes the first/main window. from selenium import webdriver import time driver = webdriver.Chrome() driver.get("file:///D:/blackhole/print.html") han = driver.window_handles print("handles:", han) # gets 1 handle time.sleep(2) click_btn = driver.find_element_by_link_text('Print') click_btn.click() han = driver.window_handles print("handles:", han) # gets 2 handles driver.switch_to_window = han[1] # first element is always first window handle driver.close() # main window close Below

How to close all neural network diagrams in MATLAB?

回眸只為那壹抹淺笑 提交于 2019-12-06 11:27:10
I need to show diagrams of some networks, but the problem is that close all doesn't close these windows, so I have several windows to close manually after a few runs. [x,t] = house_dataset; net1 = newff(x, t, [5, 3]); view(net1); net2 = newff(x, t, [7, 5]); view(net2); close all; However if I keep the handle of window, close function will close it: net3 = newff(x, t, [9, 7]); h = view(net3); close(h); But it's not easy for me to collect all those handles. How can I find all those handles programmatically? You can use the command: nnet.guis.closeAllViews() This will close all the diagrams for

Are window handles (HWND) unique, or do they ever get reused?

风格不统一 提交于 2019-12-05 08:08:10
I am thinking if there are handles of the same value ? To clarify my question, let's say I open Notepad, type in some text, save it and then close Notepad. If I repeat this a thousand times (or even more), will I ever have a chance to see the same window handle (HWND) value being used for the Notepad main window that was used the first time? If so, why? ybungalobill By the pigeonhole principal , yes, they can't be unique. In fact, Microsoft still maintains compatibility with 16-bit Windows, and as a result handles are 16-bit values. So there are at most 65536 possible handle values. Yes. There

C# List currently open files and programs

送分小仙女□ 提交于 2019-12-05 06:46:35
问题 Is there a way I can get a list of all open applications and a list of all open files? For the files I only need the files that I opened (documents etc) not OS's open system files. The same for the applications (only browsers, document processors etc). I already tried various functions from the Windows API like EnumWindows but I couldn't get what I wanted. An example of what my ultimate goal would be, is to have lists like this: Applications Microsoft Word, Notepad, Mozilla Firefox Files foo

How to convert IntPtr to int

谁都会走 提交于 2019-12-05 01:35:16
A window handle sometimes of type int and other times of type IntPtr int example: [DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(int hWnd, int ProcessId); IntPtr example: [DllImport("user32.dll", CharSet = CharSet.Auto)] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam); I don't seem to be able to convert/cast from one to the other. When I try this.ProcessID = GetWindowThreadProcessId(windowHandle.ToInt32(),0) I get an error cannot implicitly convert from uint to int The SendMessage signature is static extern IntPtr SendMessage

Modifying opacity of any window from C#

人走茶凉 提交于 2019-12-03 18:00:38
问题 Is it possible to modify the opacity of all opened windows from C#. I googled for minimizing the windows and i came to know that its possible with pInvoke calls. It even worked. Similarly is it possible to change the opacity of all the opened windows from C#? Also, i am not in to MFC stuffs. Still is there any tools to know the list of apis exposed in a dll? 回答1: You can use SetLayeredWindowAttributes API to do so. Check this for the pInvoke version of this API. Sample Code from the above