-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClickyShortcuts.ahk
68 lines (58 loc) · 1.22 KB
/
ClickyShortcuts.ahk
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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;#IfWinActive ahk_exe notepad++.exe ; For debugging in another program
#IfWinActive ahk_exe KingdomsAndCastles.exe
#SingleInstance force
SendMode Event
KeyPositions := {}
; Ctrl + #. Toggles Capture mode, which while associate a key to a mouse position.
^Sc029::
Sound("on")
;Wait for input, (L1) means limited to 1 key
Input key, L1
while (key != "#")
{
SoundBeep 500
Hotkey, %key%, OnKeyPressed
MouseGetPos, x, y
position := new Position(x, y)
KeyPositions[key] := position
Input key, L1
}
Sound("off")
return
BACKSPACE::
Reload
return
OnKeyPressed:
ClickAndReturn(A_ThisHotkey)
return
ClickAndReturn(key)
{
global KeyPositions
position := KeyPositions[key]
MouseGetPos, initialX, initialY
MouseClick, left, position.X, position.Y
MouseMove, initialX, initialY
}
Sound(value)
{
length := 100
if(value = "on"){
SoundBeep 500, length
SoundBeep 750, length
}
else if("off"){
SoundBeep 750, length
SoundBeep 500, length
}
}
class Position
{
__New(x, y)
{
this.X := x
this.Y := y
}
}