Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; to exit this script right click the icon in the system tray
- ; title of the window you want to capture shortcuts in
- $WindowTitle = "Notepad"
- ; visible text in window to help differentiate windows (optional)
- $WindowText = ""
- ; number of buttons defined below
- $NumberOfButtons = 5
- ; example button definition, the function can do any action - in this case making a message box and left clicking at coordinates 300 x 300
- $Button1_Capture = "a"
- Func Button1_Click()
- MsgBox(0,"","Button 1 Clicked")
- MouseClick("left", 300, 300, 1, 0)
- EndFunc
- $Button2_Capture = "b"
- Func Button2_Click()
- MsgBox(0,"","Button 2 Clicked")
- MouseClick("left", 400, 400, 1, 0)
- EndFunc
- $Button3_Capture = "c"
- Func Button3_Click()
- MsgBox(0,"","Button 3 Clicked")
- MouseClick("left", 500, 500, 1, 0)
- EndFunc
- $Button4_Capture = "d"
- Func Button4_Click()
- MsgBox(0,"","Button 4 Clicked")
- MouseClick("left", 600, 600, 1, 0)
- EndFunc
- $Button5_Capture = "e"
- Func Button5_Click()
- MsgBox(0,"","Button 5 Clicked")
- MouseClick("left", 700, 700, 1, 0)
- EndFunc
- ; === END DEFS ===
- Opt("WinTitleMatchMode", 2) ; makes title string match anywhere in the title (vs. starting at the left)
- While 1
- ; if window is active map hot keys
- If WinActive($WindowTitle, $WindowText) Then
- For $i = 1 To $NumberOfButtons
- HotKeySet(Execute("$Button" & $i & "_Capture"), "Button" & $i & "_Click")
- Next
- ; if window is not active remove hot keys
- Else
- For $i = 1 To $NumberOfButtons
- HotKeySet(Execute("$Button" & $i & "_Capture"))
- Next
- EndIf
- Sleep(100)
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement