Advertisement
Guest User

Hotkeys

a guest
Dec 15th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance force
  2. #NoEnv
  3. #Persistent
  4.  
  5. Gui, Add, Hotkey, x12 y9 w100 h20 vMyHotkey,
  6. Gui, Add, Text, x122 y11 , Вызовет Msgbox
  7. Gui, Add, Button, x12 y39 w100 h30 gSave, Сохраняем
  8. Gui, Add, Button, x122 y39 w90 h30 gLoad, Загружаем
  9. Gui, Show,, Заголовок окна Hotkey
  10. return
  11.  
  12. GuiClose(GuiHwnd)
  13. {
  14.     ExitApp
  15. }
  16.  
  17. Save()
  18. {
  19.     GuiControlGet, hk,, MyHotkey
  20.     Hotkey, IfWinNotActive, Заголовок окна Hotkey      ; все хоткеи, что создадутся ниже в этом потоке будут работать везде кроме активного окна c таким заголовком. Подробнее тут - https://www.autohotkey.com/docs/commands/Hotkey.htm
  21.     Hotkey, % "~" GetKeysVK(hk), hkFunc                      ; там же можно прилепить всякие модификаторы ~, * и $
  22.     IniWrite, % "~" GetKeysVK(hk), tmp.ini, Section, Key
  23. }
  24.  
  25. Load()
  26. {
  27.     IniRead, hk, tmp.ini, Section, Key
  28.     Hotkey, IfWinNotActive, Заголовок окна Hotkey   ; а можно сделать "Hotkey, IfWinActive, GTA:SA:MP"
  29.     Hotkey, % "~" GetKeysVK(hk), hkFunc
  30.     GuiControl,, "~" MyHotkey, % GetKeysVK(hk)
  31. }
  32.  
  33. GetKeysVK(Hotkey)
  34. {
  35.     RegExMatch(Hotkey, "S)^([\^\+!]*)(.*?)$", K)
  36.     If (StrLen(K2) = 1 && !Instr("1234567890-=", K2))
  37.         Return K1 . Format("vk{:X}", GetKeyVK(K2))
  38.     Return Hotkey
  39. }
  40.  
  41. hkFunc()
  42. {
  43.     MsgBox, 0, Кнопка работает, Доброго времени суток`, господа и дамы, 2
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement