summaryrefslogtreecommitdiff
path: root/_windows/ahk/capslock.ahk
blob: 0f03daf0ef009b44f5e0a019d397c19895039a85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#Requires AutoHotkey v2
#SingleInstance Force

CapsLock::Esc

SetKeyDelay 1

global CurrentDesktop := 1

ShowCurrentWindows() {
    titles := []
    text := ""

    hwnds := WinGetList()
    for hwnd in hwnds {
        ; skip tool windows
        style := DllCall("GetWindowLongPtr", "Ptr", hwnd, "Int", -20, "Ptr")
        WS_EX_TOOLWINDOW := 0x80
        if style & WS_EX_TOOLWINDOW
            continue

        title := WinGetTitle("ahk_id " hwnd)
        if title = ""
            continue

        titles.Push(title)
        text .= title
        text .= "`n"
    }
    ToolTip text, 0, 0
    SetTimer ToolTip, -1000
}

SwitchDesktop(num) {
    global CurrentDesktop
    While CurrentDesktop > num {
        SendEvent "{Ctrl down}{LWin down}{Left}{LWin up}{Ctrl up}"
        CurrentDesktop--
    }
    While CurrentDesktop < num {
        SendEvent "{Ctrl down}{LWin down}{Right}{LWin up}{Ctrl up}"
        CurrentDesktop++
    }
    ShowCurrentWindows()
}

!1::SwitchDesktop(1)
!2::SwitchDesktop(2)
!3::SwitchDesktop(3)
!4::SwitchDesktop(4)
!5::SwitchDesktop(5)
!6::SwitchDesktop(6)
!7::SwitchDesktop(7)
!8::SwitchDesktop(8)
!9::SwitchDesktop(9)
!0::SwitchDesktop(10)

~^#Left::{
    global CurrentDesktop
    if (CurrentDesktop > 1)
        CurrentDesktop--
}

~^#Right::{
    global CurrentDesktop
    if (CurrentDesktop < 10)
        CurrentDesktop++
}

RCtrl & Backspace::Reload