Windows 10 - How to distinguish between "visible" and "invisible" windows. Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
GEV
Posts: 754
Joined: 25 Feb 2014, 00:50

Windows 10 - How to distinguish between "visible" and "invisible" windows.

28 Dec 2015, 10:50

Can Autohotkey recognize a/the difference between

"visible" windows (= windows on the current desktop)
and
"invisible" windows (= windows they have been sent to or opened on another virtual desktop)

?
User avatar
Flipeador
Posts: 1044
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: Windows 10 - How to distinguish between "visible" and "invisible" windows.  Topic is solved

28 Dec 2015, 17:47

hi,
I have come to this, but apparently IsWindowOnCurrentVirtualDesktop() does not work, do not know why, maybe you or someone else can find the error.
Edited*
ok, this work

Code: Select all

hWnd := WinExist("ahk_class Notepad")
MsgBox % "IsWindowOnCurrentVirtualDesktop: " IsWindowOnCurrentVirtualDesktop(hWnd)
ExitApp

;Indicates whether the provided window is on the currently active virtual desktop.
IsWindowOnCurrentVirtualDesktop(hWnd) {
	;IVirtualDesktopManager interface
	;Exposes methods that enable an application to interact with groups of windows that form virtual workspaces.
	;https://msdn.microsoft.com/en-us/library/windows/desktop/mt186440(v=vs.85).aspx
	CLSID := "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" ;search VirtualDesktopManager clsid
	IID := "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}" ;search IID_IVirtualDesktopManager
	IVirtualDesktopManager := ComObjCreate(CLSID, IID)
	
	;IVirtualDesktopManager::IsWindowOnCurrentVirtualDesktop method
	;Indicates whether the provided window is on the currently active virtual desktop.
	;https://msdn.microsoft.com/en-us/library/windows/desktop/mt186442(v=vs.85).aspx
	Error := DllCall(NumGet(NumGet(IVirtualDesktopManager+0), 3*A_PtrSize), "Ptr", IVirtualDesktopManager, "Ptr", hWnd, "IntP", onCurrentDesktop)

	;free IVirtualDesktopManager
	ObjRelease(IVirtualDesktopManager)
	
	;return
	if !(Error=0) ;S_OK
		return false, ErrorLevel := true
	return onCurrentDesktop, ErrorLevel := false
}
GEV
Posts: 754
Joined: 25 Feb 2014, 00:50

Re: Windows 10 - How to distinguish between "visible" and "invisible" windows.

29 Dec 2015, 15:36

Thanks a million!!! Works great.

How about the other two Methods of the IVirtualDesktopManager (GetWindowDesktopId, MoveWindowToDesktop)?

Return to “Ask For Help”

Who is online

Users browsing this forum: asdgh8, Bing [Bot] and 115 guests