/res/ahk/windows.ahk
AutoHotKey | 70 lines | 60 code | 9 blank | 1 comment | 8 complexity | 02bdd6144012b5fbbdd6c58e08fe882f MD5 | raw file
1class Windows extends CGUI 2{ 3 4 __New(mainGui, Owner) 5 { 6 this.windowsLV := this.AddControl("ListView", "windowsLV", "w500 h300 NoSortHdr -Multi -LV0x10", "Title |Class |Exe") 7 this.windowsLV.IndependentSorting := true 8 this.AddControl("Button", "btnCancel", "x435 w75 h23", "Cancel") 9 10 this.Title := "Select Program" 11 this.gui := mainGui 12 this.Owner := owner, this.OwnerAutoClose := 1, this.MinimizeBox := 0 13 } 14 15 Load() { 16 this.AddWindows() 17 this.Show() 18 this.windowsLV.Modify() 19 } 20 21 windowsLV_DoubleClick(RowItem) { 22 class := this.windowsLV.Items[RowItem][2] 23 ; No item was selected 24 if (!class) 25 return 26 WinGet, exe, ProcessPath, % "ahk_class " . class 27 this.gui.Profile.edtExe.Text := exe 28 this.btnCancel_Click() 29 } 30 31 AddWindows() { 32 windows := GetWindows() 33 for index, window in windows 34 { 35 for key, value in window 36 %key% := value 37 this.windowsLV.Items.Add("", title, class, exe) 38 } 39 } 40 41 btnCancel_Click() { 42 this.gui.Profile.Enabled := true 43 this.Hide() 44 Loop % this.windowsLV.Items.Count 45 this.windowsLV.Items.Delete(1) 46 } 47 48 PreClose() { 49 this.gui.Profile.Enabled := true 50 } 51 52} 53 54GetWindows() { 55 DetectHiddenWindows, Off 56 WinGet, id, list,,, Program Manager 57 Windows := [] 58 Loop % id 59 { 60 id := id%A_Index% 61 WinGetClass, class, ahk_id %id% 62 WinGet, exe, ProcessName, ahk_id %id% 63 WinGetTitle, title, ahk_id %id% 64 if((!title && exe != "Explorer.exe") || InStr(class, "Tooltip") || InStr(class, "SysShadow")) ;Filter some windows 65 continue 66 tmpArray := { title: title, class: class, exe: exe} 67 Windows.Insert(tmpArray) 68 } 69 return Windows 70}