Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. SetTitleMatchMode, 1
  3.  
  4. Global masterKeyList := ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h"
  5.     , "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
  6.     , "{Numpad1}", "{Numpad3}", "{Numpad9}", "{Numpad0}", "{NumpadMult}", "{NumpadDot}", "{Insert}", "{Delete}"
  7.     , "{Home}", "{End}", "{Space}", "{Esc}", "{F1}", "{F2}", "{F3}", "{F4}", "{F5}", "{F6}"
  8.     , "[", "]", ";", "'", ",", ".", "-", "=", "{Tab}"]
  9.  
  10. Global totalCheckboxes := masterKeyList.MaxIndex()
  11. Global registrySettingsLocation := "HKEY_CURRENT_USER\Software\AOAC-Settings"
  12. Global guiBuilt = 0
  13. Global scriptPaused = 0
  14.  
  15. ; Gather info on settings
  16. RegRead, mainCharReg, %registrySettingsLocation%, mainChar
  17. if ErrorLevel {
  18.     RegWrite, REG_SZ, %registrySettingsLocation%, mainChar, No Data
  19.     mainCharReg = No Data
  20. }
  21.  
  22. RegRead, aoScriptsLocationReg, %registrySettingsLocation%, aoScriptsLocation
  23. if ErrorLevel {
  24.     RegWrite, REG_SZ, %registrySettingsLocation%, aoScriptsLocation, No Data
  25.     aoScriptsLocationReg = No Data
  26. }
  27.  
  28. RegRead, varFollowKey, %registrySettingsLocation%, followKey
  29. RegRead, varFollowStop, %registrySettingsLocation%, followStop
  30.  
  31.  
  32. for each,obj in masterKeyList {
  33.     RegRead, checkboxKey%each%Reg, %registrySettingsLocation%, checkboxKey%each%
  34.     If ErrorLevel
  35.         RegWrite, REG_DWORD, %registrySettingsLocation%, checkboxKey%each%, 0
  36. }
  37.  
  38. ; main loop
  39. loop {
  40.     if !guiBuilt
  41.         GoSub BuildGUI
  42.     if scriptPaused
  43.         continue
  44. }
  45.  
  46. BuildGUI:
  47. Gui, Add, Edit, x12 y9 w110 h20 vmainChar,
  48. Gui, Add, Text, x122 y9 w180 h20 , <- Character to assist (Main Window)
  49. Gui, Add, CheckBox, x12 y69 w35 h20 vcheckboxKey1, - 1
  50. Gui, Add, CheckBox, x12 y89 w35 h20 vcheckboxKey2, - 2
  51. Gui, Add, CheckBox, x12 y109 w35 h20 vcheckboxKey3, - 3
  52. Gui, Add, CheckBox, x12 y129 w35 h20 vcheckboxKey4, - 4
  53. Gui, Add, CheckBox, x12 y149 w35 h20 vcheckboxKey5, - 5
  54. Gui, Add, CheckBox, x12 y169 w35 h20 vcheckboxKey6, - 6
  55. Gui, Add, CheckBox, x12 y189 w35 h20 vcheckboxKey7, - 7
  56. Gui, Add, CheckBox, x12 y209 w35 h20 vcheckboxKey8, - 8
  57. Gui, Add, CheckBox, x12 y229 w35 h20 vcheckboxKey9, - 9
  58. Gui, Add, CheckBox, x12 y249 w35 h20 vcheckboxKey10, - 0
  59. Gui, Add, CheckBox, x60 y69 w35 h20 vcheckboxKey11, - A
  60. Gui, Add, CheckBox, x60 y89 w35 h20 vcheckboxKey12, - B
  61. Gui, Add, CheckBox, x60 y109 w35 h20 vcheckboxKey13, - C
  62. Gui, Add, CheckBox, x60 y129 w35 h20 vcheckboxKey14, - D
  63. Gui, Add, CheckBox, x60 y149 w35 h20 vcheckboxKey15, - E
  64. Gui, Add, CheckBox, x60 y169 w35 h20 vcheckboxKey16, - F
  65. Gui, Add, CheckBox, x60 y189 w35 h20 vcheckboxKey17, - G
  66. Gui, Add, CheckBox, x60 y209 w35 h20 vcheckboxKey18, - H
  67. Gui, Add, CheckBox, x60 y229 w35 h20 vcheckboxKey19, - I
  68. Gui, Add, CheckBox, x60 y249 w35 h20 vcheckboxKey20, - J
  69. Gui, Add, CheckBox, x108 y69 w35 h20 vcheckboxKey21, - K
  70. Gui, Add, CheckBox, x108 y89 w35 h20 vcheckboxKey22, - L
  71. Gui, Add, CheckBox, x108 y109 w35 h20 vcheckboxKey23, - M
  72. Gui, Add, CheckBox, x108 y129 w35 h20 vcheckboxKey24, - N
  73. Gui, Add, CheckBox, x108 y149 w35 h20 vcheckboxKey25, - O
  74. Gui, Add, CheckBox, x108 y169 w35 h20 vcheckboxKey26, - P
  75. Gui, Add, CheckBox, x108 y189 w35 h20 vcheckboxKey27, - Q
  76. Gui, Add, CheckBox, x108 y209 w35 h20 vcheckboxKey28, - R
  77. Gui, Add, CheckBox, x108 y229 w35 h20 vcheckboxKey29, - S
  78. Gui, Add, CheckBox, x108 y249 w35 h20 vcheckboxKey30, - T
  79. Gui, Add, CheckBox, x156 y69 w35 h20 vcheckboxKey31, - U
  80. Gui, Add, CheckBox, x156 y89 w35 h20 vcheckboxKey32, - V
  81. Gui, Add, CheckBox, x156 y109 w35 h20 vcheckboxKey33, - W
  82. Gui, Add, CheckBox, x156 y129 w35 h20 vcheckboxKey34, - X
  83. Gui, Add, CheckBox, x156 y149 w35 h20 vcheckboxKey35, - Y
  84. Gui, Add, CheckBox, x156 y169 w35 h20 vcheckboxKey36, - Z
  85. Gui, Add, CheckBox, x204 y69 w70 h20 vcheckboxKey37, Numpad 1
  86. Gui, Add, CheckBox, x204 y89 w70 h20 vcheckboxKey38, Numpad 3
  87. Gui, Add, CheckBox, x204 y109 w70 h20 vcheckboxKey39, Numpad 9
  88. Gui, Add, CheckBox, x204 y129 w70 h20 vcheckboxKey40, Numpad 0
  89. Gui, Add, CheckBox, x204 y149 w70 h20 vcheckboxKey41, Numpad *
  90. Gui, Add, CheckBox, x204 y169 w70 h20 vcheckboxKey42, Numpad .
  91. Gui, Add, CheckBox, x204 y189 w70 h20 vcheckboxKey43, Insert
  92. Gui, Add, CheckBox, x204 y209 w70 h20 vcheckboxKey44, Delete
  93. Gui, Add, CheckBox, x204 y229 w70 h20 vcheckboxKey45, Home
  94. Gui, Add, CheckBox, x204 y249 w70 h20 vcheckboxKey46, End
  95. Gui, Add, CheckBox, x285 y69 w70 h20 vcheckboxKey47, Space bar
  96. Gui, Add, CheckBox, x285 y89 w70 h20 vcheckboxKey48, Escape
  97. Gui, Add, CheckBox, x285 y109 w35 h20 vcheckboxKey49, - F1
  98. Gui, Add, CheckBox, x285 y129 w35 h20 vcheckboxKey50, - F2
  99. Gui, Add, CheckBox, x285 y149 w35 h20 vcheckboxKey51, - F3
  100. Gui, Add, CheckBox, x285 y169 w35 h20 vcheckboxKey52, - F4
  101. Gui, Add, CheckBox, x285 y189 w35 h20 vcheckboxKey53, - F5
  102. Gui, Add, CheckBox, x285 y209 w35 h20 vcheckboxKey54, - F6
  103. Gui, Add, CheckBox, x365 y69 w35 h20 vcheckboxKey55, - [
  104. Gui, Add, CheckBox, x365 y89 w35 h20 vcheckboxKey56, - ]
  105. Gui, Add, CheckBox, x365 y109 w35 h20 vcheckboxKey57, - `;
  106. Gui, Add, CheckBox, x365 y129 w35 h20 vcheckboxKey58, - '
  107. Gui, Add, CheckBox, x365 y149 w35 h20 vcheckboxKey59, - ,
  108. Gui, Add, CheckBox, x365 y169 w35 h20 vcheckboxKey60, - .
  109. Gui, Add, CheckBox, x365 y189 w35 h20 vcheckboxKey61, - -
  110. Gui, Add, CheckBox, x365 y209 w35 h20 vcheckboxKey62, - =
  111. Gui, Add, CheckBox, x365 y229 w70 h20 vcheckboxKey63, - Tab
  112. Gui, Add, CheckBox, x502 y159 w100 h30 vch1 gCheckAll, Select All
  113. Gui, Add, CheckBox, x502 y189 w100 h30 vch2 gUnCheckAll, De-Select All
  114. Gui, Add, Button, x502 y109 w100 h30 gSaveAsDefault, Save As Default
  115. Gui, Add, Button, x502 y69 w100 h30 gActivateKeys, Activate Selected
  116. Gui, Add, Edit, x12 y39 w470 h20 vaoScriptsLocation,
  117. Gui, Add, Button, x502 y29 w100 h30 gBrowseAOFolder, Browse to AO Scripts
  118. Gui, Add, Text, x482 y39 w20 h20 , <----
  119. Gui, Add, Button, x15 y300 w50 h20 gHelpButton, Help
  120. Gui, Add, DropDownList, x110 y300 w95 h250 vfollowKey,
  121. Gui, Add, Text, x205 y300 w180 h20, <- Follow (must be checked above)
  122. Gui, Add, DropDownList, x110 y330 w95 h250 vfollowStop,
  123. Gui, Add, Text, x205 y330 w200 h20, <- Stop Follow (must be checked above)
  124. Gui, Add, Text, x480 y300 w130 h40 vpauseResumeTextBox,
  125. Gui, Add, Button, x502 y250 w100 h30 gPauseHotkeys, Toggle On/Off
  126. Gui, Show, x127 y87 h375 w624, AOAC - AO Alt Controller 1.0d
  127.  
  128. ; Set initial values if first time running
  129. if !guiBuilt {
  130.     GuiControl,,aoScriptsLocation, %aoScriptsLocationReg%
  131.     GuiControl,,mainChar, %mainCharReg%
  132.     for each,obj in masterKeyList {
  133.         s := checkboxKey%each%Reg
  134.         GuiControl,,checkboxKey%each%, %s%
  135.     }
  136.     s := ""
  137.     for each,obj in masterKeyList {
  138.         s .= "|" . obj
  139.         if (obj = varFollowKey) {
  140.             s .= "|"
  141.             if (each = masterKeyList.MaxIndex()) ; add another if at the end
  142.                 s .= "|"
  143.         }
  144.     }
  145.     GuiControl,,followKey, %s%
  146.     s := ""
  147.     for each,obj in masterKeyList {
  148.         s .= "|" . obj
  149.         if (obj = varFollowStop) {
  150.             s .= "|"
  151.             if (each = masterKeyList.MaxIndex()) ; add another if at the end
  152.                 s .= "|"
  153.         }
  154.     }
  155.     GuiControl,,followStop, %s%
  156.    
  157.     ; turn off all hotkeys until activated
  158.     for each,obj in masterKeyList {
  159.         tempKey := StrReplace(StrReplace(obj, "{"), "}")
  160.         Hotkey, %tempKey%, Off
  161.     }
  162. }
  163.  
  164. guiBuilt = 1
  165. Return
  166.  
  167. BrowseAOFolder:
  168.     EnvGet, tempFolder, LOCALAPPDATA
  169.     FileSelectFolder, aoScriptsLocation, *%tempFolder%
  170.     GuiControl,,aoScriptsLocation, %aoScriptsLocation%
  171. Return
  172.  
  173. CheckAll:
  174.     Loop, %totalCheckboxes%
  175.         GuiControl,,checkboxKey%A_Index%, 1
  176.     GuiControl,,ch1, 0
  177. Return
  178.  
  179. UnCheckAll:
  180.     Loop, %totalCheckboxes%
  181.         GuiControl,,checkboxKey%A_Index%, 0
  182.     GuiControl,,ch2, 0
  183. Return
  184.  
  185. SaveAsDefault:
  186.     ProcessGUI()
  187.     GuiControlGet, tempMainChar,,mainChar
  188.     GuiControlGet, tempScriptsLocation,,aoScriptsLocation
  189.     GuiControlGet, tempFollowKey,,followKey
  190.     GuiControlGet, tempFollowStop,,followStop
  191.     RegWrite, REG_SZ, %registrySettingsLocation%, mainChar, %tempMainChar%
  192.     RegWrite, REG_SZ, %registrySettingsLocation%, aoScriptsLocation, %tempScriptsLocation%
  193.     RegWrite, REG_SZ, %registrySettingsLocation%, followKey, %tempFollowKey%
  194.     RegWrite, REG_SZ, %registrySettingsLocation%, followStop, %tempFollowStop%
  195.     for each,obj in masterKeyList {
  196.         GuiControlGet, tempCheckBox,,checkboxKey%each%
  197.         RegWrite, REG_DWORD, %registrySettingsLocation%, checkboxKey%each%, %tempCheckBox%
  198.     }
  199. Return
  200.  
  201. ActivateKeys:
  202.     Gui, Submit, NoHide
  203.     scriptPaused = 1
  204.     GoSub PauseHotKeys ; updates the screen to show running
  205.     ProcessGUI()
  206. Return
  207.  
  208. PauseHotkeys:
  209.     if scriptPaused {
  210.         scriptPaused = 0
  211.         Gui, Font, s18 cGreen Bold, Verdana
  212.         GuiControl,Font,pauseResumeTextBox,
  213.         GuiControl,,pauseResumeTextBox, RUNNING
  214.         Gui, Font,,
  215.     }
  216.     else {
  217.         scriptPaused = 1
  218.         Gui, Font, s18 cRed Bold, Verdana
  219.         GuiControl,Font,pauseResumeTextBox,
  220.         GuiControl,,pauseResumeTextBox, PAUSED
  221.         Gui, Font,,
  222.  
  223.     }
  224.     ProcessGUI()
  225. Return
  226.  
  227. HelpButton:
  228.     s := "INFO:`nCreate assist macro as /macro assist /ahkassist`n`n"
  229.     s .= "Use the ~ key to pause as needed (or press the button) `n`n"
  230.     s .= "The Scripts folder will look starting in the AppData folder, most likely just browse to Local\Funcom\Anarchy Online\<random>\Anarchy Online\Scripts `n`n"
  231.     s .= "The follow keybind assumes the follow macro is in this place on all characters and will hit F2  then the /follow macro on all but the main character. The Stop Follow key will send ""s"" to all background windows briefly to walk backwards, breaking follow. If you have this key bound to something else then it won't work."
  232.     MsgBox % s
  233. Return
  234.  
  235. GuiClose:
  236. ExitApp
  237.  
  238. ProcessGUI() {
  239.     GuiControlGet, tempScriptsLocation,,aoScriptsLocation
  240.     GuiControlGet, tempMainChar,,mainChar
  241.     if (tempScriptsLocation = "") {
  242.         s := "You must browse to the AO Scripts folder,`nusually found in c:\users\<username>\appdata\local"
  243.         s .= "`nand browse through the Funcom folders until you find the scripts folder, otherwise`n"
  244.         s .= "the assist macro will not work correctly."
  245.         MsgBox % s
  246.         Return
  247.     }
  248.     if (tempMainChar = "") {
  249.         MsgBox You must fill out a main character name as this `ngets written to the assist script
  250.         Return
  251.     }
  252.     for each,obj in masterKeyList {
  253.         tempKey := StrReplace(StrReplace(obj, "{"), "}")
  254.  
  255.         if (checkboxKey%each% and !scriptPaused)
  256.             Hotkey, %tempKey%, On
  257.         else
  258.             Hotkey, %tempKey%, Off
  259.     }
  260.     tempAssist := tempScriptsLocation . "\ahkassist"
  261.     assistFile := FileOpen(tempAssist, "w")
  262.     if !IsObject(assistFile)
  263.         MsgBox % "There was a problem opening the script file at `n" assistFile
  264.     else {
  265.         s := "/assist " . tempMainChar
  266.         assistFile.Write(s)
  267.         assistFile.Close()
  268.     }
  269. }
  270.  
  271. SendToAO(keyCommand) {
  272.     Global followKey
  273.     Global followStop
  274.     IfWinActive, Anarchy Online
  275.         WinGet, id, list, Anarchy Online
  276.             Loop, %id% {
  277.                 this_id := id%A_Index%
  278.                 IfWinActive, ahk_id %this_id%
  279.                         Continue ; bypass sending to active session, send to all others
  280.                 if (keyCommand = followKey or keyCommand = followStop)
  281.                     if (keyCommand = followKey)
  282.                         ControlSend,, {F2}, ahk_id %this_id%
  283.                     else
  284.                         ControlSend,, "s", ahk_id %this_id%
  285.                 ControlSend,, %keyCommand%, ahk_id %this_id%
  286.             }
  287. }
  288.  
  289.  
  290.  
  291. ; We want all other hotkeys in this app to only execute when AO is the active window
  292. #IfWinActive, Anarchy Online
  293. ~`::GoSub PauseHotKeys
  294. ~1::SendToAO("1")
  295. ~2::SendToAO("2")
  296. ~3::SendToAO("3")
  297. ~4::SendToAO("4")
  298. ~5::SendToAO("5")
  299. ~6::SendToAO("6")
  300. ~7::SendToAO("7")
  301. ~8::SendToAO("8")
  302. ~9::SendToAO("9")
  303. ~0::SendToAO("0")
  304. ~a::SendToAO("a")
  305. ~b::SendToAO("b")
  306. ~c::SendToAO("c")
  307. ~d::SendToAO("d")
  308. ~e::SendToAO("e")
  309. ~f::SendToAO("f")
  310. ~g::SendToAO("g")
  311. ~h::SendToAO("h")
  312. ~i::SendToAO("i")
  313. ~j::SendToAO("j")
  314. ~k::SendToAO("k")
  315. ~l::SendToAO("l")
  316. ~m::SendToAO("m")
  317. ~n::SendToAO("n")
  318. ~o::SendToAO("o")
  319. ~p::SendToAO("p")
  320. ~q::SendToAO("q")
  321. ~r::SendToAO("r")
  322. ~s::SendToAO("s")
  323. ~t::SendToAO("t")
  324. ~u::SendToAO("u")
  325. ~v::SendToAO("v")
  326. ~w::SendToAO("w")
  327. ~x::SendToAO("x")
  328. ~y::SendToAO("y")
  329. ~z::SendToAO("z")
  330. ~NumPad1::SendToAO("{Numpad1}")
  331. ~NumPad3::SendToAO("{Numpad3}")
  332. ~NumPad9::SendToAO("{Numpad9}")
  333. ~NumPad0::SendToAO("{Numpad0}")
  334. ~NumPadMult::SendToAO("{NumpadMult}")
  335. ~NumPadDot::SendToAO("{NumpadDot}")
  336. ~Insert::SendToAO("{Insert}")
  337. ~Delete::SendToAO("{Delete}")
  338. ~Home::SendToAO("{Home}")
  339. ~End::SendToAO("{End}")
  340. ~Space::SendToAO("{Space}")
  341. ~Esc::SendToAO("{Esc}")
  342. ~F1::SendToAO("{F1}")
  343. ~F2::SendToAO("{F2}")
  344. ~F3::SendToAO("{F3}")
  345. ~F4::SendToAO("{F4}")
  346. ~F5::SendToAO("{F5}")
  347. ~F6::SendToAO("{F6}")
  348. ~[::SendToAO("[")
  349. ~]::SendToAO("]")
  350. ~`;::SendToAO(";")
  351. ~'::SendToAO("'")
  352. ~,::SendToAO(",")
  353. ~.::SendToAO(".")
  354. ~-::SendToAO("-")
  355. ~=::SendToAO("=")
  356. ~Tab::SendToAO("{Tab}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement