clone of my dotfiles.ssp.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'master' of github.com:sspaeti/dotfiles

sspaeti cf95ce52 869d0b70

+2598 -1
Windows/AutoHotKey/SetForeGroundWindow.exe

This is a binary file and will not be displayed.

+190
Windows/AutoHotKey/SetForegroundWindow.asm
··· 1 + ; https://github.com/ayaka14732/TinyPE-on-Win10/blob/main/step7/stretch.asm 2 + ; nasm SetForegroundWindow.asm -o SetForegroundWindow.exe 3 + BITS 64 4 + 5 + %define align(n,r) (((n+(r-1))/r)*r) 6 + ; DOS Header 7 + dw 'MZ' ; e_magic 8 + dw 0 ; [UNUSED] e_cblp 9 + pe_hdr: ; PE Header 10 + dw 'PE' ; [UNUSED] c_cp ; Signature 11 + dw 0 ; [UNUSED] e_crlc ; Signature (Cont) 12 + ; Image File Header 13 + dw 0x8664 ; [UNUSED] e_cparhdr ; Machine 14 + code: 15 + dw 0x01 ; NumberOfSections 16 + dd 0 ; [UNUSED] TimeDateStamp 17 + dd 0 ; PointerToSymbolTable 18 + dd 0 ; NumberOfSymbols 19 + dw opt_hdr_size ; SizeOfOptionalHeader 20 + dw 0x22 ; Characteristics 21 + opt_hdr: ; Optional Header, COFF Standard Fields 22 + dw 0x020b ; [UNUSED] e_res ; Magic (PE32+) 23 + db 0 ; [UNUSED] e_res (Cont) ; [UNUSED] MajorLinkerVersion 24 + db 0 ; [UNUSED] e_res (Cont) ; [UNUSED] MinorLinkerVersion 25 + dd code_size ; [UNUSED] e_res (Cont) ; SizeOfCode 26 + dw 0 ; [UNUSED] e_oemid ; [UNUSED] SizeOfInitializedData 27 + dw 0 ; [UNUSED] e_oeminfo ; [UNUSED] SizeOfInitializedData (Cont) 28 + dd 0 ; [UNUSED] e_res2 ; [UNUSED] SizeOfUninitializedData 29 + dd entry ; [UNUSED] e_res2 (Cont) ; AddressOfEntryPoint 30 + dd code ; [UNUSED] e_res2 (Cont) ; BaseOfCode 31 + ; Optional Header, NT Additional Fields 32 + dq 0x000140000000 ; [UNUSED] e_res2 (Cont) ; ImageBase 33 + dd pe_hdr ; e_lfanew ; [MODIFIED] SectionAlignment (0x10 -> 0x04) 34 + dd 0x04 ; [MODIFIED] FileAlignment (0x10) 35 + dw 0x06 ; [UNUSED] MajorOperatingSystemVersion 36 + dw 0 ; [UNUSED] MinorOperatingSystemVersion 37 + dw 0 ; [UNUSED] MajorImageVersion 38 + dw 0 ; [UNUSED] MinorImageVersion 39 + dw 0x06 ; MajorSubsystemVersion 40 + dw 0 ; MinorSubsystemVersion 41 + dd 0 ; [UNUSED] Reserved1 42 + dd file_size ; SizeOfImage 43 + dd hdr_size ; SizeOfHeaders 44 + dd 0 ; [UNUSED] CheckSum 45 + dw 0x02 ; Subsystem (Windows GUI) 46 + dw 0x8160 ; DllCharacteristics 47 + dq 0x100000 ; SizeOfStackReserve 48 + dq 0x1000 ; SizeOfStackCommit 49 + dq 0x100000 ; SizeOfHeapReserve 50 + dll_name: ; DLLName 51 + db 'USER32.dll', 0 ; DLLName 52 + times 12-($-dll_name) db 0 ; [UNUSED] SizeOfHeapCommit 53 + ; [UNUSED] LoaderFlags 54 + dd 0x02 ; [MODIFIED] NumberOfRvaAndSizes (0x10) 55 + 56 + ; Optional Header, Data Directories 57 + lol: 58 + dd 0 ; [UNUSED] Export, RVA 59 + dd 0 ; [UNUSED] Export, Size 60 + iatbl: ; Import Address Directory 61 + dd itbl ; Import, RVA ; [USEDAFTERLOAD] DLLFuncEntry 62 + dd itbl_size ; Import, Size ; [USEDAFTERLOAD] DLLFuncEntry (Cont) 63 + 64 + opt_hdr_size equ $-opt_hdr 65 + 66 + ; Section Table 67 + section_name db '.', 0 ; Name 68 + times 8-($-section_name) db 0 69 + dd sect_size ; VirtualSize 70 + dd iatbl ; VirtualAddress 71 + dd code_size ; SizeOfRawData 72 + dd iatbl ; PointerToRawData 73 + content: ; Strings 74 + db 0x41,0x00,0x42,0x00,0x43,0x00,0x44,0x00 75 + db 0x45,0x00,0x46,0x00,0x47,0x00,0,0 76 + ; [UNUSED] PointerToRelocations 77 + ; [UNUSED] PointerToLinenumbers 78 + ; [UNUSED] NumberOfRelocations 79 + ; [UNUSED] NumberOfLinenumbers 80 + ; [UNUSED] Characteristics 81 + hdr_size equ $-$$ 82 + 83 + intblFirstThunk1: ; Import Name Table 84 + dq symbol11 ; [UNUSED] FirstThunk ; Symbol 85 + dq 0 86 + intblFirstThunk2: ; Import Name Table 87 + dq symbol21 ; [UNUSED] FirstThunk ; Symbol 88 + dq 0 89 + intblFirstThunk3: ; Import Name Table 90 + dq symbol31 ; [UNUSED] FirstThunk ; Symbol 91 + dq 0 92 + times align($-$$,16)-($-$$) db 0xcc 93 + 94 + ; Entry 95 + entry: 96 + ;int3 97 + sub rsp, 28h 98 + call [rel intbl2] ; GetCommandLineW 99 + mov rcx, rax 100 + lea rdx, [rel pNumArgs2] 101 + call [rel intbl3] ; CommandLineToArgvW 102 + 103 + ;AtoI 104 + mov rcx, [08h + rax] 105 + movzx edx, BYTE [rcx] 106 + test dl,dl 107 + je endXor 108 + add rcx, 02h 109 + xor eax,eax 110 + ;I have no clue what this data16 does: padding for performance ??? 111 + ;data16 data16 data16 data16 data16 cs nopw 0x0(%rax,%rax,1) 112 + 113 + ;db 0x66 114 + ;db 0x66 115 + ;db 0x66 116 + ;db 0x66 117 + ;db 0x66 118 + ;nop word cs:[rax + rax*1] 119 + db 0x66,0x66,0x66,0x66,0x66,0x66,0x2E,0x0F,0x1F,0x84,0x00,0x00,0x00,0x00,0x00 120 + 121 + midAtoI: 122 + lea eax, [rax + 4*rax] 123 + xor dl,30h 124 + movsx edx,dl 125 + lea eax, [rdx + 2*rax] 126 + movzx edx,BYTE [rcx] 127 + add rcx, 02h 128 + test dl,dl 129 + jne midAtoI 130 + jmp endAtoI 131 + endXor: 132 + xor eax,eax 133 + endAtoI: 134 + mov ecx,eax 135 + call [rel intbl] ; SetForegroundWindow 136 + add rsp, 28h 137 + ret 138 + pNumArgs2: 139 + dd 0 140 + times align($-$$,16)-($-$$) db 0xcc 141 + 142 + itbl: ; Import Directory 143 + dd intbl ; OriginalFirstThunk 144 + dd 0 ; [UNUSED] TimeDateStamp 145 + dd 0 ; [UNUSED] Forwarder Chain 146 + dd dll_name ; Name 147 + dd intbl ; FirstThunk 148 + dd intbl2 ; OriginalFirstThunk 149 + dd 0 ; [UNUSED] TimeDateStamp 150 + dd 0 ; [UNUSED] Forwarder Chain 151 + dd dll_name2 ; Name 152 + dd intbl2 ; FirstThunk 153 + dd intbl3 ; OriginalFirstThunk 154 + dd 0 ; [UNUSED] TimeDateStamp 155 + dd 0 ; [UNUSED] Forwarder Chain 156 + dd dll_name3 ; Name 157 + dd intbl3 ; FirstThunk 158 + dd 0 ; OriginalFirstThunk 159 + dd 0 ; [UNUSED] TimeDateStamp 160 + dd 0 ; [UNUSED] Forwarder Chain 161 + dd 0 ; Name 162 + itbl_size equ $-itbl 163 + intbl: ; Import Name Table 164 + dq symbol11 ; [UNUSED] FirstThunk ; Symbol 165 + dq 0 166 + intbl2: ; Import Name Table 167 + dq symbol21 ; [UNUSED] FirstThunk ; Symbol 168 + dq 0 169 + intbl3: ; Import Name Table 170 + dq symbol31 ; [UNUSED] FirstThunk ; Symbol 171 + dq 0 172 + symbol11: 173 + dw 0x0294 ; [UNUSED] Function Order 174 + db 'SetForegroundWindow', 0 ; Function Name 175 + symbol21: 176 + dw 0x0296 ; [UNUSED] Function Order 177 + db 'GetCommandLineW', 0 ; Function Name 178 + symbol31: 179 + dw 0x0297 ; [UNUSED] Function Order 180 + db 'CommandLineToArgvW', 0 ; Function Name 181 + dll_name2: 182 + db 'KERNEL32.dll', 0 183 + dll_name3: 184 + db 'Shell32.dll', 0 185 + 186 + ;sect_size equ $-code 187 + ;code_size equ $-code 188 + sect_size equ $-iatbl 189 + code_size equ $-iatbl 190 + file_size equ $-$$
+9
Windows/AutoHotKey/VD.ahk
··· 1 + ; in YOUR app 2 + #Include %A_LineFile%\..\VD.ahk 3 + ; or 4 + ; #Include %A_LineFile%\..\_VD.ahk 5 + ; ...{startup code} 6 + ; VD.init() 7 + 8 + ; VD.ahk : calls `VD.init()` on #Include 9 + ; _VD.ahk : `VD.init()` when you want, like after a GUI has rendered, for startup performance reasons
+1087
Windows/AutoHotKey/_VD.ahk
··· 1 + ; VD.getCurrentDesktopNum() 2 + ; VD.getDesktopNumOfWindow(wintitle) ;please use VD.goToDesktopOfWindow instead if you just want to go there. 3 + ; VD.getDesktopNumOfWindow(wintitle) ;returns 0 for "Show on all desktops" 4 + 5 + ; VD.getCount() ;how many virtual desktops you now have 6 + ; VD.getRelativeDesktopNum(anchor_desktopNum, relative_count) 7 + 8 + ; VD.goToDesktopNum(desktopNum) 9 + ; VD.goToDesktopOfWindow(wintitle, activateYourWindow:=true) 10 + ; VD.gotoRelativeDesktopNum(relative_count) 11 + 12 + ; VD.MoveWindowToDesktopNum(wintitle, desktopNum) 13 + ; VD.MoveWindowToCurrentDesktop(wintitle, activateYourWindow:=true) 14 + ; VD.MoveWindowToRelativeDesktopNum(wintitle, relative_count) 15 + 16 + ; VD.createDesktop(goThere:=true) ; VD.createUntil(howMany, goToLastlyCreated:=true) 17 + ; VD.removeDesktop(desktopNum, fallback_desktopNum:=false) 18 + 19 + ; "Show this window on all desktops" 20 + ; VD.IsWindowPinned(wintitle) 21 + ; VD.TogglePinWindow(wintitle) 22 + ; VD.PinWindow(wintitle) 23 + ; VD.UnPinWindow(wintitle) 24 + 25 + ; "Show windows from this app on all desktops" 26 + ; VD.IsAppPinned(wintitle) 27 + ; VD.TogglePinApp(wintitle) 28 + ; VD.PinApp(wintitle) 29 + ; VD.UnPinApp(wintitle) 30 + 31 + ; Thanks to: 32 + ; Blackholyman: 33 + ; https://www.autohotkey.com/boards/viewtopic.php?t=67642#p291160 34 + ; and 35 + ; Flipeador: 36 + ; https://www.autohotkey.com/boards/viewtopic.php?t=54202#p234192 37 + ; https://www.autohotkey.com/boards/viewtopic.php?t=54202#p234309 38 + ; and then later 39 + ; MScholtes: 40 + ; https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop.cs 41 + ; (for all the other functions I didnt know about. and windows 11) 42 + 43 + class VD { 44 + 45 + ; #Include %A_LineFile%\..\VD.ahk 46 + ; or 47 + ; #Include %A_LineFile%\..\_VD.ahk 48 + ; ...{startup code} 49 + ; VD.init() 50 + 51 + ; VD.ahk : calls `VD.init()` on #Include 52 + ; _VD.ahk : `VD.init()` when you want, like after a GUI has rendered, for startup performance reasons 53 + init() 54 + { 55 + splitByDot:=StrSplit(A_OSVersion, ".") 56 + buildNumber:=splitByDot[3] 57 + if (buildNumber < 22000) 58 + { 59 + ; Windows 10 60 + IID_IVirtualDesktopManagerInternal_:="{F31574D6-B682-4CDC-BD56-1827860ABEC6}" ;https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop.cs#L177-L191 61 + IID_IVirtualDesktop_:="{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}" ;https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop.cs#L149-L150 62 + ;conditionally assign method to method 63 + this._dll_GetCurrentDesktop:=this._dll_GetCurrentDesktop_Win10 64 + this._dll_GetDesktops:=this._dll_GetDesktops_Win10 65 + this._dll_CreateDesktop:=this._dll_CreateDesktop_Win10 66 + this._dll_GetName:=this._dll_GetName_Win10 67 + this.RegisterDesktopNotifications:=this.RegisterDesktopNotifications_Win10 68 + } 69 + else 70 + { 71 + ; Windows 11 72 + IID_IVirtualDesktopManagerInternal_:="{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}" ;https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop11.cs#L163-L185 73 + IID_IVirtualDesktop_:="{536D3495-B208-4CC9-AE26-DE8111275BF8}" ;https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop11.cs#L149-L150 74 + ;conditionally assign method to method 75 + this._dll_GetCurrentDesktop:=this._dll_GetCurrentDesktop_Win11 76 + this._dll_GetDesktops:=this._dll_GetDesktops_Win11 77 + this._dll_CreateDesktop:=this._dll_CreateDesktop_Win11 78 + this._dll_GetName:=this._dll_GetName_Win11 79 + this.RegisterDesktopNotifications:=this.RegisterDesktopNotifications_Win11 80 + } 81 + ;---------------------- 82 + this.IVirtualDesktopManager := ComObjCreate("{AA509086-5CA9-4C25-8F95-589D3C07B48A}", "{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}") 83 + this.GetWindowDesktopId := this._vtable(this.IVirtualDesktopManager, 4) 84 + this.MoveWindowToDesktop := this._vtable(this.IVirtualDesktopManager, 5) 85 + 86 + this.IServiceProvider := ComObjCreate("{C2F03A33-21F5-47FA-B4BB-156362A2F239}", "{6D5140C1-7436-11CE-8034-00AA006009FA}") 87 + 88 + this.IVirtualDesktopManagerInternal := ComObjQuery(this.IServiceProvider, "{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}", IID_IVirtualDesktopManagerInternal_) 89 + 90 + ; this.GetCount := this._vtable(this.IVirtualDesktopManagerInternal, 3 ; int GetCount(); 91 + this.MoveViewToDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 4) ; void MoveViewToDesktop(object pView, IVirtualDesktop desktop); 92 + this.CanViewMoveDesktops := this._vtable(this.IVirtualDesktopManagerInternal, 5) ; bool CanViewMoveDesktops(IApplicationView view); 93 + this.GetCurrentDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 6) ; IVirtualDesktop GetCurrentDesktop(); || IVirtualDesktop GetCurrentDesktop(IntPtr hWndOrMon); 94 + if (buildNumber < 22000) { 95 + ;Windows 10 https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop.cs#L177-L191 96 + 97 + this.GetDesktops := this._vtable(this.IVirtualDesktopManagerInternal, 7) ; void GetDesktops(out IObjectArray desktops); 98 + ; this.GetAdjacentDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 8) ; int GetAdjacentDesktop(IVirtualDesktop from, int direction, out IVirtualDesktop desktop); 99 + ; this.SwitchDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 9) ; void SwitchDesktop(IVirtualDesktop desktop); 100 + this.Ptr_CreateDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 10) ; IVirtualDesktop CreateDesktop(); 101 + this.Ptr_RemoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 11) ; void RemoveDesktop(IVirtualDesktop desktop, IVirtualDesktop fallback); 102 + this.FindDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 12) ; IVirtualDesktop FindDesktop(ref Guid desktopid); 103 + } else if (buildNumber < 22489) { 104 + ;Windows 11 https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop11.cs#L163-L185 105 + 106 + this.GetDesktops := this._vtable(this.IVirtualDesktopManagerInternal, 7) ; void GetDesktops(IntPtr hWndOrMon, out IObjectArray desktops); 107 + ; this.GetAdjacentDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 8) ; int GetAdjacentDesktop(IVirtualDesktop from, int direction, out IVirtualDesktop desktop); 108 + ; this.SwitchDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 9) ; void SwitchDesktop(IntPtr hWndOrMon, IVirtualDesktop desktop); 109 + this.Ptr_CreateDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 10) ; IVirtualDesktop CreateDesktop(IntPtr hWndOrMon); 110 + ; this.MoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 11) ; void MoveDesktop(IVirtualDesktop desktop, IntPtr hWndOrMon, int nIndex); 111 + this.Ptr_RemoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 12) ; void RemoveDesktop(IVirtualDesktop desktop, IVirtualDesktop fallback); 112 + this.FindDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 13) ; IVirtualDesktop FindDesktop(ref Guid desktopid); 113 + } else { 114 + ;Windows 11 Insider build 22489 https://github.com/MScholtes/VirtualDesktop/blob/9f3872e1275408a0802bdbe46df499bb7645dc87/VirtualDesktop11Insider.cs#L163-L186 115 + 116 + ; this.GetAllCurrentDesktops := this._vtable(this.IVirtualDesktopManagerInternal, 7) ; IObjectArray GetAllCurrentDesktops(); 117 + this.GetDesktops := this._vtable(this.IVirtualDesktopManagerInternal, 8) ; void GetDesktops(IntPtr hWndOrMon, out IObjectArray desktops); 118 + ; this.GetAdjacentDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 9) ; int GetAdjacentDesktop(IVirtualDesktop from, int direction, out IVirtualDesktop desktop); 119 + ; this.SwitchDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 10) ; void SwitchDesktop(IntPtr hWndOrMon, IVirtualDesktop desktop); 120 + this.Ptr_CreateDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 11) ; IVirtualDesktop CreateDesktop(IntPtr hWndOrMon); 121 + ; this.MoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 12) ; void MoveDesktop(IVirtualDesktop desktop, IntPtr hWndOrMon, int nIndex); 122 + this.Ptr_RemoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 13) ; void RemoveDesktop(IVirtualDesktop desktop, IVirtualDesktop fallback); 123 + this.FindDesktop := this._vtable(this.IVirtualDesktopManagerInternal, 14) ; IVirtualDesktop FindDesktop(ref Guid desktopid); 124 + } 125 + 126 + ;https://github.com/MScholtes/VirtualDesktop/blob/812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop.cs#L225-L234 127 + this.IVirtualDesktopPinnedApps := ComObjQuery(this.IServiceProvider, "{B5A399E7-1C87-46B8-88E9-FC5747B171BD}", "{4CE81583-1E4C-4632-A621-07A53543148F}") 128 + 129 + ; this.IsAppIdPinned := this._vtable(this.IVirtualDesktopPinnedApps, 3) ; bool IsAppIdPinned(string appId); 130 + ; this.PinAppID := this._vtable(this.IVirtualDesktopPinnedApps, 4) ; void PinAppID(string appId); 131 + ; this.UnpinAppID := this._vtable(this.IVirtualDesktopPinnedApps, 5) ; void UnpinAppID(string appId); 132 + this.IsViewPinned := this._vtable(this.IVirtualDesktopPinnedApps, 6) ; bool IsViewPinned(IApplicationView applicationView); 133 + this.PinView := this._vtable(this.IVirtualDesktopPinnedApps, 7) ; void PinView(IApplicationView applicationView); 134 + this.UnpinView := this._vtable(this.IVirtualDesktopPinnedApps, 8) ; void UnpinView(IApplicationView applicationView); 135 + 136 + 137 + ImmersiveShell := ComObjCreate("{C2F03A33-21F5-47FA-B4BB-156362A2F239}", "{00000000-0000-0000-C000-000000000046}") 138 + ; if !(IApplicationViewCollection := ComObjQuery(ImmersiveShell,"{1841C6D7-4F9D-42C0-AF41-8747538F10E5}" ) ) ; doesn't work 139 + ; SAME CLSID and IID ? 140 + ; wait it's not CLSID: 141 + ; SID 142 + ; A service identifier in the same form as IID. When omitting this parameter, also omit the comma. 143 + this.IApplicationViewCollection := ComObjQuery(ImmersiveShell,"{1841C6D7-4F9D-42C0-AF41-8747538F10E5}","{1841C6D7-4F9D-42C0-AF41-8747538F10E5}" ) 144 + if (!this.IApplicationViewCollection) ; 1607-1809 145 + { 146 + MsgBox IApplicationViewCollection interface not supported. 147 + } 148 + this.GetViewForHwnd := this._vtable(this.IApplicationViewCollection, 6) ; (IntPtr hwnd, out IApplicationView view); 149 + 150 + 151 + ;---------------------- 152 + 153 + ; VarSetCapacity(IID_IVirtualDesktop, 16) 154 + ; this will never be garbage collected 155 + this.Ptr_IID_IVirtualDesktop := DllCall( "GlobalAlloc", "UInt",0x00, "UInt", 16, "Ptr") 156 + DllCall("Ole32.dll\CLSIDFromString", "Str", IID_IVirtualDesktop_, "Ptr", this.Ptr_IID_IVirtualDesktop) 157 + 158 + ;---------------------- 159 + 160 + this.savedLocalizedWord_Desktop:=false 161 + 162 + } 163 + ;dll methods start 164 + _dll_GetCurrentDesktop_Win10() { 165 + IVirtualDesktop_ofCurrentDesktop := 0 166 + DllCall(this.GetCurrentDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr*", IVirtualDesktop_ofCurrentDesktop) 167 + return IVirtualDesktop_ofCurrentDesktop 168 + } 169 + _dll_GetCurrentDesktop_Win11() { 170 + IVirtualDesktop_ofCurrentDesktop := 0 171 + DllCall(this.GetCurrentDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", 0, "Ptr*", IVirtualDesktop_ofCurrentDesktop) 172 + return IVirtualDesktop_ofCurrentDesktop 173 + } 174 + _dll_GetDesktops_Win10() { 175 + IObjectArray := 0 176 + DllCall(this.GetDesktops, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr*", IObjectArray) 177 + return IObjectArray 178 + } 179 + _dll_GetDesktops_Win11() { 180 + IObjectArray := 0 181 + DllCall(this.GetDesktops, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", 0, "UPtr*", IObjectArray) 182 + return IObjectArray 183 + } 184 + _dll_CreateDesktop_Win10() { 185 + IVirtualDesktop_ofNewDesktop:=0 186 + DllCall(this.Ptr_CreateDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr*", IVirtualDesktop_ofNewDesktop) 187 + return IVirtualDesktop_ofNewDesktop 188 + } 189 + _dll_CreateDesktop_Win11() { 190 + IVirtualDesktop_ofNewDesktop:=0 191 + DllCall(this.Ptr_CreateDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", 0, "Ptr*", IVirtualDesktop_ofNewDesktop) 192 + return IVirtualDesktop_ofNewDesktop 193 + } 194 + _dll_GetName_Win10(IVirtualDesktop) { 195 + QueryInterface:=this._vtable(IVirtualDesktop, 0) 196 + VarSetCapacity(CLSID, 16) 197 + DllCall("Ole32.dll\CLSIDFromString", "Str","{31EBDE3F-6EC3-4CBD-B9FB-0EF6D09B41F4}", "Ptr",&CLSID) 198 + DllCall(QueryInterface, "UPtr",IVirtualDesktop, "Ptr",&CLSID, "Ptr*", IVirtualDesktop2) 199 + 200 + GetName:=this._vtable(IVirtualDesktop2,5) 201 + DllCall(GetName, "UPtr", IVirtualDesktop2, "Ptr*", Handle_DesktopName) 202 + if (Handle_DesktopName==0) { 203 + return "" ;you can't have empty desktopName so this can represent error 204 + } 205 + Ptr_DesktopName:=DllCall("combase\WindowsGetStringRawBuffer", "Ptr",Handle_DesktopName, "UInt*",length, "Ptr") 206 + desktopName:=StrGet(Ptr_DesktopName+0,"UTF-16") 207 + return desktopName 208 + } 209 + /* _dll_GetName_Win10(IVirtualDesktop) { 210 + GetId := this._vtable(IVirtualDesktop, 4) 211 + VarSetCapacity(GUID_Desktop, 16) 212 + DllCall(GetId, "UPtr",IVirtualDesktop, "Ptr",&GUID_Desktop) 213 + 214 + strGUID:=this._string_from_GUID(GUID_Desktop) 215 + KeyName:="HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops\Desktops\" strGUID 216 + ;RegRead gives "" on key not found, convenient 217 + RegRead, desktopName, % KeyName, % "Name" 218 + ; I don't like this because registry can be edited, then it wouldn't reflect the desktopName 219 + return desktopName 220 + } 221 + */ 222 + _dll_GetName_Win11(IVirtualDesktop) { 223 + GetName:=this._vtable(IVirtualDesktop,6) 224 + DllCall(GetName, "UPtr", IVirtualDesktop, "Ptr*", Handle_DesktopName) 225 + if (Handle_DesktopName==0) { 226 + return "" ;you can't have empty desktopName so this can represent error 227 + } 228 + Ptr_DesktopName:=DllCall("combase\WindowsGetStringRawBuffer", "Ptr",Handle_DesktopName, "UInt*",length, "Ptr") 229 + desktopName:=StrGet(Ptr_DesktopName+0,"UTF-16") 230 + return desktopName 231 + } 232 + ;dll methods end 233 + 234 + ;actual methods start 235 + getCount() { ;how many virtual desktops you now have 236 + return this._GetDesktops_Obj().GetCount() 237 + } 238 + 239 + goToDesktopNum(desktopNum) { ; Lej77 https://github.com/Grabacr07/VirtualDesktop/pull/23#issuecomment-334918711 240 + firstWindowId:=this._getFirstWindowInVD(desktopNum) 241 + 242 + Gui VD_animation_gui:New, % "-Border -SysMenu +Owner -Caption +HwndVD_animation_gui_hwnd_tmp" 243 + VD_animation_gui_hwnd:=VD_animation_gui_hwnd_tmp+0 244 + IVirtualDesktop := this._GetDesktops_Obj().GetAt(desktopNum) 245 + GetId:=this._vtable(IVirtualDesktop, 4) 246 + VarSetCapacity(GUID_Desktop, 16) 247 + DllCall(GetId, "Ptr", IVirtualDesktop, "Ptr", &GUID_Desktop) 248 + DllCall(this.MoveWindowToDesktop, "Ptr", this.IVirtualDesktopManager, "Ptr", VD_animation_gui_hwnd, "Ptr", &GUID_Desktop) 249 + DllCall("ShowWindow","Ptr",VD_animation_gui_hwnd,"Int",4) ;after gui on current desktop owned by current process became active window, Show gui on different desktop owned by current process 250 + this._WinActivate_NewProcess(VD_animation_gui_hwnd) 251 + loop 20 { 252 + if (this.getCurrentDesktopNum()==desktopNum) { ; wildest hack ever.. 253 + if (firstWindowId) { 254 + DllCall("SetForegroundWindow","Ptr",firstWindowId) 255 + } else { 256 + this._activateDesktopBackground() 257 + } 258 + break 259 + } 260 + Sleep 25 261 + } 262 + Gui VD_animation_gui:Destroy 263 + 264 + } 265 + 266 + _getLocalizedWord_Desktop() { 267 + if (this.savedLocalizedWord_Desktop) { 268 + return this.savedLocalizedWord_Desktop 269 + } 270 + 271 + hModule := DllCall("GetModuleHandle", "Str","shell32.dll", "Ptr") ;ahk always loads "shell32.dll" 272 + length:=DllCall("LoadString", "Uint",hModule, "Uint",21769, "Ptr*",lpBuffer, "Int",0) ;21769="Desktop" 273 + this.savedLocalizedWord_Desktop := StrGet(lpBuffer, length, "UTF-16") 274 + return this.savedLocalizedWord_Desktop 275 + } 276 + getNameFromDesktopNum(desktopNum) { 277 + IVirtualDesktop:=this._GetDesktops_Obj().GetAt(desktopNum) 278 + _name:=this._dll_GetName(IVirtualDesktop) 279 + if (!_name) { 280 + _name:=this._getLocalizedWord_Desktop() " " desktopNum 281 + } 282 + return _name 283 + } 284 + 285 + getDesktopNumOfWindow(wintitle) { 286 + found:=this._tryGetValidWindow(wintitle) 287 + if (!found) { 288 + return -1 ;for false 289 + } 290 + theHwnd:=found[1] 291 + 292 + desktopNum_ofWindow:=this._desktopNum_from_Hwnd(theHwnd) 293 + return desktopNum_ofWindow ; 0 for "Show on all desktops" 294 + } 295 + 296 + goToDesktopOfWindow(wintitle, activateYourWindow:=true) { 297 + found:=this._tryGetValidWindow(wintitle) 298 + if (!found) { 299 + return -1 ;for false 300 + } 301 + theHwnd:=found[1] 302 + 303 + desktopNum_ofWindow:=this._desktopNum_from_Hwnd(theHwnd) 304 + this.goToDesktopNum(desktopNum_ofWindow) 305 + 306 + if (activateYourWindow) { 307 + WinActivate, ahk_id %theHwnd% 308 + } 309 + } 310 + 311 + MoveWindowToDesktopNum(wintitle, desktopNum) { 312 + found:=this._tryGetValidWindow(wintitle) 313 + if (!found) { 314 + return -1 ;for false 315 + } 316 + theHwnd:=found[1] 317 + thePView:=found[2] 318 + 319 + needActivateWindowUnder:=false 320 + if (activeHwnd:=WinExist("A")) { 321 + if (activeHwnd==theHwnd) { 322 + currentDesktopNum:=this.getCurrentDesktopNum() 323 + if (!(currentDesktopNum==desktopNum)) { 324 + needActivateWindowUnder:=true 325 + } 326 + } 327 + } 328 + 329 + IVirtualDesktop:=this._GetDesktops_Obj().GetAt(desktopNum) 330 + DllCall(this.MoveViewToDesktop, "ptr", this.IVirtualDesktopManagerInternal, "Ptr", thePView, "Ptr", IVirtualDesktop) 331 + 332 + if (needActivateWindowUnder) { 333 + firstWindowId:=this._getFirstWindowInVD(currentDesktopNum, theHwnd) 334 + if (firstWindowId) { 335 + VD._WinActivate_NewProcess(firstWindowId) 336 + } else { 337 + this._activateDesktopBackground() 338 + } 339 + } 340 + 341 + } 342 + 343 + getRelativeDesktopNum(anchor_desktopNum, relative_count) 344 + { 345 + Desktops_Obj:=this._GetDesktops_Obj() 346 + count_Desktops:=Desktops_Obj.GetCount() 347 + 348 + absolute_desktopNum:=anchor_desktopNum + relative_count 349 + ;// The 1-based indices wrap around on the first and last desktop. 350 + ;// say count_Desktops:=3 351 + absolute_desktopNum:=Mod(absolute_desktopNum, count_Desktops) 352 + ; 4 -> 1 353 + if (absolute_desktopNum <= 0) { 354 + ; 0 -> 3 355 + absolute_desktopNum:=absolute_desktopNum + count_Desktops 356 + } 357 + 358 + return absolute_desktopNum 359 + } 360 + 361 + MoveWindowToRelativeDesktopNum(wintitle, relative_count) { 362 + 363 + desktopNum_ofWindow := this.getDesktopNumOfWindow(wintitle) 364 + absolute_desktopNum := this.getRelativeDesktopNum(desktopNum_ofWindow, relative_count) 365 + 366 + this.MoveWindowToDesktopNum(wintitle, absolute_desktopNum) 367 + 368 + return absolute_desktopNum 369 + } 370 + 371 + gotoRelativeDesktopNum(relative_count) { 372 + this.goToDesktopNum(this.getRelativeDesktopNum(this.getCurrentDesktopNum(), relative_count)) 373 + } 374 + 375 + MoveWindowToCurrentDesktop(wintitle, activateYourWindow:=true) { 376 + found:=this._tryGetValidWindow(wintitle) 377 + if (!found) { 378 + return -1 ;for false 379 + } 380 + theHwnd:=found[1] 381 + thePView:=found[2] 382 + 383 + currentDesktopNum:=this.getCurrentDesktopNum() 384 + IVirtualDesktop:=this._GetDesktops_Obj().GetAt(currentDesktopNum) 385 + 386 + DllCall(this.MoveViewToDesktop, "ptr", this.IVirtualDesktopManagerInternal, "Ptr", thePView, "Ptr", IVirtualDesktop) 387 + 388 + if (activateYourWindow) { 389 + WinActivate % "ahk_id " theHwnd 390 + } 391 + } 392 + 393 + getCurrentDesktopNum() { 394 + IVirtualDesktop_ofCurrentDesktop:=this._dll_GetCurrentDesktop() 395 + 396 + desktopNum:=this._desktopNum_from_IVirtualDesktop(IVirtualDesktop_ofCurrentDesktop) 397 + return desktopNum 398 + } 399 + 400 + createDesktop(goThere:=false) { 401 + IVirtualDesktop_ofNewDesktop:=this._dll_CreateDesktop() 402 + 403 + if (goThere) { 404 + ;we could assume that it's the rightmost desktop: 405 + ; desktopNum:=this.getCount() 406 + ;but I'm not risking it 407 + desktopNum:=this._desktopNum_from_IVirtualDesktop(IVirtualDesktop_ofNewDesktop) 408 + this.goToDesktopNum(desktopNum) 409 + } 410 + } 411 + 412 + createUntil(howMany, goToLastlyCreated:=false) { 413 + howManyThereAlreadyAre:=this.getCount() 414 + if (howManyThereAlreadyAre>=howMany) { 415 + return 416 + } 417 + 418 + ;this will create until one less than wanted 419 + loop % howMany - howManyThereAlreadyAre - 1 { 420 + this.createDesktop(false) 421 + } 422 + this.createDesktop(goToLastlyCreated) 423 + } 424 + 425 + removeDesktop(desktopNum, fallback_desktopNum:=false) { 426 + ;FALLBACK IS ONLY USED IF YOU ARE CURRENTLY ON THE VD BEING DELETED 427 + ;but we NEED a fallback, regardless, so I'm not checking if you are currently on the vd being deleted 428 + 429 + Desktops_Obj:=this._GetDesktops_Obj() 430 + 431 + ;if no fallback, 432 + if (!fallback_desktopNum) { 433 + 434 + ;look left 435 + if (desktopNum > 1) { 436 + fallback_desktopNum:=desktopNum - 1 437 + } 438 + ;look right 439 + else if (desktopNum < Desktops_Obj.GetCount()) { 440 + fallback_desktopNum:=desktopNum + 1 441 + } 442 + ;no fallback to go to 443 + else { 444 + return false 445 + } 446 + } 447 + 448 + IVirtualDesktop:=Desktops_Obj.GetAt(desktopNum) 449 + IVirtualDesktop_fallback:=Desktops_Obj.GetAt(fallback_desktopNum) 450 + 451 + DllCall(this.Ptr_RemoveDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", IVirtualDesktop, "Ptr", IVirtualDesktop_fallback) 452 + } 453 + 454 + IsWindowPinned(wintitle) { 455 + found:=this._tryGetValidWindow(wintitle) 456 + if (!found) { 457 + return -1 ;for false 458 + } 459 + thePView:=found[2] 460 + 461 + viewIsPinned:=this._IsViewPinned(thePView) 462 + return viewIsPinned 463 + } 464 + TogglePinWindow(wintitle) { 465 + found:=this._tryGetValidWindow(wintitle) 466 + if (!found) { 467 + return -1 ;for false 468 + } 469 + thePView:=found[2] 470 + 471 + viewIsPinned:=this._IsViewPinned(thePView) 472 + if (viewIsPinned) { 473 + DllCall(this.UnPinView, "UPtr", this.IVirtualDesktopPinnedApps, "Ptr", thePView) 474 + } else { 475 + DllCall(this.PinView, "UPtr", this.IVirtualDesktopPinnedApps, "Ptr", thePView) 476 + } 477 + 478 + } 479 + PinWindow(wintitle) { 480 + found:=this._tryGetValidWindow(wintitle) 481 + if (!found) { 482 + return -1 ;for false 483 + } 484 + thePView:=found[2] 485 + 486 + DllCall(this.PinView, "UPtr", this.IVirtualDesktopPinnedApps, "Ptr", thePView) 487 + } 488 + UnPinWindow(wintitle) { 489 + found:=this._tryGetValidWindow(wintitle) 490 + if (!found) { 491 + return -1 ;for false 492 + } 493 + thePView:=found[2] 494 + 495 + DllCall(this.UnPinView, "UPtr", this.IVirtualDesktopPinnedApps, "Ptr", thePView) 496 + } 497 + 498 + ; COM class start ;https://github.com/Ciantic/VirtualDesktopAccessor/blob/5bc1bbaab247b5d72e70abc9432a15275fd2d229/VirtualDesktopAccessor/dllmain.h#L718-L794 499 + _QueryInterface_Win10(riid, ppvObject) { 500 + if (!ppvObject) { 501 + return 0x80070057 ;E_INVALIDARG 502 + } 503 + 504 + str_IID_IUnknown:="{00000000-0000-0000-C000-000000000046}" 505 + str_IID_IVirtualDesktopNotification:="{C179334C-4295-40D3-BEA1-C654D965605A}" 506 + 507 + VarSetCapacity(someStr, 40*2) 508 + DllCall("Ole32\StringFromGUID2", "Ptr", riid, "Ptr",&someStr, "Ptr",40) 509 + str_riid:=StrGet(&someStr) 510 + 511 + if (str_riid==str_IID_IUnknown || str_riid==str_IID_IVirtualDesktopNotification) { 512 + NumPut(this, ppvObject+0, 0, "Ptr") 513 + VD._AddRef_Same.Call(this) 514 + return 0 ;S_OK 515 + } 516 + ; *ppvObject = NULL; 517 + NumPut(0, ppvObject+0, 0, "Ptr") 518 + return 0x80004002 ;E_NOINTERFACE 519 + 520 + ; // Always set out parameter to NULL, validating it first. 521 + ; if (!ppvObject) 522 + ; return E_INVALIDARG; 523 + ; *ppvObject = NULL; 524 + ; 525 + ; if (riid == IID_IUnknown || riid == IID_IVirtualDesktopNotification) 526 + ; { 527 + ; // Increment the reference count and return the pointer. 528 + ; *ppvObject = (LPVOID)this; 529 + ; AddRef(); 530 + ; return S_OK; 531 + ; } 532 + ; return E_NOINTERFACE; 533 + } 534 + _AddRef_Same() { 535 + refCount:=NumGet(this+0, A_PtrSize, "UInt") 536 + refCount++ 537 + NumPut(refCount, this+0, A_PtrSize, "UInt") 538 + ; NumPut(this + 4) 539 + ; refCount:= 540 + 541 + ; return InterlockedIncrement(&_referenceCount); 542 + return refCount 543 + } 544 + _Release_Same() { 545 + refCount:=NumGet(this+0, A_PtrSize, "UInt") 546 + refCount-- 547 + NumPut(refCount, this+0, A_PtrSize, "UInt") 548 + ; ULONG result = InterlockedDecrement(&_referenceCount); 549 + ; if (result == 0) 550 + ; { 551 + ; delete this; 552 + ; } 553 + return refCount 554 + } 555 + _VirtualDesktopCreated_Win10(pDesktop) { 556 + ; Tooltip % 11111 557 + VD.VirtualDesktopCreated.Call(VD._desktopNum_from_IVirtualDesktop(pDesktop)) 558 + return 0 ;S_OK 559 + } 560 + _VirtualDesktopDestroyBegin_Win10(pDesktopDestroyed, pDesktopFallback) { 561 + ; Tooltip % 22222 562 + VD.VirtualDesktopDestroyBegin.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopDestroyed), VD._desktopNum_from_IVirtualDesktop(pDesktopFallback)) 563 + return 0 ;S_OK 564 + } 565 + _VirtualDesktopDestroyFailed_Win10(pDesktopDestroyed, pDesktopFallback) { 566 + ; Tooltip % 33333 567 + VD.VirtualDesktopDestroyFailed.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopDestroyed), VD._desktopNum_from_IVirtualDesktop(pDesktopFallback)) 568 + return 0 ;S_OK 569 + } 570 + _VirtualDesktopDestroyed_Win10(pDesktopDestroyed, pDesktopFallback) { 571 + ; Tooltip % 44444 572 + VD.VirtualDesktopDestroyed.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopDestroyed), VD._desktopNum_from_IVirtualDesktop(pDesktopFallback)) 573 + return 0 ;S_OK 574 + } 575 + _ViewVirtualDesktopChanged_Win10(pView) { 576 + ; Tooltip % 55555 577 + VD.ViewVirtualDesktopChanged.Call(pView) 578 + return 0 ;S_OK 579 + } 580 + _CurrentVirtualDesktopChanged_Win10(pDesktopOld, pDesktopNew) { 581 + VD.CurrentVirtualDesktopChanged.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopOld), VD._desktopNum_from_IVirtualDesktop(pDesktopNew)) 582 + return 0 ;S_OK 583 + } 584 + RegisterDesktopNotifications_Win10() { ;https://github.com/Ciantic/VirtualDesktopAccessor/blob/5bc1bbaab247b5d72e70abc9432a15275fd2d229/VirtualDesktopAccessor/dllmain.h#L718-L794 585 + methods:=DllCall("GlobalAlloc", "Uint",0x00, "Uint",9*A_PtrSize) ;PLEASE DON'T GARBAGE COLLECT IT, this took me hours to debug, I was lucky ahkv2 garbage collected slowly 586 + NumPut(RegisterCallback("VD._QueryInterface_Win10", "F"), methods+0, 0*A_PtrSize, "Ptr") 587 + NumPut(RegisterCallback("VD._AddRef_Same", "F"), methods+0, 1*A_PtrSize, "Ptr") 588 + NumPut(RegisterCallback("VD._Release_Same", "F"), methods+0, 2*A_PtrSize, "Ptr") 589 + NumPut(RegisterCallback("VD._VirtualDesktopCreated_Win10", "F"), methods+0, 3*A_PtrSize, "Ptr") 590 + NumPut(RegisterCallback("VD._VirtualDesktopDestroyBegin_Win10", "F"), methods+0, 4*A_PtrSize, "Ptr") 591 + NumPut(RegisterCallback("VD._VirtualDesktopDestroyFailed_Win10", "F"), methods+0, 5*A_PtrSize, "Ptr") 592 + NumPut(RegisterCallback("VD._VirtualDesktopDestroyed_Win10", "F"), methods+0, 6*A_PtrSize, "Ptr") 593 + NumPut(RegisterCallback("VD._ViewVirtualDesktopChanged_Win10", "F"), methods+0, 7*A_PtrSize, "Ptr") 594 + NumPut(RegisterCallback("VD._CurrentVirtualDesktopChanged_Win10", "F"), methods+0, 8*A_PtrSize, "Ptr") 595 + 596 + this.RegisterDesktopNotifications_Same(methods) 597 + } 598 + ;COM class for Win11 599 + _QueryInterface_Win11(riid, ppvObject) { 600 + if (!ppvObject) { 601 + return 0x80070057 ;E_INVALIDARG 602 + } 603 + 604 + str_IID_IUnknown:="{00000000-0000-0000-C000-000000000046}" 605 + str_IID_IVirtualDesktopNotification:="{CD403E52-DEED-4C13-B437-B98380F2B1E8}" 606 + 607 + VarSetCapacity(someStr, 40*2) 608 + DllCall("Ole32\StringFromGUID2", "Ptr", riid, "Ptr",&someStr, "Ptr",40) 609 + str_riid:=StrGet(&someStr) 610 + 611 + if (str_riid==str_IID_IUnknown || str_riid==str_IID_IVirtualDesktopNotification) { 612 + NumPut(this, ppvObject+0, 0, "Ptr") 613 + VD._AddRef_Same.Call(this) 614 + return 0 ;S_OK 615 + } 616 + ; *ppvObject = NULL; 617 + NumPut(0, ppvObject+0, 0, "Ptr") 618 + return 0x80004002 ;E_NOINTERFACE 619 + } 620 + _VirtualDesktopCreated_Win11(p0, pDesktop) { 621 + ; Tooltip % 11111 622 + VD.VirtualDesktopCreated.Call(VD._desktopNum_from_IVirtualDesktop(pDesktop)) 623 + return 0 ;S_OK 624 + } 625 + _VirtualDesktopDestroyBegin_Win11(p0, pDesktopDestroyed, pDesktopFallback) { 626 + ; Tooltip % 22222 627 + VD.VirtualDesktopDestroyBegin.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopDestroyed), VD._desktopNum_from_IVirtualDesktop(pDesktopFallback)) 628 + return 0 ;S_OK 629 + } 630 + _VirtualDesktopDestroyFailed_Win11(p0, pDesktopDestroyed, pDesktopFallback) { 631 + ; Tooltip % 33333 632 + VD.VirtualDesktopDestroyFailed.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopDestroyed), VD._desktopNum_from_IVirtualDesktop(pDesktopFallback)) 633 + return 0 ;S_OK 634 + } 635 + _VirtualDesktopDestroyed_Win11(p0, pDesktopDestroyed, pDesktopFallback) { 636 + ; Tooltip % 44444 637 + VD.VirtualDesktopDestroyed.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopDestroyed), VD._desktopNum_from_IVirtualDesktop(pDesktopFallback)) 638 + return 0 ;S_OK 639 + } 640 + _ViewVirtualDesktopChanged_Win11(pView) { 641 + ; Tooltip % 55555 642 + VD.ViewVirtualDesktopChanged.Call(pView) 643 + return 0 ;S_OK 644 + } 645 + _CurrentVirtualDesktopChanged_Win11(p0, pDesktopOld, pDesktopNew) { 646 + VD.CurrentVirtualDesktopChanged.Call(VD._desktopNum_from_IVirtualDesktop(pDesktopOld), VD._desktopNum_from_IVirtualDesktop(pDesktopNew)) 647 + return 0 ;S_OK 648 + } 649 + _No_Op() { 650 + } 651 + RegisterDesktopNotifications_Win11() { 652 + methods:=DllCall("GlobalAlloc", "Uint",0x00, "Uint",13*A_PtrSize) ;PLEASE DON'T GARBAGE COLLECT IT, this took me hours to debug, I was lucky ahkv2 garbage collected slowly 653 + ; Thanks to mntone for IID and signatures https://mntone.hateblo.jp/entry/2021/05/23/121028#IVirtualDesktopNotification-3 654 + ; Thanks to NyaMisty for explanation https://github.com/mntone/VirtualDesktop/pull/1#issuecomment-922269079 655 + NumPut(RegisterCallback("VD._QueryInterface_Win11", "F"), methods+0, 0*A_PtrSize, "Ptr") 656 + NumPut(RegisterCallback("VD._AddRef_Same", "F"), methods+0, 1*A_PtrSize, "Ptr") 657 + NumPut(RegisterCallback("VD._Release_Same", "F"), methods+0, 2*A_PtrSize, "Ptr") 658 + NumPut(RegisterCallback("VD._VirtualDesktopCreated_Win11", "F"), methods+0, 3*A_PtrSize, "Ptr") 659 + NumPut(RegisterCallback("VD._VirtualDesktopDestroyBegin_Win11", "F"), methods+0, 4*A_PtrSize, "Ptr") 660 + NumPut(RegisterCallback("VD._VirtualDesktopDestroyFailed_Win11", "F"), methods+0, 5*A_PtrSize, "Ptr") 661 + NumPut(RegisterCallback("VD._VirtualDesktopDestroyed_Win11", "F"), methods+0, 6*A_PtrSize, "Ptr") 662 + ; NumPut(RegisterCallback("VD._VirtualDesktopIsPerMonitorChanged_Win11", "F"), methods+0, 7*A_PtrSize, "Ptr") 663 + NumPut(RegisterCallback("VD._No_Op", "F"), methods+0, 7*A_PtrSize, "Ptr") 664 + ; NumPut(RegisterCallback("VD._VirtualDesktopMoved_Win11", "F"), methods+0, 8*A_PtrSize, "Ptr") 665 + NumPut(RegisterCallback("VD._No_Op", "F"), methods+0, 8*A_PtrSize, "Ptr") 666 + ; NumPut(RegisterCallback("VD._VirtualDesktopNameChanged_Win11", "F"), methods+0, 9*A_PtrSize, "Ptr") 667 + NumPut(RegisterCallback("VD._No_Op", "F"), methods+0, 9*A_PtrSize, "Ptr") 668 + NumPut(RegisterCallback("VD._ViewVirtualDesktopChanged_Win11", "F"), methods+0, 10*A_PtrSize, "Ptr") 669 + NumPut(RegisterCallback("VD._CurrentVirtualDesktopChanged_Win11", "F"), methods+0, 11*A_PtrSize, "Ptr") 670 + ; NumPut(RegisterCallback("VD._VirtualDesktopWallpaperChanged_Win11", "F"), methods+0, 12*A_PtrSize, "Ptr") 671 + NumPut(RegisterCallback("VD._No_Op", "F"), methods+0, 12*A_PtrSize, "Ptr") 672 + 673 + this.RegisterDesktopNotifications_Same(methods) 674 + } 675 + RegisterDesktopNotifications_Same(methods) { 676 + obj:=DllCall("GlobalAlloc", "Uint",0x00, "Uint",A_PtrSize + 4) ;PLEASE DON'T GARBAGE COLLECT IT, this took me hours to debug, I was lucky ahkv2 garbage collected slowly 677 + NumPut(methods, obj+0, 0, "Ptr") 678 + NumPut(0, obj+0, A_PtrSize, "UInt") ;refCount 679 + 680 + pDesktopNotificationService := ComObjQuery(this.IServiceProvider, "{A501FDEC-4A09-464C-AE4E-1B9C21B84918}", "{0CD45E71-D927-4F15-8B0A-8FEF525337BF}") 681 + Register:=this._vtable(pDesktopNotificationService, 3) 682 + HRESULT:=DllCall(Register,"UPtr",pDesktopNotificationService, "Ptr",obj, "Uint*",pdwCookie:=0) 683 + ; ok1:=ErrorLevel 684 + ; ok2:=A_LastError 685 + ; ok:=0 686 + 687 + ; HRESULT hrNotificationService = pServiceProvider->QueryService( 688 + ; CLSID_IVirtualNotificationService, 689 + ; __uuidof(IVirtualDesktopNotificationService), 690 + ; (PVOID*)&pDesktopNotificationService); 691 + } 692 + 693 + VirtualDesktopCreated(desktopNum:=0) { 694 + } 695 + VirtualDesktopDestroyBegin(desktopNum_Destroyed:=0, desktopNum_Fallback:=0) { 696 + } 697 + VirtualDesktopDestroyFailed(desktopNum_Destroyed:=0, desktopNum_Fallback:=0) { 698 + } 699 + VirtualDesktopDestroyed(desktopNum_Destroyed:=0, desktopNum_Fallback:=0) { 700 + } 701 + ViewVirtualDesktopChanged(pView:=0) { 702 + } 703 + CurrentVirtualDesktopChanged(desktopNum_Old:=0, desktopNum_New:=0) { 704 + } 705 + 706 + ; <Run in VD 707 + startShellMessage() { 708 + ; https://www.autohotkey.com/boards/viewtopic.php?t=63424#p271528 709 + DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd) 710 + MsgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK") 711 + OnMessage(MsgNum, func("VD.ShellMessage").bind(this)) 712 + 713 + ; this.map_title_class:={"":{"":{"Hourglass.exe":func("VD.callback").bind(this, 2)}}} 714 + this.map_title_class:={} 715 + } 716 + 717 + Run(Target, WorkingDir, this_titleName, this_class, this_processName, desktopNum) { 718 + this.addToWaitNewWindow(this_titleName, this_class, this_processName, func("VD.callback_MoveWindow").bind(this, desktopNum)) 719 + 720 + Run % Target, % WorkingDir 721 + } 722 + 723 + Run_lock_VD(Target, WorkingDir, this_titleName, this_class, this_processName, window_desktopNum, your_desktopNum) { 724 + this.addToWaitNewWindow(this_titleName, this_class, this_processName, func("VD.callback_MoveWindow_lockVD").bind(this, [window_desktopNum, your_desktopNum])) 725 + 726 + Run % Target, % WorkingDir 727 + } 728 + 729 + addToWaitNewWindow(this_titleName, this_class, this_processName, callback) { 730 + map_class_processName:=this.map_title_class.HasKey(this_titleName) ? this.map_title_class[this_titleName] : this.map_title_class[this_titleName]:={} 731 + map_processName_data:=map_class_processName.HasKey(this_class) ? map_class_processName[this_class] : map_class_processName[this_class]:={} 732 + arrOfCallback:=map_processName_data.HasKey(this_processName) ? map_processName_data[this_processName] : map_processName_data[this_processName]:=[] 733 + arrOfCallback.Push(callback) 734 + } 735 + 736 + callback_MoveWindow(desktopNum, hwnd) { 737 + WinActivate % "ahk_id " hwnd 738 + this.MoveWindowToDesktopNum("ahk_id " hwnd,desktopNum) 739 + } 740 + 741 + callback_MoveWindow_lockVD(tuple, hwnd) { 742 + window_desktopNum:=tuple[1] 743 + your_desktopNum:=tuple[2] 744 + WinActivate % "ahk_id " hwnd 745 + this.goToDesktopNum(your_desktopNum) 746 + WinActivate % "ahk_id " hwnd 747 + this.MoveWindowToDesktopNum("ahk_id " hwnd,window_desktopNum) 748 + WinActivate % "ahk_id " hwnd 749 + } 750 + 751 + ShellMessage(wParam, lParam, msg, hwnd) { 752 + Critical ;this is what makes many callbacks AT THE SAME TIME possible 753 + Sleep 100 ;necessary 754 + 755 + if (wParam == 1) { ; HSHELL_WINDOWCREATED := 1, HSHELL_MONITORCHANGED := 16 756 + theHwnd:=lParam 757 + 758 + bak_DetectHiddenWindows := A_DetectHiddenWindows 759 + DetectHiddenWindows, ON ;very important 760 + 761 + arrOfCallback:=false 762 + outside_map_processName_data:=false 763 + outside_map_class_processName:=false 764 + outside_subString_title:=false 765 + 766 + WinGetTitle, this_title, % "ahk_id " theHwnd 767 + for subString_title, map_class_processName in this.map_title_class { 768 + if (InStr(this_title, subString_title, true)) { 769 + WinGetClass, this_class, % "ahk_id " theHwnd 770 + for subString_class, map_processName_data in map_class_processName { 771 + if (InStr(this_class, subString_class, true)) { 772 + WinGet, this_processName, ProcessName, % "ahk_id " theHwnd 773 + for subString_processName, possibly_arrOfCallback in map_processName_data { 774 + if (InStr(this_processName, subString_processName, true)) { 775 + arrOfCallback:=possibly_arrOfCallback 776 + outside_map_processName_data:=map_processName_data 777 + outside_map_class_processName:=map_class_processName 778 + outside_subString_title:=subString_title 779 + break 780 + } 781 + } 782 + break 783 + } 784 + } 785 + break 786 + } 787 + } 788 + 789 + DetectHiddenWindows % bak_DetectHiddenWindows 790 + 791 + if (arrOfCallback) { 792 + callback:=arrOfCallback[1] 793 + callback.Call(theHwnd) 794 + 795 + if (arrOfCallback.Length() > 1) { 796 + arrOfCallback.RemoveAt(1) 797 + } else if (outside_map_processName_data.Count() > 1) { 798 + outside_map_processName_data.Delete(subString_processName) 799 + } else if (outside_map_class_processName.Count() > 1) { 800 + outside_map_class_processName.Delete(subString_class) 801 + } else { 802 + this.map_title_class.Delete(outside_subString_title) 803 + } 804 + 805 + } 806 + } 807 + } 808 + ; Run in VD> 809 + 810 + ;actual methods end 811 + 812 + ;internal methods start 813 + 814 + _WinActivate_NewProcess(hWnd) { 815 + ; WinActivate of AHK will first try SetForegroundWindow(), it will work if the keyboard hook is not used 816 + ; so it will work for 817 + ; Numpad2:: 818 + ; it will not work for 819 + ; ^#Right:: 820 + ; Right always uses the keyboard hook 821 + 822 + ; AHK will then try AttachThreadInput(), it works reliably, but fails for Teams.exe for reasons I have yet to uncover 823 + ; let's just say that either Teams.exe is resistant to AttachThreadInput, or the code inside Teams.exe has a weird defined behavior once AttachThreadInput is called 824 + 825 + ; this ? there's only one way to find out how well it works, by testing in production 826 + ; attempt Number 2 827 + ; new Thread doesn't work, somehow new Process works 828 + 829 + foregroundWindow:=DllCall("GetForegroundWindow","Ptr") 830 + threadID:=DllCall("GetWindowThreadProcessId","Ptr",foregroundWindow,"Uint*",PID) 831 + currentThreadID:=DllCall("GetCurrentThreadId") 832 + if (threadID==currentThreadID) { 833 + DllCall("SetForegroundWindow","Ptr",hWnd) 834 + } else { 835 + loop 10 { 836 + Run % """" A_LineFile "\..\SetForeGroundWindow.exe"" " hWnd 837 + if (DllCall("GetForegroundWindow","Ptr")==hWnd) { 838 + break 839 + } 840 + Sleep 10 841 + if (DllCall("GetForegroundWindow","Ptr")==hWnd) { 842 + break 843 + } 844 + } 845 + } 846 + } 847 + 848 + _activateDesktopBackground() { ;this is really copying extremely long comments for short code like in AHK source code 849 + ; Win10: 850 + ; "FolderView ahk_class SysListView32 ahk_exe explorer.exe" 851 + ; "ahk_class SHELLDLL_DefView ahk_exe explorer.exe" 852 + ; "Program Manager ahk_class Progman ahk_exe explorer.exe" is the top level parent 853 + 854 + ; the parent parent of FolderView BECOMES "ahk_class WorkerW ahk_exe explorer.exe" after you press Win+Tab 855 + ; WorkerW doesn't exist before you press Win+Tab 856 + ; it's the same for Win11, Progman gets replaced by WorkerW, Progman still exists but isn't the parent of FolderView or top-level window that gets activated 857 + 858 + ; Q: if WinActivate Progman activates WorkerW(we want that) then what's the problem ? 859 + ; A: WinActivate will send {Alt down}{Alt up}{Alt down}{Alt up} if Progman is not activated : AHK source code: ((VK_MENU | 0x12 | ALT key)) https://github.com/AutoHotkey/AutoHotkey/blob/df84a3e902b522db0756a7366bd9884c80fa17b6/source/window.cpp#L260-L261 860 + ; the desktop background is correctly activated, we just don't want the extra Alt keys: 861 + ; if the hotkey is Ctrl+Shift+Win, and you add an Alt in there, Office 365 hotkey is triggered: 862 + ; https://github.com/FuPeiJiang/VD.ahk/issues/40#issuecomment-1548252485 863 + ; https://answers.microsoft.com/en-us/msoffice/forum/all/help-disabling-office-hotkey-of-ctrl-win-alt-shift/040ef6e5-8152-449b-849a-7494323101bb 864 + ; https://superuser.com/questions/1457073/how-do-i-disable-specific-windows-10-office-keyboard-shortcut-ctrlshiftwinal 865 + ; this is also bad because it prevents subsequent uses of the hotkey #!Right:: because {Alt up} releases Alt 866 + ; if (WinExist("ahk_class WorkerW ahk_exe explorer.exe")) { 867 + ; WinActivate % "ahk_class WorkerW ahk_exe explorer.exe" 868 + ; } else { 869 + ; WinActivate % "ahk_class Progman ahk_exe explorer.exe" 870 + ; } 871 + DllCall("SetForegroundWindow","Ptr",WinExist("ahk_class Progman ahk_exe explorer.exe")) 872 + } 873 + 874 + _getFirstWindowInVD(desktopNum, excludeHwnd:=0) { 875 + bak_DetectHiddenWindows:=A_DetectHiddenWindows 876 + DetectHiddenWindows, on 877 + returnValue:=0 878 + WinGet, outHwndList, List 879 + VarSetCapacity(GUID_Desktop, 16) 880 + Desktops_Obj:=this._GetDesktops_Obj() 881 + IVirtualDesktop:=Desktops_Obj.GetAt(desktopNum) 882 + loop % outHwndList { 883 + theHwnd:=outHwndList%A_Index%+0 884 + if (theHwnd==excludeHwnd) { 885 + continue 886 + } 887 + arr_success_pView_hWnd:=this._isValidWindow(theHwnd) 888 + if (arr_success_pView_hWnd[1]==0) { 889 + pView:=arr_success_pView_hWnd[2] 890 + WinGet, OutputVar_MinMax, MinMax, % "ahk_id " theHwnd 891 + if (!(OutputVar_MinMax==-1)) { ;not Minimized 892 + 893 + HRESULT := DllCall(this.GetWindowDesktopId, "UPtr", this.IVirtualDesktopManager, "Ptr", theHwnd, "Ptr", &GUID_Desktop) 894 + if (!(HRESULT==0)) { 895 + continue 896 + } 897 + DllCall(this.FindDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", &GUID_Desktop, "Ptr*", IVirtualDesktop_ofWindow) 898 + if (IVirtualDesktop_ofWindow == IVirtualDesktop) { 899 + ; WinActivate % "ahk_id " theHwnd 900 + returnValue:=theHwnd 901 + break 902 + } 903 + } 904 + } 905 + } 906 + DetectHiddenWindows % bak_DetectHiddenWindows 907 + return returnValue 908 + } 909 + 910 + _tryGetValidWindow(wintitle) { 911 + bak_DetectHiddenWindows:=A_DetectHiddenWindows 912 + bak_TitleMatchMode:=A_TitleMatchMode 913 + DetectHiddenWindows, on 914 + SetTitleMatchMode, 2 915 + WinGet, outHwndList, List, % wintitle 916 + returnValue:=false 917 + loop % outHwndList { 918 + theHwnd:=outHwndList%A_Index%+0 919 + arr_success_pView_hWnd:=this._isValidWindow(theHwnd) 920 + pView:=arr_success_pView_hWnd[2] 921 + if (pView) { 922 + returnValue:=[arr_success_pView_hWnd[3], pView] 923 + break 924 + } 925 + } 926 + 927 + SetTitleMatchMode % bak_TitleMatchMode 928 + DetectHiddenWindows % bak_DetectHiddenWindows 929 + return returnValue 930 + } 931 + 932 + _view_from_Hwnd(theHwnd) { 933 + pView := 0 934 + DllCall(this.GetViewForHwnd, "UPtr", this.IApplicationViewCollection, "Ptr", theHwnd, "Ptr*", pView) 935 + return pView 936 + } 937 + 938 + _IVirtualDesktop_from_Hwnd(theHwnd) { 939 + VarSetCapacity(GUID_Desktop, 16) 940 + HRESULT := DllCall(this.GetWindowDesktopId, "UPtr", this.IVirtualDesktopManager, "Ptr", theHwnd, "Ptr", &GUID_Desktop) 941 + if (!(HRESULT==0)) { 942 + return false 943 + } 944 + 945 + IVirtualDesktop_ofWindow:=0 946 + DllCall(this.FindDesktop, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", &GUID_Desktop, "Ptr*", IVirtualDesktop_ofWindow) 947 + 948 + return IVirtualDesktop_ofWindow 949 + } 950 + 951 + _desktopNum_from_IVirtualDesktop(IVirtualDesktop) { 952 + Desktops_Obj:=this._GetDesktops_Obj() 953 + Loop % Desktops_Obj.GetCount() 954 + { 955 + IVirtualDesktop_ofDesktop:=Desktops_Obj.GetAt(A_Index) 956 + 957 + if (IVirtualDesktop_ofDesktop == IVirtualDesktop) { 958 + return A_Index 959 + } 960 + } 961 + return 0 ;for "Show on all desktops" 962 + } 963 + 964 + _desktopNum_from_Hwnd(theHwnd) { 965 + IVirtualDesktop:=this._IVirtualDesktop_from_Hwnd(theHwnd) 966 + desktopNum:=this._desktopNum_from_IVirtualDesktop(IVirtualDesktop) 967 + return desktopNum 968 + } 969 + 970 + _GetDesktops_Obj() { 971 + IObjectArray:=this._dll_GetDesktops() 972 + return new this.IObjectArray_Wrapper(IObjectArray, this.Ptr_IID_IVirtualDesktop) 973 + } 974 + 975 + _IsViewPinned(thePView) { 976 + viewIsPinned:=0 977 + DllCall(this.IsViewPinned, "UPtr", this.IVirtualDesktopPinnedApps, "Ptr", thePView, "Int*",viewIsPinned) 978 + return viewIsPinned 979 + } 980 + 981 + ;internal methods end 982 + 983 + ;utility methods start 984 + _isWindowFullScreen( winTitle ) { 985 + ;checks if the specified window is full screen 986 + 987 + winID := WinExist( winTitle ) 988 + 989 + If ( !winID ) 990 + Return false 991 + 992 + WinGet style, Style, ahk_id %WinID% 993 + WinGetPos ,,,winW,winH, %winTitle% 994 + ; 0x800000 is WS_BORDER. 995 + ; 0x20000000 is WS_MINIMIZE. 996 + ; no border and not minimized 997 + Return ((style & 0x20800000) or winH < A_ScreenHeight or winW < A_ScreenWidth) ? false : true 998 + } 999 + 1000 + _isValidWindow(hWnd,checkUpper:=true) ;returns [0,pView,hWnd] if succeeded 1001 + { 1002 + returnValue:=[1,0,0] 1003 + breakToReturnFalse: 1004 + loop 1 { 1005 + dwStyle:=DllCall("GetWindowLongPtrW","Ptr",hWnd,"Int",-16,"Ptr") 1006 + if (!(dwStyle & 0x10000000)) { ;0x10000000=WS_VISIBLE 1007 + break breakToReturnFalse 1008 + } 1009 + dwExStyle:=DllCall("GetWindowLongPtrW","Ptr",hWnd,"Int",-20,"Ptr") 1010 + if (!(dwExStyle&0x00040000)) { ;0x00040000=WS_EX_APPWINDOW 1011 + if (dwExStyle&0x00000080 || dwExStyle&0x08000000) { ;0x00000080=WS_EX_TOOLWINDOW, 0x08000000=WS_EX_NOACTIVATE 1012 + break breakToReturnFalse 1013 + } 1014 + ; if any of ancestor is valid window, can't be valid window 1015 + if (checkUpper) { 1016 + toCheck:=[] 1017 + upHwnd:=hWnd 1018 + while (upHwnd := DllCall("GetWindow","Ptr",upHwnd,"Uint",4)) { ;4=GW_OWNER 1019 + if (upHwnd==65552) { 1020 + break breakToReturnFalse 1021 + } 1022 + toCheck.Push(upHwnd) 1023 + } 1024 + i:=toCheck.Length() + 1 1025 + while (i-->1) { ;i goes to 1 (lmao) 1026 + arr_success_pView_hWnd:=this._isValidWindow(toCheck[i],false) 1027 + if (arr_success_pView_hWnd[1]==0) { 1028 + arr_success_pView_hWnd[1]:=2 1029 + returnValue:=arr_success_pView_hWnd 1030 + break breakToReturnFalse 1031 + } 1032 + } 1033 + } 1034 + } 1035 + 1036 + pView:=this._view_from_Hwnd(hWnd) 1037 + if (!pView) { 1038 + break breakToReturnFalse 1039 + } 1040 + pfCanViewMoveDesktops := 0 1041 + DllCall(this.CanViewMoveDesktops, "UPtr", this.IVirtualDesktopManagerInternal, "Ptr", pView, "int*", pfCanViewMoveDesktops) ; return value BOOL 1042 + if (!pfCanViewMoveDesktops) { 1043 + break breakToReturnFalse 1044 + } 1045 + 1046 + returnValue:=[0,pView,hWnd] 1047 + } 1048 + return returnValue 1049 + } 1050 + ;------------------- 1051 + _vtable(ppv, index) { 1052 + Return NumGet(NumGet(0+ppv)+A_PtrSize*index) 1053 + } 1054 + ; _string_from_GUID(Byref byref_GUID) { 1055 + ; VarSetCapacity(strGUID, 38 * 2) ;38 is StrLen("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}") 1056 + ; DllCall("Ole32.dll\StringFromGUID2", "UPtr", &byref_GUID, "UPtr", &strGUID, "Int", 38 + 1) 1057 + ; return StrGet(&strGUID, "UTF-16") 1058 + ; } 1059 + 1060 + class IObjectArray_Wrapper { 1061 + __New(IObjectArray, Ptr_IID_Interface) { 1062 + this.IObjectArray:=IObjectArray 1063 + this.Ptr_IID_Interface:=Ptr_IID_Interface 1064 + 1065 + this.Ptr_GetAt:=VD._vtable(IObjectArray,4) 1066 + } 1067 + __Delete() { 1068 + ;IUnknown::Release 1069 + Ptr_Release:=VD._vtable(this.IObjectArray,2) 1070 + DllCall(Ptr_Release, "UPtr", this.IObjectArray) 1071 + } 1072 + GetAt(oneBasedIndex) { 1073 + Ptr_Interface:=0 1074 + DllCall(this.Ptr_GetAt, "UPtr", this.IObjectArray, "UInt", oneBasedIndex - 1, "Ptr", this.Ptr_IID_Interface, "Ptr*", Ptr_Interface) 1075 + return Ptr_Interface 1076 + } 1077 + GetCount() { 1078 + Ptr_GetCount:=VD._vtable(this.IObjectArray,3) 1079 + Count := 0 1080 + DllCall(Ptr_GetCount, "UPtr", this.IObjectArray, "UInt*", Count) 1081 + return Count 1082 + } 1083 + 1084 + } 1085 + ;utility methods end 1086 + 1087 + }
+758
Windows/AutoHotKey/capslock_sspaeti.ahk
··· 1 + ;=====================================================================o 2 + ; Feng Ruohang's AHK Script | 3 + ; CapsLock Enhancement | 4 + ; Updated Simon Späti | 5 + ;---------------------------------------------------------------------o 6 + ;Description: | 7 + ; This Script is wrote by Feng Ruohang via AutoHotKey Script. It | 8 + ; Provieds an enhancement towards the "Useless Key" CapsLock, and | 9 + ; turns CapsLock into an useful function Key just like Ctrl and Alt | 10 + ; by combining CapsLock with almost all other keys in the keyboard. | 11 + ; | 12 + ;Summary: | 13 + ;o----------------------o---------------------------------------------o 14 + ;|CapsLock; | {ESC} Especially Convient for vim user | 15 + ;|CaspLock + ` | {CapsLock}CapsLock Switcher as a Substituent| 16 + ;|CapsLock + hjklwb | Vim-Style Cursor Mover | 17 + ;|CaspLock + uiop | Convient Home/End PageUp/PageDn | 18 + ;|CaspLock + nm,. | Convient Delete Controller | 19 + ;|CapsLock + zxcvay | Windows-Style Editor | 20 + ;|CapsLock + Direction | Mouse Move | 21 + ;|CapsLock + Enter | Mouse Click | 22 + ;|CaspLock + {F1}~{F6} | Media Volume Controller | 23 + ;|CapsLock + qs | Windows & Tags Control | 24 + ;|CapsLock + ;'[] | Convient Key Mapping | 25 + ;|CaspLock + dfert | Frequently Used Programs (Self Defined) | 26 + ;|CaspLock + 123456 | Dev-Hotkey for Visual Studio (Self Defined) | 27 + ;|CapsLock + 67890-= | Shifter as Shift | 28 + ;-----------------------o---------------------------------------------o 29 + ;|Use it whatever and wherever you like. Hope it help | 30 + ;=====================================================================o 31 + 32 + 33 + ;=====================================================================o 34 + ; CapsLock Initializer ;| 35 + ;---------------------------------------------------------------------o 36 + SetCapsLockState, AlwaysOff ;| 37 + ;---------------------------------------------------------------------o 38 + 39 + 40 + ;=====================================================================o 41 + ; CapsLock Switcher: ;| 42 + ;---------------------------------o-----------------------------------o 43 + ; CapsLock + ` | {CapsLock} ;| 44 + ;---------------------------------o-----------------------------------o 45 + CapsLock & `:: ;| 46 + GetKeyState, CapsLockState, CapsLock, T ;| 47 + if CapsLockState = D ;| 48 + SetCapsLockState, AlwaysOff ;| 49 + else ;| 50 + SetCapsLockState, AlwaysOn ;| 51 + KeyWait, `` ;| 52 + return ;| 53 + ;---------------------------------------------------------------------o 54 + 55 + 56 + ;=====================================================================o 57 + ; CapsLock Escaper: ;| 58 + ;----------------------------------o----------------------------------o 59 + ; CapsLock | {ESC} ;| 60 + ;----------------------------------o----------------------------------o 61 + CapsLock::Send, {ESC} ;| 62 + ;---------------------------------------------------------------------o 63 + 64 + 65 + ;=====================================================================o 66 + ; CapsLock Direction Navigator ;| 67 + ;-----------------------------------o---------------------------------o 68 + ; CapsLock + h | Left ;| 69 + ; CapsLock + j | Down ;| 70 + ; CapsLock + k | Up ;| 71 + ; CapsLock + l | Right ;| 72 + ; Ctrl, Alt Compatible ;| 73 + ;-----------------------------------o---------------------------------o 74 + CapsLock & h:: ;| 75 + if GetKeyState("control") = 0 ;| 76 + { ;| 77 + if GetKeyState("alt") = 0 ;| 78 + Send, {Left} ;| 79 + else ;| 80 + Send, +{Left} ;| 81 + return ;| 82 + } ;| 83 + else { ;| 84 + if GetKeyState("alt") = 0 ;| 85 + Send, ^{Left} ;| 86 + else ;| 87 + Send, +^{Left} ;| 88 + return ;| 89 + } ;| 90 + return ;| 91 + ;-----------------------------------o ;| 92 + CapsLock & j:: ;| 93 + if GetKeyState("control") = 0 ;| 94 + { ;| 95 + if GetKeyState("alt") = 0 ;| 96 + Send, {Down} ;| 97 + else ;| 98 + Send, +{Down} ;| 99 + return ;| 100 + } ;| 101 + else { ;| 102 + if GetKeyState("alt") = 0 ;| 103 + Send, ^{Down} ;| 104 + else ;| 105 + Send, +^{Down} ;| 106 + return ;| 107 + } ;| 108 + return ;| 109 + ;-----------------------------------o ;| 110 + CapsLock & k:: ;| 111 + if GetKeyState("control") = 0 ;| 112 + { ;| 113 + if GetKeyState("alt") = 0 ;| 114 + Send, {Up} ;| 115 + else ;| 116 + Send, +{Up} ;| 117 + return ;| 118 + } ;| 119 + else { ;| 120 + if GetKeyState("alt") = 0 ;| 121 + Send, ^{Up} ;| 122 + else ;| 123 + Send, +^{Up} ;| 124 + return ;| 125 + } ;| 126 + return ;| 127 + ;-----------------------------------o ;| 128 + CapsLock & l:: ;| 129 + if GetKeyState("control") = 0 ;| 130 + { ;| 131 + if GetKeyState("alt") = 0 ;| 132 + Send, {Right} ;| 133 + else ;| 134 + Send, +{Right} ;| 135 + return ;| 136 + } ;| 137 + else { ;| 138 + if GetKeyState("alt") = 0 ;| 139 + Send, ^{Right} ;| 140 + else ;| 141 + Send, +^{Right} ;| 142 + return ;| 143 + } ;| 144 + return ;| 145 + ;---------------------------------------------------------------------o 146 + 147 + 148 + ;=====================================================================o 149 + ; CapsLock Home/End Navigator ;| 150 + ;-----------------------------------o---------------------------------o 151 + ; CapsLock + i | Home ;| 152 + ; CapsLock + o | End ;| 153 + ; Ctrl, Alt Compatible ;| 154 + ;-----------------------------------o---------------------------------o 155 + CapsLock & i:: ;| 156 + if GetKeyState("control") = 0 ;| 157 + { ;| 158 + if GetKeyState("alt") = 0 ;| 159 + Send, {Home} ;| 160 + else ;| 161 + Send, +{Home} ;| 162 + return ;| 163 + } ;| 164 + else { ;| 165 + if GetKeyState("alt") = 0 ;| 166 + Send, ^{Home} ;| 167 + else ;| 168 + Send, +^{Home} ;| 169 + return ;| 170 + } ;| 171 + return ;| 172 + ;-----------------------------------o ;| 173 + ;CapsLock & o:: ;| 174 + ;if GetKeyState("control") = 0 ;| 175 + ;{ ;| 176 + ; if GetKeyState("alt") = 0 ;| 177 + ; Send, {End} ;| 178 + ; else ;| 179 + ; Send, +{End} ;| 180 + ; return ;| 181 + ;} ;| 182 + ;else { ;| 183 + ; if GetKeyState("alt") = 0 ;| 184 + ; Send, ^{End} ;| 185 + ; else ;| 186 + ; Send, +^{End} ;| 187 + ; return ;| 188 + ;} ;| 189 + ;return ;| 190 + ;---------------------------------------------------------------------o 191 + 192 + 193 + ;=====================================================================o 194 + ; CapsLock Page Navigator ;| 195 + ;-----------------------------------o---------------------------------o 196 + ; CapsLock + u | PageUp ;| 197 + ; CapsLock + p | PageDown ;| 198 + ; Ctrl, Alt Compatible ;| 199 + ;-----------------------------------o---------------------------------o 200 + ;CapsLock & u:: ;| 201 + ;if GetKeyState("control") = 0 ;| 202 + ;{ ;| 203 + ; if GetKeyState("alt") = 0 ;| 204 + ; Send, {PgUp} ;| 205 + ; else ;| 206 + ; Send, +{PgUp} ;| 207 + ; return ;| 208 + ;} ;| 209 + ;else { ;| 210 + ; if GetKeyState("alt") = 0 ;| 211 + ; Send, ^{PgUp} ;| 212 + ; else ;| 213 + ; Send, +^{PgUp} ;| 214 + ; return ;| 215 + ;} ;| 216 + ;return ;| 217 + ;-----------------------------------o ;| 218 + CapsLock & p:: ;| 219 + if GetKeyState("control") = 0 ;| 220 + { ;| 221 + if GetKeyState("alt") = 0 ;| 222 + Send, {PgDn} ;| 223 + else ;| 224 + Send, +{PgDn} ;| 225 + return ;| 226 + } ;| 227 + else { ;| 228 + if GetKeyState("alt") = 0 ;| 229 + Send, ^{PgDn} ;| 230 + else ;| 231 + Send, +^{PgDn} ;| 232 + return ;| 233 + } ;| 234 + return ;| 235 + ;---------------------------------------------------------------------o 236 + 237 + 238 + ;=====================================================================o 239 + ; CapsLock Mouse Controller ;| 240 + ;-----------------------------------o---------------------------------o 241 + ; CapsLock + Up | Mouse Up ;| 242 + ; CapsLock + Down | Mouse Down ;| 243 + ; CapsLock + Left | Mouse Left ;| 244 + ; CapsLock + Right | Mouse Right ;| 245 + ; CapsLock + Enter(Push Release) | Mouse Left Push(Release) ;| 246 + ;-----------------------------------o---------------------------------o 247 + CapsLock & Up:: MouseMove, 0, -10, 0, R ;| 248 + CapsLock & Down:: MouseMove, 0, 10, 0, R ;| 249 + CapsLock & Left:: MouseMove, -10, 0, 0, R ;| 250 + CapsLock & Right:: MouseMove, 10, 0, 0, R ;| 251 + ;-----------------------------------o ;| 252 + CapsLock & Enter:: ;| 253 + SendEvent {Blind}{LButton down} ;| 254 + KeyWait Enter ;| 255 + SendEvent {Blind}{LButton up} ;| 256 + return ;| 257 + ;---------------------------------------------------------------------o 258 + 259 + 260 + ;=====================================================================o 261 + ; CapsLock Deletor ;| 262 + ;-----------------------------------o---------------------------------o 263 + ; CapsLock + n | Ctrl + Delete (Delete a Word) ;| 264 + ; CapsLock + m | Delete ;| 265 + ; CapsLock + , | BackSpace ;| 266 + ; CapsLock + . | Ctrl + BackSpace ;| 267 + ;-----------------------------------o---------------------------------o 268 + CapsLock & ,:: Send, {Del} ;| 269 + CapsLock & .:: Send, ^{Del} ;| 270 + CapsLock & m:: Send, {BS} ;| 271 + CapsLock & n:: Send, ^{BS} ;| 272 + ;---------------------------------------------------------------------o 273 + 274 + 275 + ;=====================================================================o 276 + ; CapsLock Editor ;| 277 + ;-----------------------------------o---------------------------------o 278 + ; CapsLock + z | Ctrl + z (Cancel) ;| 279 + ; CapsLock + x | Ctrl + x (Cut) ;| 280 + ; CapsLock + c | Ctrl + c (Copy) ;| 281 + ; CapsLock + v | Ctrl + z (Paste) ;| 282 + ; CapsLock + a | Ctrl + a (Select All) ;| 283 + ; CapsLock + y | Ctrl + z (Yeild) ;| 284 + ; CapsLock + w | Ctrl + Right(Move as [vim: w]);| 285 + ; CapsLock + b | Ctrl + Left (Move as [vim: b]);| 286 + ;-----------------------------------o---------------------------------o 287 + CapsLock & z:: Send, ^z ;| 288 + CapsLock & x:: Send, ^x ;| 289 + CapsLock & c:: Send, ^c ;| 290 + CapsLock & v:: Send, ^v ;| 291 + ;CapsLock & a:: Send, ^a ;| 292 + CapsLock & y:: Send, ^y ;| 293 + CapsLock & w:: Send, ^{Right} ;| 294 + CapsLock & b:: Send, ^{Left} ;| 295 + ;---------------------------------------------------------------------o 296 + 297 + 298 + ;=====================================================================o 299 + ; CapsLock Media Controller ;| 300 + ;-----------------------------------o---------------------------------o 301 + ; CapsLock + F1 | Volume_Mute ;| 302 + ; CapsLock + F2 | Volume_Down ;| 303 + ; CapsLock + F3 | Volume_Up ;| 304 + ; CapsLock + F3 | Media_Play_Pause ;| 305 + ; CapsLock + F5 | Media_Next ;| 306 + ; CapsLock + F6 | Media_Stop ;| 307 + ;-----------------------------------o---------------------------------o 308 + CapsLock & F1:: Send, {Volume_Mute} ;| 309 + CapsLock & F2:: Send, {Volume_Down} ;| 310 + CapsLock & F3:: Send, {Volume_Up} ;| 311 + CapsLock & F4:: Send, {Media_Play_Pause} ;| 312 + CapsLock & F5:: Send, {Media_Next} ;| 313 + CapsLock & F6:: Send, {Media_Stop} ;| 314 + ;---------------------------------------------------------------------o 315 + 316 + 317 + ;=====================================================================o 318 + ; CapsLock Window Controller ;| 319 + ;-----------------------------------o---------------------------------o 320 + ; CapsLock + s | Ctrl + Tab (Swith Tag) ;| 321 + ; Alt + CapsLock + q | Ctrl + Tab (Close Windows) ;| 322 + ; CapsLock + g | AppsKey (Menu Key) ;| 323 + ;-----------------------------------o---------------------------------o 324 + CapsLock & s::Send, ^{Tab} ;| 325 + ;-----------------------------------o ;| 326 + CapsLock & q:: ;| 327 + if GetKeyState("alt") = 0 ;| 328 + { ;| 329 + Send, ^w ;| 330 + } ;| 331 + else { ;| 332 + Send, !{F4} ;| 333 + return ;| 334 + } ;| 335 + return ;| 336 + ;-----------------------------------o ;| 337 + CapsLock & g:: Send, {AppsKey} ;| 338 + ;---------------------------------------------------------------------o 339 + 340 + 341 + ;=====================================================================o 342 + ; CapsLock Self Defined Area ;| 343 + ;-----------------------------------o---------------------------------o 344 + ; CapsLock + d | Alt + d(Dictionary) ;| 345 + ; CapsLock + f | Alt + f(Search via Everything);| 346 + ; CapsLock + e | Open Search Engine ;| 347 + ; CapsLock + r | Open Shell ;| 348 + ; CapsLock + t | Open Text Editor ;| 349 + ;-----------------------------------o---------------------------------o 350 + CapsLock & d:: Send, !d ;| 351 + CapsLock & f:: Send, !f ;| 352 + CapsLock & e:: Run http://cn.bing.com/ ;| 353 + CapsLock & r:: Run Powershell ;| 354 + CapsLock & t:: Run C:\Program Files (x86)\Notepad++\notepad++.exe ;| 355 + ;---------------------------------------------------------------------o 356 + 357 + 358 + ;=====================================================================o 359 + ; CapsLock Char Mapping ;| 360 + ;-----------------------------------o---------------------------------o 361 + ; CapsLock + ; | Enter (Cancel) ;| 362 + ; CapsLock + ' | = ;| 363 + ; CapsLock + [ | Back (Visual Studio) ;| 364 + ; CapsLock + ] | Goto Define (Visual Studio) ;| 365 + ; CapsLock + / | Comment (Visual Studio) ;| 366 + ; CapsLock + \ | Uncomment (Visual Studio) ;| 367 + ; CapsLock + 1 | Build and Run(Visual Studio) ;| 368 + ; CapsLock + 2 | Debuging (Visual Studio) ;| 369 + ; CapsLock + 3 | Step Over (Visual Studio) ;| 370 + ; CapsLock + 4 | Step In (Visual Studio) ;| 371 + ; CapsLock + 5 | Stop Debuging(Visual Studio) ;| 372 + ; CapsLock + 6 | Shift + 6 ^ ;| 373 + ; CapsLock + 7 | Shift + 7 & ;| 374 + ; CapsLock + 8 | Shift + 8 * ;| 375 + ; CapsLock + 9 | Shift + 9 ( ;| 376 + ; CapsLock + 0 | Shift + 0 ) ;| 377 + ;-----------------------------------o---------------------------------o 378 + CapsLock & `;:: Send, {Enter} ;| 379 + CapsLock & ':: Send, = ;| 380 + CapsLock & [:: Send, ^- ;| 381 + CapsLock & ]:: Send, {F12} ;| 382 + ;-----------------------------------o ;| 383 + CapsLock & /:: ;| 384 + Send, ^e ;| 385 + Send, c ;| 386 + return ;| 387 + ;-----------------------------------o ;| 388 + CapsLock & \:: ;| 389 + Send, ^e ;| 390 + Send, u ;| 391 + return ;| 392 + ;-----------------------------------o ;| 393 + CapsLock & 1:: Send,^{F5} ;| 394 + CapsLock & 2:: Send,{F5} ;| 395 + CapsLock & 3:: Send,{F10} ;| 396 + CapsLock & 4:: Send,{F11} ;| 397 + CapsLock & 5:: Send,+{F5} ;| 398 + ;-----------------------------------o ;| 399 + CapsLock & 6:: Send,+6 ;| 400 + CapsLock & 7:: Send,+7 ;| 401 + CapsLock & 8:: Send,+8 ;| 402 + CapsLock & 9:: Send,+9 ;| 403 + CapsLock & 0:: Send,+0 ;| 404 + ;---------------------------------------------------------------------o 405 + ;=====================================================================o 406 + ; Umlaut Char Mapping ;| 407 + ;-----------------------------------o---------------------------------o 408 + ; CapsLock + a | ä ;| 409 + ; CapsLock + a | ä ;| 410 + ; CapsLock + u | ü ;| 411 + ; LAlt + o | ö ;| 412 + ; LAlt + u | ü ;| 413 + ; LAlt + o | ö ;| 414 + ; z | y ;| 415 + ; y | z ;| 416 + ;-----------------------------------o---------------------------------o 417 + CapsLock & a:: 418 + { 419 + GetKeyState, state, Lshift 420 + if state = D 421 + SendInput, {U+00C4} 422 + else 423 + SendInput, {U+00E4} 424 + return 425 + } 426 + CapsLock & u:: 427 + { 428 + GetKeyState, state, Lshift 429 + if state = D 430 + SendInput, {U+00DC} 431 + else 432 + SendInput, {U+00FC} 433 + return 434 + } 435 + CapsLock & o:: 436 + { 437 + GetKeyState, state, Lshift 438 + if state = D 439 + SendInput, {U+00D6} 440 + else 441 + SendInput, {U+00F6} 442 + return 443 + } 444 + ;---------------------------------------------------------------------o 445 + <!a:: 446 + { 447 + GetKeyState, state, Lshift 448 + if state = D 449 + SendInput, {U+00C4} 450 + else 451 + SendInput, {U+00E4} 452 + return 453 + } 454 + <!u:: 455 + { 456 + GetKeyState, state, Lshift 457 + if state = D 458 + SendInput, {U+00DC} 459 + else 460 + SendInput, {U+00FC} 461 + return 462 + } 463 + <!o:: 464 + { 465 + GetKeyState, state, Lshift 466 + if state = D 467 + SendInput, {U+00D6} 468 + else 469 + SendInput, {U+00F6} 470 + return 471 + } 472 + ;---------------------------------------------------------------------o 473 + ; this is only used if keyboard has not switched it automatically o 474 + ; default is switching it, as US layout has z and y not like QWERY as o 475 + ; I want o 476 + ;---------------------------------------------------------------------o 477 + SC015::z ;| 478 + SC02C::y ;| 479 + ;---------------------------------------------------------------------o 480 + 481 + 482 + ;=====================================================================o 483 + ; Delta Phoenix's AHK Script | 484 + ; Virtual Desktop Enhancement | 485 + ;---------------------------------------------------------------------o 486 + ;from: https://superuser.com/a/1050690 487 + ;IMPORTANT: 488 + ; 489 + ;In order for it to work you must ONLY use hotkeys for opening, closing, and changing desktops because the script listens for these hotkeys to know the current and total number of desktops. 490 + ; 491 + ;If you do create, close, or change desktops via the WIN+TAB menu with the mouse the script will stop working. In order to get it working again you will need to edit the first two lines to reflect the current state of your desktops. (desktopcount/currentdesktop) 492 + ; 493 + ;This doesn't mean you can't use the WIN+TAB screen as an overview of your current desktops. You can actually use it in combination of the hotkeys to organize your desktops. Yes, the hotkeys still work when the windows task viewer is open! (WIN+TAB) Just DO NOT use the mouse!!! 494 + ; 495 + ;Also, wait for the script to load after Windows startup before creating new desktops or it will not work. This could take a moment depending on how many startup programs you have. 496 + ; 497 + ;Ok, I added one more thing to make it easier to re-sync the script with your desktop state. There is now a hotkey that will display the state the script believes the desktops to be in so all you have to do is adjust your desktops with the mouse to fit the script and it will be all synced up again! For me with a Swiss keyboard it worked out nicely having the '? key next to 0 and it makes sense with a ? on it, but on other keyboards you may wish to change this which can be done easily by changing the line right after the hotkey for 0/10 (starting with #') to whatever you like. 498 + ; 499 + ;Actually, I just realized.... as long as the Desktop Count is correct than creating a new desktop will automatically re-sync the Current Desktop value. 500 + ; 501 + #NoTrayIcon 502 + ;If the script stops working: 503 + ;Change the following values to reflect your current desktop state and reload the script. 504 + ;Remember to change them back to 1 after reloading the script if you have it set to start with Windows 505 + 506 + desktopcount := 1 507 + currentdesktop := 1 508 + 509 + ;You can change the hotkeys for creating, closing, and switching desktops bellow. 510 + ;The current hotkeys are CTRL+WIN+D for new desktop, CTRL+WIN+F4 to close desktop 511 + ;and ALT+NUMBER for switching desktops. 512 + ;For example, to change the hotkey for new desktop replace !^#D bellow with the desired hotkey. 513 + ;Refer to the autohotkey documentation for a full list of symbols refering to modifier keys, 514 + ;as you can see ! is ALT (^ would be CTRL) and # is WIN key. 515 + ;If you wanted to change the switch desktop from WIN key to CTRL for example you would have 516 + 517 + !^D::NewDesktop() 518 + !^w::CloseDesktop() 519 + !1::SwitchDesktop(1) 520 + !2::SwitchDesktop(2) 521 + !3::SwitchDesktop(3) 522 + !4::SwitchDesktop(4) 523 + !5::SwitchDesktop(5) 524 + !6::SwitchDesktop(6) 525 + !7::SwitchDesktop(7) 526 + !8::SwitchDesktop(8) 527 + !9::SwitchDesktop(9) 528 + !0::SwitchDesktop(10) 529 + !'::MsgBox Desktop Count = %desktopcount%`nCurrent Desktop = %currentdesktop% 530 + 531 + ;Do not change anything after this line, unless you know what you are doing ;) 532 + ;----------------------------------------------------------------------------------------------- 533 + SwitchDesktop(desktop) 534 + { 535 + 536 + global desktopcount 537 + global currentdesktop 538 + desktopdiff := desktop - currentdesktop 539 + if (desktop > desktopcount) 540 + { 541 + return 542 + } 543 + if (desktopdiff < 0) 544 + { 545 + desktopdiff *= -1 546 + Loop %desktopdiff% 547 + { 548 + Send ^#{Left} 549 + } 550 + } 551 + else if (desktopdiff > 0) 552 + { 553 + Loop %desktopdiff% 554 + { 555 + Send ^#{Right} 556 + } 557 + } 558 + currentdesktop := desktop 559 + } 560 + 561 + NewDesktop() 562 + { 563 + global desktopcount 564 + global currentdesktop 565 + if (desktopcount > 9) 566 + { 567 + return 568 + } 569 + desktopcount ++ 570 + currentdesktop := desktopcount 571 + Send ^#d 572 + } 573 + 574 + CloseDesktop() 575 + { 576 + global desktopcount 577 + global currentdesktop 578 + desktopcount -- 579 + if (currentdesktop != 1) 580 + { 581 + currentdesktop -- 582 + } 583 + Send ^#{f4} 584 + } 585 + ;=====================================================================o 586 + ; Jump to App | 587 + ;---------------------------------------------------------------------o 588 + ;start apps with hotkey 589 + ;from: https://gist.github.com/datmt/5b7d17e8886d14bb0024f8e6c45dabcd 590 + ; 591 + #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. 592 + ; #Warn ; Enable warnings to assist with detecting common errors. 593 + SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 594 + SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 595 + ; 596 + ; 597 + SetTitleMatchMode, 2 598 + !b:: 599 + 600 + if WinExist("ahk_exe brave.exe") 601 + { 602 + WinActivate 603 + } else 604 + { 605 + Run "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" 606 + } 607 + 608 + Return 609 + 610 + 611 + !n:: 612 + 613 + if WinExist("ahk_exe Obsidian.exe") 614 + { 615 + WinActivate 616 + } else 617 + { 618 + Run "C:\Users\rah9\AppData\Local\Obsidian\Obsidian.exe" 619 + } 620 + 621 + Return 622 + 623 + 624 + !w:: 625 + 626 + if WinExist("ahk_exe wt.exe") 627 + { 628 + WinActivate 629 + } else 630 + { 631 + Run "C:\Users\rah9\AppData\Local\Microsoft\WindowsApps\wt.exe" 632 + } 633 + 634 + Return 635 + 636 + !t:: 637 + 638 + if WinExist("ahk_exe wt.exe") 639 + { 640 + WinActivate 641 + } else 642 + { 643 + Run "C:\Users\rah9\AppData\Local\Microsoft\WindowsApps\wt.exe" 644 + } 645 + 646 + Return 647 + 648 + 649 + !v:: 650 + 651 + if WinExist("ahk_exe Code.exe") 652 + { 653 + WinActivate 654 + } else 655 + { 656 + Run "C:\Users\rah9\AppData\Local\Programs\Microsoft VS Code\Code.exe" 657 + } 658 + 659 + Return 660 + 661 + ; DOES NOT WORK YET - therefore commented out 662 + ;;=====================================================================o 663 + ;; VD.akh: Virtual Desktop AHK Script | 664 + ;; Move apps to Virtual Desktops | 665 + ;;---------------------------------------------------------------------o 666 + ;;from: https://github.com/FuPeiJiang/VD.ahk 667 + ;; 668 + ;;#SETUP START 669 + ;#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. 670 + ;#SingleInstance force 671 + ;ListLines Off 672 + ;SetBatchLines -1 673 + ;SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 674 + ;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 675 + ;#KeyHistory 0 676 + ;#WinActivateForce 677 + ; 678 + ;Process, Priority,, H 679 + ; 680 + ;SetWinDelay -1 681 + ;SetControlDelay -1 682 + ; 683 + ;;START of gui stuff 684 + ;Gui,Font, s12, Segoe UI 685 + ;explanation= 686 + ;( 687 + ;Numpad0 to pin this Window on all desktops 688 + ;you can spam (Numpad2,Numpad1,Numpad2,Numpad1) for fun 689 + ; 690 + ;here's a challenge (you might lose this window): 691 + ;Unpin this using Numpad0 692 + ;go to Desktop 3 (Numpad3) 693 + ;this time, use Win + * on Numpad to come back to this window wherever you are 694 + ;(and wherever this window is) 695 + ;so you can move this window to desktop 2 (Numpad5), you go to desktop 1, and use Win + * on Numpad 696 + ;(if you want to search in this script, the hotkey is #NumpadMult) 697 + ; 698 + ;Numpad9 to throw a window to Desktop 3 (and not follow it) 699 + ; 700 + ;getters: 701 + ;f1 to see which desktop you currently are in 702 + ;f6 to see which desktop this window is in 703 + ;f2 to see the total number of virtual desktops 704 + ; 705 + ;(You might want to pin this window for this part): 706 + ;!NumpadAdd (Alt + Numpad+) to createDesktop and go to it 707 + ;f1 to see which desktop you currently are in 708 + ; 709 + ;but at this point, just use Win + Tab.. 710 + ;these functions are mostly for script only, 711 + ;for example: I used VD.createUntil(3) 712 + ;at the start of this tutorial, to make sure we have at least 3 VD 713 + ; 714 + ;^+NumpadAdd (Ctrl Alt + Numpad+) to create until you have 3 desktops 715 + ;!NumpadSub (Alt + Numpad-) to remove the current desktop 716 + ;^+NumpadSub (Ctrl ALt + Numpad-) to delete the 3rd desktop 717 + ; 718 + ;more below, look at the hotkeys in code. 719 + ;) 720 + ;gui, add, Edit, -vscroll -E0x200 +hwndHWndExplanation_Edit, % explanation ; https://www.autohotkey.com/boards/viewtopic.php?t=3956#p21359 721 + ;;deselect edit text BY moving caret to start 722 + ;Postmessage,0xB1,0,0,, % "ahk_id " HWndExplanation_Edit 723 + ;gui, show,, VD.ahk examples WinTitle 724 + ;;END of gui stuff 725 + ; 726 + ;;include the library 727 + ;#Include %A_LineFile%\..\VD.ahk 728 + ;; or 729 + ;; #Include %A_LineFile%\..\_VD.ahk 730 + ;; ...{startup code} 731 + ;; VD.init() 732 + ; 733 + ;; VD.ahk : calls `VD.init()` on #Include 734 + ;; _VD.ahk : `VD.init()` when you want, like after a GUI has rendered, for startup performance reasons 735 + ; 736 + ; 737 + ;;you should WinHide invisible programs that have a window. 738 + ;WinHide, % "Malwarebytes Tray Application" 739 + ;;#SETUP END 740 + ; 741 + ;VD.createUntil(3) ;create until we have at least 3 VD 742 + ; 743 + ;return 744 + ;; 745 + ;; 746 + ;!^1::VD.MoveWindowToDesktopNum("A",1), VD.goToDesktopNum(1) 747 + ;!^2::VD.MoveWindowToDesktopNum("A",2), VD.goToDesktopNum(2) 748 + ;!^3::VD.MoveWindowToDesktopNum("A",3), VD.goToDesktopNum(3) 749 + ;!^4::VD.MoveWindowToDesktopNum("A",4), VD.goToDesktopNum(4) 750 + ;!^5::VD.MoveWindowToDesktopNum("A",5), VD.goToDesktopNum(5) 751 + ;!^6::VD.MoveWindowToDesktopNum("A",6), VD.goToDesktopNum(6) 752 + ;!^7::VD.MoveWindowToDesktopNum("A",7), VD.goToDesktopNum(7) 753 + ;!^8::VD.MoveWindowToDesktopNum("A",8), VD.goToDesktopNum(8) 754 + ;!^9::VD.MoveWindowToDesktopNum("A",9), VD.goToDesktopNum(9) 755 + ;; move window to left and follow it 756 + ;!^left::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", -1)) 757 + ;; move window to right and follow it 758 + ;!^right::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", 1))
+116
Windows/AutoHotKey/examples/Vim Keys V3.ahk
··· 1 + SendMode Input 2 + RegRead, OutputVar, HKEY_CLASSES_ROOT, http\shell\open\command 3 + StringReplace, OutputVar, OutputVar," 4 + SplitPath, OutputVar,,OutDir,,OutNameNoExt, OutDrive 5 + browser=%OutDir%\%OutNameNoExt%.exe 6 + 7 + Suspend On 8 + 9 + ;===Navigate 10 + h::Left 11 + j::Down 12 + k::Up 13 + l::Right 14 + p::PgUp 15 + `;::PgDn 16 + a::Home 17 + e::End 18 + 19 + ;===Run, First letter of service, blog, homework, snip, autohotkey, dropbox 20 + r & b:: Run D:\Users\Corm\Dropbox\Notebooks\Notes\Personal Notes\blog posts\(1) March 21 + r & h::Run D:\Users\Corm\Dropbox\Notebooks\Homework 22 + r & s:: Run D:\Users\Corm\Documents\Unsorted\SnippingTool.exe 23 + r & a::Reload 24 + r & d::Run D:\Users\Corm\Dropbox\Backup Data 25 + 26 + ;===Skip words 27 + *w:: 28 + SetKeyDelay -1 29 + Send {Blind}{Control DownTemp}{Right DownTemp} 30 + return 31 + 32 + *w up:: 33 + SetKeyDelay -1 34 + Send {Blind}{Right up}{Control Up} 35 + return 36 + 37 + *b:: 38 + SetKeyDelay -1 39 + Send {Blind}{Control DownTemp}{Left DownTemp} 40 + return 41 + 42 + *b up:: 43 + SetKeyDelay -1 44 + Send {Blind}{Left up}{Control Up} 45 + return 46 + 47 + ;===Skip down/up 48 + 49 + Space:: 50 + SetKeyDelay -1 51 + Loop, 16 52 + Send {Down} 53 + return 54 + 55 + +space:: 56 + SetKeyDelay -1 57 + Loop, 16 58 + Send {Up} 59 + return 60 + 61 + ;===Google! 62 + 63 + g:: 64 + { 65 + BlockInput, on 66 + prevClipboard = %clipboard% 67 + clipboard = 68 + Send, ^c 69 + BlockInput, off 70 + ClipWait, 2 71 + if ErrorLevel = 0 72 + { 73 + searchQuery=%clipboard% 74 + GoSub, GoogleSearch 75 + } 76 + clipboard = %prevClipboard% 77 + return 78 + } 79 + 80 + GoogleSearch: 81 + StringReplace, searchQuery, searchQuery, `r`n, %A_Space%, All 82 + Loop 83 + { 84 + noExtraSpaces=1 85 + StringLeft, leftMost, searchQuery, 1 86 + IfInString, leftMost, %A_Space% 87 + { 88 + StringTrimLeft, searchQuery, searchQuery, 1 89 + noExtraSpaces=0 90 + } 91 + StringRight, rightMost, searchQuery, 1 92 + IfInString, rightMost, %A_Space% 93 + { 94 + StringTrimRight, searchQuery, searchQuery, 1 95 + noExtraSpaces=0 96 + } 97 + If (noExtraSpaces=1) 98 + break 99 + } 100 + StringReplace, searchQuery, searchQuery, \, `%5C, All 101 + StringReplace, searchQuery, searchQuery, %A_Space%, +, All 102 + StringReplace, searchQuery, searchQuery, `%, `%25, All 103 + IfInString, searchQuery, . 104 + { 105 + IfInString, searchQuery, + 106 + Run, %browser% http://www.google.com/search?hl=en&q=%searchQuery% 107 + else 108 + Run, %browser% %searchQuery% 109 + } 110 + else 111 + Run, %browser% http://www.google.com/search?hl=en&q=%searchQuery% 112 + return 113 + 114 + +Capslock:: 115 + CapsLock::Suspend Off 116 + CapsLock Up::Suspend On
Windows/AutoHotKey/examples/Vim Keys V3.exe

This is a binary file and will not be displayed.

+405
Windows/AutoHotKey/examples/capslock.ahk
··· 1 + ;=====================================================================o 2 + ; Feng Ruohang's AHK Script | 3 + ; CapsLock Enhancement | 4 + ;---------------------------------------------------------------------o 5 + ;Description: | 6 + ; This Script is wrote by Feng Ruohang via AutoHotKey Script. It | 7 + ; Provieds an enhancement towards the "Useless Key" CapsLock, and | 8 + ; turns CapsLock into an useful function Key just like Ctrl and Alt | 9 + ; by combining CapsLock with almost all other keys in the keyboard. | 10 + ; | 11 + ;Summary: | 12 + ;o----------------------o---------------------------------------------o 13 + ;|CapsLock; | {ESC} Especially Convient for vim user | 14 + ;|CaspLock + ` | {CapsLock}CapsLock Switcher as a Substituent| 15 + ;|CapsLock + hjklwb | Vim-Style Cursor Mover | 16 + ;|CaspLock + uiop | Convient Home/End PageUp/PageDn | 17 + ;|CaspLock + nm,. | Convient Delete Controller | 18 + ;|CapsLock + zxcvay | Windows-Style Editor | 19 + ;|CapsLock + Direction | Mouse Move | 20 + ;|CapsLock + Enter | Mouse Click | 21 + ;|CaspLock + {F1}~{F6} | Media Volume Controller | 22 + ;|CapsLock + qs | Windows & Tags Control | 23 + ;|CapsLock + ;'[] | Convient Key Mapping | 24 + ;|CaspLock + dfert | Frequently Used Programs (Self Defined) | 25 + ;|CaspLock + 123456 | Dev-Hotkey for Visual Studio (Self Defined) | 26 + ;|CapsLock + 67890-= | Shifter as Shift | 27 + ;-----------------------o---------------------------------------------o 28 + ;|Use it whatever and wherever you like. Hope it help | 29 + ;=====================================================================o 30 + 31 + 32 + ;=====================================================================o 33 + ; CapsLock Initializer ;| 34 + ;---------------------------------------------------------------------o 35 + SetCapsLockState, AlwaysOff ;| 36 + ;---------------------------------------------------------------------o 37 + 38 + 39 + ;=====================================================================o 40 + ; CapsLock Switcher: ;| 41 + ;---------------------------------o-----------------------------------o 42 + ; CapsLock + ` | {CapsLock} ;| 43 + ;---------------------------------o-----------------------------------o 44 + CapsLock & `:: ;| 45 + GetKeyState, CapsLockState, CapsLock, T ;| 46 + if CapsLockState = D ;| 47 + SetCapsLockState, AlwaysOff ;| 48 + else ;| 49 + SetCapsLockState, AlwaysOn ;| 50 + KeyWait, `` ;| 51 + return ;| 52 + ;---------------------------------------------------------------------o 53 + 54 + 55 + ;=====================================================================o 56 + ; CapsLock Escaper: ;| 57 + ;----------------------------------o----------------------------------o 58 + ; CapsLock | {ESC} ;| 59 + ;----------------------------------o----------------------------------o 60 + CapsLock::Send, {ESC} ;| 61 + ;---------------------------------------------------------------------o 62 + 63 + 64 + ;=====================================================================o 65 + ; CapsLock Direction Navigator ;| 66 + ;-----------------------------------o---------------------------------o 67 + ; CapsLock + h | Left ;| 68 + ; CapsLock + j | Down ;| 69 + ; CapsLock + k | Up ;| 70 + ; CapsLock + l | Right ;| 71 + ; Ctrl, Alt Compatible ;| 72 + ;-----------------------------------o---------------------------------o 73 + CapsLock & h:: ;| 74 + if GetKeyState("control") = 0 ;| 75 + { ;| 76 + if GetKeyState("alt") = 0 ;| 77 + Send, {Left} ;| 78 + else ;| 79 + Send, +{Left} ;| 80 + return ;| 81 + } ;| 82 + else { ;| 83 + if GetKeyState("alt") = 0 ;| 84 + Send, ^{Left} ;| 85 + else ;| 86 + Send, +^{Left} ;| 87 + return ;| 88 + } ;| 89 + return ;| 90 + ;-----------------------------------o ;| 91 + CapsLock & j:: ;| 92 + if GetKeyState("control") = 0 ;| 93 + { ;| 94 + if GetKeyState("alt") = 0 ;| 95 + Send, {Down} ;| 96 + else ;| 97 + Send, +{Down} ;| 98 + return ;| 99 + } ;| 100 + else { ;| 101 + if GetKeyState("alt") = 0 ;| 102 + Send, ^{Down} ;| 103 + else ;| 104 + Send, +^{Down} ;| 105 + return ;| 106 + } ;| 107 + return ;| 108 + ;-----------------------------------o ;| 109 + CapsLock & k:: ;| 110 + if GetKeyState("control") = 0 ;| 111 + { ;| 112 + if GetKeyState("alt") = 0 ;| 113 + Send, {Up} ;| 114 + else ;| 115 + Send, +{Up} ;| 116 + return ;| 117 + } ;| 118 + else { ;| 119 + if GetKeyState("alt") = 0 ;| 120 + Send, ^{Up} ;| 121 + else ;| 122 + Send, +^{Up} ;| 123 + return ;| 124 + } ;| 125 + return ;| 126 + ;-----------------------------------o ;| 127 + CapsLock & l:: ;| 128 + if GetKeyState("control") = 0 ;| 129 + { ;| 130 + if GetKeyState("alt") = 0 ;| 131 + Send, {Right} ;| 132 + else ;| 133 + Send, +{Right} ;| 134 + return ;| 135 + } ;| 136 + else { ;| 137 + if GetKeyState("alt") = 0 ;| 138 + Send, ^{Right} ;| 139 + else ;| 140 + Send, +^{Right} ;| 141 + return ;| 142 + } ;| 143 + return ;| 144 + ;---------------------------------------------------------------------o 145 + 146 + 147 + ;=====================================================================o 148 + ; CapsLock Home/End Navigator ;| 149 + ;-----------------------------------o---------------------------------o 150 + ; CapsLock + i | Home ;| 151 + ; CapsLock + o | End ;| 152 + ; Ctrl, Alt Compatible ;| 153 + ;-----------------------------------o---------------------------------o 154 + CapsLock & i:: ;| 155 + if GetKeyState("control") = 0 ;| 156 + { ;| 157 + if GetKeyState("alt") = 0 ;| 158 + Send, {Home} ;| 159 + else ;| 160 + Send, +{Home} ;| 161 + return ;| 162 + } ;| 163 + else { ;| 164 + if GetKeyState("alt") = 0 ;| 165 + Send, ^{Home} ;| 166 + else ;| 167 + Send, +^{Home} ;| 168 + return ;| 169 + } ;| 170 + return ;| 171 + ;-----------------------------------o ;| 172 + CapsLock & o:: ;| 173 + if GetKeyState("control") = 0 ;| 174 + { ;| 175 + if GetKeyState("alt") = 0 ;| 176 + Send, {End} ;| 177 + else ;| 178 + Send, +{End} ;| 179 + return ;| 180 + } ;| 181 + else { ;| 182 + if GetKeyState("alt") = 0 ;| 183 + Send, ^{End} ;| 184 + else ;| 185 + Send, +^{End} ;| 186 + return ;| 187 + } ;| 188 + return ;| 189 + ;---------------------------------------------------------------------o 190 + 191 + 192 + ;=====================================================================o 193 + ; CapsLock Page Navigator ;| 194 + ;-----------------------------------o---------------------------------o 195 + ; CapsLock + u | PageUp ;| 196 + ; CapsLock + p | PageDown ;| 197 + ; Ctrl, Alt Compatible ;| 198 + ;-----------------------------------o---------------------------------o 199 + CapsLock & u:: ;| 200 + if GetKeyState("control") = 0 ;| 201 + { ;| 202 + if GetKeyState("alt") = 0 ;| 203 + Send, {PgUp} ;| 204 + else ;| 205 + Send, +{PgUp} ;| 206 + return ;| 207 + } ;| 208 + else { ;| 209 + if GetKeyState("alt") = 0 ;| 210 + Send, ^{PgUp} ;| 211 + else ;| 212 + Send, +^{PgUp} ;| 213 + return ;| 214 + } ;| 215 + return ;| 216 + ;-----------------------------------o ;| 217 + CapsLock & p:: ;| 218 + if GetKeyState("control") = 0 ;| 219 + { ;| 220 + if GetKeyState("alt") = 0 ;| 221 + Send, {PgDn} ;| 222 + else ;| 223 + Send, +{PgDn} ;| 224 + return ;| 225 + } ;| 226 + else { ;| 227 + if GetKeyState("alt") = 0 ;| 228 + Send, ^{PgDn} ;| 229 + else ;| 230 + Send, +^{PgDn} ;| 231 + return ;| 232 + } ;| 233 + return ;| 234 + ;---------------------------------------------------------------------o 235 + 236 + 237 + ;=====================================================================o 238 + ; CapsLock Mouse Controller ;| 239 + ;-----------------------------------o---------------------------------o 240 + ; CapsLock + Up | Mouse Up ;| 241 + ; CapsLock + Down | Mouse Down ;| 242 + ; CapsLock + Left | Mouse Left ;| 243 + ; CapsLock + Right | Mouse Right ;| 244 + ; CapsLock + Enter(Push Release) | Mouse Left Push(Release) ;| 245 + ;-----------------------------------o---------------------------------o 246 + CapsLock & Up:: MouseMove, 0, -10, 0, R ;| 247 + CapsLock & Down:: MouseMove, 0, 10, 0, R ;| 248 + CapsLock & Left:: MouseMove, -10, 0, 0, R ;| 249 + CapsLock & Right:: MouseMove, 10, 0, 0, R ;| 250 + ;-----------------------------------o ;| 251 + CapsLock & Enter:: ;| 252 + SendEvent {Blind}{LButton down} ;| 253 + KeyWait Enter ;| 254 + SendEvent {Blind}{LButton up} ;| 255 + return ;| 256 + ;---------------------------------------------------------------------o 257 + 258 + 259 + ;=====================================================================o 260 + ; CapsLock Deletor ;| 261 + ;-----------------------------------o---------------------------------o 262 + ; CapsLock + n | Ctrl + Delete (Delete a Word) ;| 263 + ; CapsLock + m | Delete ;| 264 + ; CapsLock + , | BackSpace ;| 265 + ; CapsLock + . | Ctrl + BackSpace ;| 266 + ;-----------------------------------o---------------------------------o 267 + CapsLock & ,:: Send, {Del} ;| 268 + CapsLock & .:: Send, ^{Del} ;| 269 + CapsLock & m:: Send, {BS} ;| 270 + CapsLock & n:: Send, ^{BS} ;| 271 + ;---------------------------------------------------------------------o 272 + 273 + 274 + ;=====================================================================o 275 + ; CapsLock Editor ;| 276 + ;-----------------------------------o---------------------------------o 277 + ; CapsLock + z | Ctrl + z (Cancel) ;| 278 + ; CapsLock + x | Ctrl + x (Cut) ;| 279 + ; CapsLock + c | Ctrl + c (Copy) ;| 280 + ; CapsLock + v | Ctrl + z (Paste) ;| 281 + ; CapsLock + a | Ctrl + a (Select All) ;| 282 + ; CapsLock + y | Ctrl + z (Yeild) ;| 283 + ; CapsLock + w | Ctrl + Right(Move as [vim: w]);| 284 + ; CapsLock + b | Ctrl + Left (Move as [vim: b]);| 285 + ;-----------------------------------o---------------------------------o 286 + CapsLock & z:: Send, ^z ;| 287 + CapsLock & x:: Send, ^x ;| 288 + CapsLock & c:: Send, ^c ;| 289 + CapsLock & v:: Send, ^v ;| 290 + CapsLock & a:: Send, ^a ;| 291 + CapsLock & y:: Send, ^y ;| 292 + CapsLock & w:: Send, ^{Right} ;| 293 + CapsLock & b:: Send, ^{Left} ;| 294 + ;---------------------------------------------------------------------o 295 + 296 + 297 + ;=====================================================================o 298 + ; CapsLock Media Controller ;| 299 + ;-----------------------------------o---------------------------------o 300 + ; CapsLock + F1 | Volume_Mute ;| 301 + ; CapsLock + F2 | Volume_Down ;| 302 + ; CapsLock + F3 | Volume_Up ;| 303 + ; CapsLock + F3 | Media_Play_Pause ;| 304 + ; CapsLock + F5 | Media_Next ;| 305 + ; CapsLock + F6 | Media_Stop ;| 306 + ;-----------------------------------o---------------------------------o 307 + CapsLock & F1:: Send, {Volume_Mute} ;| 308 + CapsLock & F2:: Send, {Volume_Down} ;| 309 + CapsLock & F3:: Send, {Volume_Up} ;| 310 + CapsLock & F4:: Send, {Media_Play_Pause} ;| 311 + CapsLock & F5:: Send, {Media_Next} ;| 312 + CapsLock & F6:: Send, {Media_Stop} ;| 313 + ;---------------------------------------------------------------------o 314 + 315 + 316 + ;=====================================================================o 317 + ; CapsLock Window Controller ;| 318 + ;-----------------------------------o---------------------------------o 319 + ; CapsLock + s | Ctrl + Tab (Swith Tag) ;| 320 + ; CapsLock + q | Ctrl + W (Close Tag) ;| 321 + ; (Disabled) Alt + CapsLock + s | AltTab (Switch Windows) ;| 322 + ; Alt + CapsLock + q | Ctrl + Tab (Close Windows) ;| 323 + ; CapsLock + g | AppsKey (Menu Key) ;| 324 + ;-----------------------------------o---------------------------------o 325 + CapsLock & s::Send, ^{Tab} ;| 326 + ;-----------------------------------o ;| 327 + CapsLock & q:: ;| 328 + if GetKeyState("alt") = 0 ;| 329 + { ;| 330 + Send, ^w ;| 331 + } ;| 332 + else { ;| 333 + Send, !{F4} ;| 334 + return ;| 335 + } ;| 336 + return ;| 337 + ;-----------------------------------o ;| 338 + CapsLock & g:: Send, {AppsKey} ;| 339 + ;---------------------------------------------------------------------o 340 + 341 + 342 + ;=====================================================================o 343 + ; CapsLock Self Defined Area ;| 344 + ;-----------------------------------o---------------------------------o 345 + ; CapsLock + d | Alt + d(Dictionary) ;| 346 + ; CapsLock + f | Alt + f(Search via Everything);| 347 + ; CapsLock + e | Open Search Engine ;| 348 + ; CapsLock + r | Open Shell ;| 349 + ; CapsLock + t | Open Text Editor ;| 350 + ;-----------------------------------o---------------------------------o 351 + CapsLock & d:: Send, !d ;| 352 + CapsLock & f:: Send, !f ;| 353 + CapsLock & e:: Run http://cn.bing.com/ ;| 354 + CapsLock & r:: Run Powershell ;| 355 + CapsLock & t:: Run C:\Program Files (x86)\Notepad++\notepad++.exe ;| 356 + ;---------------------------------------------------------------------o 357 + 358 + 359 + ;=====================================================================o 360 + ; CapsLock Char Mapping ;| 361 + ;-----------------------------------o---------------------------------o 362 + ; CapsLock + ; | Enter (Cancel) ;| 363 + ; CapsLock + ' | = ;| 364 + ; CapsLock + [ | Back (Visual Studio) ;| 365 + ; CapsLock + ] | Goto Define (Visual Studio) ;| 366 + ; CapsLock + / | Comment (Visual Studio) ;| 367 + ; CapsLock + \ | Uncomment (Visual Studio) ;| 368 + ; CapsLock + 1 | Build and Run(Visual Studio) ;| 369 + ; CapsLock + 2 | Debuging (Visual Studio) ;| 370 + ; CapsLock + 3 | Step Over (Visual Studio) ;| 371 + ; CapsLock + 4 | Step In (Visual Studio) ;| 372 + ; CapsLock + 5 | Stop Debuging(Visual Studio) ;| 373 + ; CapsLock + 6 | Shift + 6 ^ ;| 374 + ; CapsLock + 7 | Shift + 7 & ;| 375 + ; CapsLock + 8 | Shift + 8 * ;| 376 + ; CapsLock + 9 | Shift + 9 ( ;| 377 + ; CapsLock + 0 | Shift + 0 ) ;| 378 + ;-----------------------------------o---------------------------------o 379 + CapsLock & `;:: Send, {Enter} ;| 380 + CapsLock & ':: Send, = ;| 381 + CapsLock & [:: Send, ^- ;| 382 + CapsLock & ]:: Send, {F12} ;| 383 + ;-----------------------------------o ;| 384 + CapsLock & /:: ;| 385 + Send, ^e ;| 386 + Send, c ;| 387 + return ;| 388 + ;-----------------------------------o ;| 389 + CapsLock & \:: ;| 390 + Send, ^e ;| 391 + Send, u ;| 392 + return ;| 393 + ;-----------------------------------o ;| 394 + CapsLock & 1:: Send,^{F5} ;| 395 + CapsLock & 2:: Send,{F5} ;| 396 + CapsLock & 3:: Send,{F10} ;| 397 + CapsLock & 4:: Send,{F11} ;| 398 + CapsLock & 5:: Send,+{F5} ;| 399 + ;-----------------------------------o ;| 400 + CapsLock & 6:: Send,+6 ;| 401 + CapsLock & 7:: Send,+7 ;| 402 + CapsLock & 8:: Send,+8 ;| 403 + CapsLock & 9:: Send,+9 ;| 404 + CapsLock & 0:: Send,+0 ;| 405 + ;---------------------------------------------------------------------o
Windows/AutoHotKey/examples/capslock.exe

This is a binary file and will not be displayed.

+12
Windows/AutoHotKey/examples/minimal_vim.ahk
··· 1 + CapsLock::Send, {CTRLDOWN}{SHIFTDOWN}{SHIFTUP}{CTRLUP}{CTRLUP} 2 + return 3 + !^CapsLock::CapsLock 4 + 5 + CapsLock & j :: Send {Down} 6 + CapsLock & k :: Send {Up} 7 + CapsLock & h :: Send {Left} 8 + CapsLock & l :: Send {right} 9 + CapsLock & p :: Send {PGUP} 10 + CapsLock & `; :: Send {PGDN} 11 + CapsLock & ^ :: Send {home} 12 + CapsLock & $ :: Send {end}
+21
k9s/hotkey.yml
··· 1 + hotKey: 2 + f1: 3 + shortCut: F1 4 + description: View pods 5 + command: pods 6 + f2: 7 + shortCut: F2 8 + description: View deployments 9 + command: dp 10 + f3: 11 + shortCut: F3 12 + description: View statefulsets 13 + command: sts 14 + f4: 15 + shortCut: F4 16 + description: View services 17 + command: service 18 + f5: 19 + shortCut: F5 20 + description: View ingresses 21 + command: ingress
-1
package.json
··· 1 - {}