Advertisement
Guest User

GD utility

a guest
Mar 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  5.  
  6. #SingleInstance Force
  7. physical_hotkey = c
  8. virtual_hotkey = 0
  9. loot_hotkey = p
  10. interval = 29950
  11. last_use = 0
  12. cooldown = 15000
  13.  
  14. global hotkeys = 0
  15. global window_bind = null
  16.  
  17. !a::
  18. WinGet, window_bind, ID, A
  19. hotkeys = 1
  20. SetTimer, loot, 500
  21. SetTimer, refresh, 500
  22. Hotkey,$%physical_hotkey%,intercept
  23. exit
  24.  
  25. !d::
  26. hotkeys = 0
  27. SetTimer, loot, off
  28. SetTimer, refresh, off
  29. exit
  30.  
  31. refresh:
  32. check_active()
  33. elapsed := A_TickCount - last_use
  34. if (elapsed > interval && elapsed > cooldown)
  35. {
  36. send %virtual_hotkey%
  37. last_use := A_TickCount
  38. }
  39. exit
  40.  
  41. loot:
  42. check_active()
  43. if GetKeyState("LButton")
  44. {
  45. exit
  46. }
  47. send %loot_hotkey%
  48. exit
  49.  
  50. check_active(default =-1)
  51. {
  52. WinGet, current, ID, A
  53. if (current != window_bind or !hotkeys)
  54. {
  55. If(default != -1)
  56. {
  57. send {%default%}
  58. }
  59. exit
  60. }
  61. }
  62.  
  63. intercept:
  64. check_active(physical_hotkey)
  65. elapsed := A_TickCount - last_use
  66. if (elapsed > cooldown)
  67. {
  68. last_use := A_TickCount
  69. send {%virtual_hotkey%}
  70. }
  71. exit
  72.  
  73. delay_send(keys, delay)
  74. {
  75. Loop, parse, keys
  76. {
  77. send %A_LoopField%
  78. sleep %delay%
  79. }
  80. }
  81. exit
  82.  
  83. ^Esc::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement