|
| 1 | +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. |
| 2 | +#SingleInstance, force |
| 3 | +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. |
| 4 | +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. |
| 5 | +SetBatchLines, -1 |
| 6 | +#KeyHistory 0 |
| 7 | +ListLines Off |
| 8 | + |
| 9 | +SetWinDelay, -1 |
| 10 | +SetControlDelay, -1 |
| 11 | + |
| 12 | +#Include ..\VD.ahk |
| 13 | +VD_init() |
| 14 | + |
| 15 | +arrayOfWindowsInfo:=[] ;to store {desktopNum:number, str:INFO} |
| 16 | + |
| 17 | +DetectHiddenWindows, on |
| 18 | +WinGet windows, List |
| 19 | +Loop %windows% |
| 20 | +{ |
| 21 | + id := windows%A_Index% |
| 22 | + IfEqual, False, % VD_isValidWindow(id), continue |
| 23 | + ahk_idId := "ahk_id " id |
| 24 | + desktopOfWindow:=VD_getDesktopOfWindow(ahk_idId) |
| 25 | + if (desktopOfWindow) |
| 26 | + { |
| 27 | + whichDesktop:="Desktop " desktopOfWindow |
| 28 | + |
| 29 | + ;useful |
| 30 | + WinGetTitle, OutputTitle, %ahk_idId% |
| 31 | + WinGetClass, OutputClass, %ahk_idId% |
| 32 | + WinGet, OutputEXE, ProcessName, %ahk_idId% |
| 33 | + useFulStr:="`nWinTitle: " OutputTitle "`nclass: " OutputClass "`nEXE: " OutputEXE |
| 34 | + |
| 35 | + ;not that useful |
| 36 | + WinGet, OutputFULLPATH, ProcessPath, %ahk_idId% |
| 37 | + WinGet, OutputPID, PID, %ahk_idId% |
| 38 | + |
| 39 | + notThatUseFulStr:="`n`nFULLPATH: " OutputFULLPATH "`nPID: " OutputPID "`nID: " id |
| 40 | + WinGet, OutputVar, ProcessPath, A |
| 41 | + |
| 42 | + arrayOfWindowsInfo.Push({desktopNum:desktopOfWindow, str:whichDesktop useFulStr notThatUseFulStr}) |
| 43 | + } |
| 44 | +} |
| 45 | +DetectHiddenWindows, off |
| 46 | + |
| 47 | +;below is just to print it |
| 48 | +arrayOfWindowsInfo:=sortArrByKey(arrayOfWindowsInfo,"desktopNum") |
| 49 | + |
| 50 | +ArrayStreamArray:=[] |
| 51 | +for k, v in arrayOfWindowsInfo { |
| 52 | + ArrayStreamArray.push(v["str"]) |
| 53 | +} |
| 54 | + |
| 55 | +streamArray(ArrayStreamArray,1100,200) |
| 56 | +return |
| 57 | + |
| 58 | + |
| 59 | +streamArray(Byref arr,Byref width,Byref height) |
| 60 | +{ |
| 61 | + global ArrayStreamArray, ArrayStreamIndex, ArrayStreamGuiId, ArrayStreamTextId, ArrayStreamIndexTextId, ArrayStreamLength |
| 62 | + |
| 63 | + ArrayStreamLength:=arr.Length() |
| 64 | + if (ArrayStreamLength) |
| 65 | + { |
| 66 | + ArrayStreamArray:=arr |
| 67 | + |
| 68 | + Gui, main:New, +hwndArrayStreamHwnd |
| 69 | + ArrayStreamGuiId:="ahk_id " ArrayStreamHwnd |
| 70 | + Gui,Font, s12 Normal, Segoe UI |
| 71 | + |
| 72 | + gui, add, Text,, Index: |
| 73 | + gui, add, Text, hwndArrayStreamIndexText x+10 w300, 1 |
| 74 | + ArrayStreamIndexTextId:="ahk_id " ArrayStreamIndexText |
| 75 | + Gui, Font, s12 Bold |
| 76 | + |
| 77 | + gui, add, Text, x20 w%width% h%height% hwndArrayStreamTextBox, % ArrayStreamArray[1] |
| 78 | + |
| 79 | + Gui, Font, s18 Bold |
| 80 | + gui, add, button,w70 h35 gArrayStreamGoLeft, 🠔 |
| 81 | + gui, add, button,w70 h35 Default gArrayStreamGoRight x+10, 🠖 |
| 82 | + Gui,Font, s12 Normal |
| 83 | + |
| 84 | + heightPlus:=height+90 |
| 85 | + gui, show, w%width% h%heightPlus% |
| 86 | + ArrayStreamTextId:="ahk_id " ArrayStreamTextBox |
| 87 | + ArrayStreamIndex:=1 |
| 88 | + } |
| 89 | +} |
| 90 | +#if winactive(ArrayStreamGuiId) |
| 91 | +left:: |
| 92 | +ArrayStreamGoLeft: |
| 93 | + if (ArrayStreamIndex < 2) { |
| 94 | + SoundPlay, *-1 |
| 95 | + return |
| 96 | + } |
| 97 | + ArrayStreamIndex-- |
| 98 | + ControlSetText,,% ArrayStreamArray[ArrayStreamIndex], %ArrayStreamTextId% |
| 99 | + ControlSetText,,% ArrayStreamIndex, %ArrayStreamIndexTextId% |
| 100 | +return |
| 101 | + |
| 102 | +right:: |
| 103 | +ArrayStreamGoRight: |
| 104 | + if (ArrayStreamIndex = ArrayStreamLength) { |
| 105 | + SoundPlay, *-1 |
| 106 | + return |
| 107 | + } |
| 108 | + ArrayStreamIndex++ |
| 109 | + ControlSetText,,% ArrayStreamArray[ArrayStreamIndex], %ArrayStreamTextId% |
| 110 | + ControlSetText,,% ArrayStreamIndex, %ArrayStreamIndexTextId% |
| 111 | +return |
| 112 | +#if |
| 113 | + |
| 114 | + |
| 115 | +sortArrByKey(ar,byref key) { |
| 116 | + str= |
| 117 | + for k,v in ar { |
| 118 | + str.=v[key] "+" k "|" |
| 119 | + } |
| 120 | + length:=ar.Length() |
| 121 | + firstValue:=ar[1][key] |
| 122 | + if firstValue is number |
| 123 | + { |
| 124 | + sortType := "N" |
| 125 | + } |
| 126 | + Sort, str, % "D| " sortType |
| 127 | + finalAr:=[] |
| 128 | + finalAr.SetCapacity(length) |
| 129 | + barPos:=1 |
| 130 | + loop %length% { |
| 131 | + plusPos:=InStr(str, "+",, barPos) |
| 132 | + barPos:=InStr(str, "|",, plusPos) |
| 133 | + |
| 134 | + num:=SubStr(str, plusPos + 1, barPos - plusPos - 1) |
| 135 | + finalAr.Push(ar[num]) |
| 136 | + } |
| 137 | + return finalAr |
| 138 | +} |
| 139 | + |
| 140 | +f3::Exitapp |
0 commit comments