Hi,
Windows 10 has a built-in live preview of active virtual desktops (activated by Win+Tab), that looks like this:
Now I was wondering, is there any way to access a particular desktop preview and draw it in a GUI?
I want to be able to use my first desktop, while having a little preview on what's on the second desktop:
If you have any ideas, please share with me!
Thanks in advance
Virtual desktop preview
Re: Virtual desktop preview
Code: Select all
#NoEnv
#SingleInstance force
F1::
Gui, destroy
Gui,+LastFound +AlwaysOnTop ToolWindow
Gui, Color, Black, Black
Gui, Font, s11 cWhite
num_win =
WinGet, id, list
Loop, %id%
{
this_id := id%A_Index%
If NOT IsWindow(WinExist("ahk_id" . this_id))
continue
hWnd := WinExist("ahk_id " . this_ID)
If IsWindowOnCurrentVirtualDesktop(hWnd)
continue
num_win += 1
}
If (num_win = "")
{
MsgBox, No windows on other desktop(s)
return
}
Height := num_win*35
Gui, Add, ListView, w350 h%Height% -E0x200 -Hdr gListViewClick, Icon|Title
GoSub, RefreshWindowList
Gui, show, AutoSize, windows on other desktop(s)
return
;------------------------------------
; Activate selected window
;------------------------------------
ListViewClick:
if (A_GuiEvent = "DoubleClick")
{
Gui, submit
rowNum:= LV_GetNext(0)
stringtrimleft, window_id, id_array%rowNum%, 0
WinGetTitle, WinTitle, ahk_id %window_id%
WinActivate, ahk_id %window_id%
}
return
;--------------------------------------
; Refresh the list of windows
;--------------------------------------
RefreshWindowList:
; https://autohotkey.com/boards/viewtopic.php?t=9466
list =
num_win =
num_allwin =
WinGet, id, list
Loop, %id%
{
this_id := id%A_Index%
If NOT IsWindow(WinExist("ahk_id" . this_id))
continue
hWnd := WinExist("ahk_id " . this_ID)
If IsWindowOnCurrentVirtualDesktop(hWnd)
continue
WinGetTitle, title, ahk_id %this_id%
num_allwin += 1
allwin_array%num_allwin% = %title%
allwinid_array%num_allwin% = %this_id%
}
num_win = 0
Loop, %num_allwin%
{
StringTrimRight, title, allwin_array%a_index%, 0
StringTrimRight, this_id, allwinid_array%a_index%, 0
num_win += 1
win_array%num_win% = %title%
id_array%num_win%= %this_id%
}
ImageListID1 := IL_Create(num_win,1,1)
LV_SetImageList(ImageListID1, 1)
LV_Delete()
empty=0
iconId_array:=Object()
iconTitle_array:=Object()
iconId_Num=0
loop,%num_win%,
{
ele:=win_array%a_index%
wid := id_array%a_index%
WinGet, es, ExStyle, ahk_id %wid%
iconTitle_array.Insert(win_array%a_index%)
iconId_array.Insert(wid)
iconId_Num+=1
WinGetClass, Win_Class, ahk_id %wid%
WinGetTitle, wintitle, ahk_id %wid%
If (Win_Class = "ApplicationFrameWindow")
{
IconNumber := IL_Add(ImageListID1, A_WinDir "\System32\SHELL32.dll" , 3)
LV_Add("Icon" . IconNumber,a_index-empty ,ele)
}
else
{
WinGet, Path, ProcessPath, ahk_id %wid%
IconNumber := IL_Add(ImageListID1, Path,,0)
LV_Add("Icon" . IconNumber,a_index-empty ,ele)
}
}
num_win:=iconId_Num
for i ,ele in iconId_array{
id_array%i%:=ele
win_array%i%:=iconTitle_array[i]
}
return
;----------------------------------------------------------------------
; Check whether the target window is activation target
;----------------------------------------------------------------------
IsWindow(hWnd){
WinGet, dwStyle, Style, ahk_id %hWnd%
if ((dwStyle&0x08000000) || !(dwStyle&0x10000000)) {
return false
}
WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
if (dwExStyle & 0x00000080) {
return false
}
WinGetClass, szClass, ahk_id %hWnd%
if (szClass = "TApplication") {
return false
}
return true
}
; https://autohotkey.com/boards/viewtopic.php?p=64295#p64295
; https://autohotkey.com/boards/viewtopic.php?f=5&t=12388&p=64256#p64256
;------------------------------------------------------------------------------------------------------
; Indicates whether the prvided window is on the currently active virtual desktop.
;------------------------------------------------------------------------------------------------------
IsWindowOnCurrentVirtualDesktop(hWnd) {
onCurrentDesktop := ""
CLSID := "{aa509086-5ca9-4c25-8f95-589d3c07b48a}"
IID := "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}"
IVirtualDesktopManager := ComObjCreate(CLSID, IID)
Error := DllCall(NumGet(NumGet(IVirtualDesktopManager+0), 3*A_PtrSize), "Ptr", IVirtualDesktopManager, "Ptr", hWnd, "IntP", onCurrentDesktop)
ObjRelease(IVirtualDesktopManager)
if !(Error=0)
return false, ErrorLevel := true
return onCurrentDesktop, ErrorLevel := false
}
Re: Virtual desktop preview
Hey,
Unfortunately this only shows what windows are open on a particular virtual desktop.
I'm looking for a way to get the actual image of what's on the second desktop, so I can redraw it.
Is there a way to take a screenshot of another virtual desktop?
Unfortunately this only shows what windows are open on a particular virtual desktop.
I'm looking for a way to get the actual image of what's on the second desktop, so I can redraw it.
Is there a way to take a screenshot of another virtual desktop?
Re: Virtual desktop preview
I've managed what I needed to do with GDI's Gdip_BitmapFromHWND on a fullscreen application on a virtual desktop and it works, a bit CPU-intensive though.
Who is online
Users browsing this forum: Google [Bot], jaka1, marypoppins_1, mikeyww, usser, wilkster and 143 guests