Fearsoulfire

pastebin autohotkey

Aug 16th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.82 KB | None | 0 0
  1. ;**************************************************************
  2. ;Elemeno's Keycloner for World of Warcraft
  3. ;Current Version 01/07/2013.1
  4. ;Some code inspired by other people from the AHK community
  5. ;Feel free to use / modify this code as needed
  6. ;**************************************************************
  7.  
  8. ;**************************************************************
  9. ;IMPORTANT STUFF
  10. ;To close the program use <CTRL>+<SHIFT>+C at anytime
  11. ;Press 'Pause' to temporarily suspend the program
  12. ;**************************************************************
  13.  
  14. ;To Use:
  15. ;**************************************************************
  16. ; -Log into WoW with 2 separate windows.
  17. ; -Start the program
  18. ; -Pressing <Shift> and F1 will load Camera Setup #1 [Window #1 Maximized, Window #2 25% of screen in bottom left corner]
  19. ; -Pressing <Shift> and F2 will load Camera Setup #2 [Window #1 75% of screen top left, Window #2 25% of screen in bottom left corner]
  20. ; -Pressing F1 will make Window #1 the primary window
  21. ; -Pressing F2 will make Window #2 the primary window
  22. ; -Pressing <Scroll Lock> will reload the script
  23. ;
  24. ; Special Warcraft Setup:
  25. ;**************************************************************
  26. ; This script works heavily dependant on certain macros you have
  27. ; set up with keybinds in your respective warcraft windows.
  28. ; Your two characters should be able to jump and activate the standard
  29. ; shortcut keys but will have a hard time getting around. You will need
  30. ; to set up some /follow macros, and their is no one *correct* way to do it.
  31. ; Search the web, forums, etc.. and you will have different people having their
  32. ; own preferences. I will provide a limited amount below to perform basic
  33. ; functions / tasks on your two characters.
  34. ;
  35. ; Basic Setup:
  36. ;**************************************************************
  37. ; For Wow Instance #1 [Your main character]
  38. ; - Unbind your arrow movement keys
  39. ;
  40. ; For WoW Instance #2 [Your secondary character]
  41. ; - Unbind your standard movement keys Q,W,E,A,S,D
  42. ; - Bind the movement keys to the arrow keys
  43. ; - Set up a macro / keybind to the letter 'G' to read the following:
  44. ; /target nameofmaincharacter (where 'nameofmaincharacter' is the name of your main character)
  45. ; /focus
  46. ; /follow nameofmaincharacter
  47. ; /petfollow nameofmaincharacter
  48. ; /target focustarget
  49. ; The purpose of this is to allow your second character to always have your
  50. ; main as the focus, and will always be targeting what you are targeting.
  51. ; If your main toon selects a new target and want your secondary toons target
  52. ; to get updated, just press 'G' again. I just prefer 'G'. You can make this
  53. ; whatever you want.
  54. ;
  55. ; The Basic setup will allow your secondary character to have a /follow and /target
  56. ; bound to one single key, and allow you to make minor running adjustments by way
  57. ; of the arrow keys. QWEASD control player #1, UP DOWN LEFT RIGHT arrow keys
  58. ; will control player #2 [they must be bound properly in your wow keybindings
  59.  
  60. ;**************************************************************
  61. ;********************** Top of Script *********************
  62. ;**************************************************************
  63.  
  64.  
  65. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  66. ;Warn
  67. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  68. hotkey, ^+c, close
  69. onexit, close
  70. SetBatchLines, -1
  71. windowstyle := 2
  72. WinGet, wowid, List, World of Warcraft
  73. IfWinExist, ahk_id %wowid1% and winexist ahk_id %wowid2%
  74. {
  75. gosub, winrestore
  76. gosub, alwaysontopoff
  77. winmaximize, ahk_id %wowid1%
  78. w1a := A_ScreenWidth * .75
  79. h1a := A_ScreenHeight * .75
  80. w2a := A_ScreenWidth * .25
  81. h2a := A_ScreenHeight * .25
  82. winmove, ahk_id %wowid1%, ,0,0,%w1a%,%h1a%
  83. WinGetPos, x1, y1, w1, h1, ahk_id %wowid1%
  84. gosub, winrestore
  85. winmove, ahk_id %wowid2%, ,%w1%,%h1%,%w2a%,%h2a%
  86. windowstyle := 1
  87. winmaximize, ahk_id %wowid1%
  88. winset, alwaysontop, on, ahk_id %wowid2%
  89. TrayTip , , Elemeno's Keycloner Loaded, 3, 1
  90. winactivate, ahk_id %wowid1%
  91. }
  92. else
  93. {
  94. msgbox, 16, Elemeno's Dual Boxing Keycloner, Please make sure you have both World of Warcraft windows open and running before starting.
  95. exitapp
  96. }
  97.  
  98. ; Asks the user which window they want to be the main
  99. msgbox, 4, Elemeno's Dual Boxing Keycloner, `nDo you want the large window to be your main window?,
  100. ifmsgbox, Yes
  101. {
  102. }
  103. ifmsgbox, No
  104. {
  105. gosub, alwaysontopoff
  106. switch1 = %wowid1%
  107. switch2 = %wowid2%
  108. wowid1 := switch2
  109. wowid2 := switch1
  110. winmaximize, ahk_id %wowid1%
  111. winmove, ahk_id %wowid2%, ,%w1%,%h1%,%w2a%,%h2a%
  112. winset, alwaysontop, on, ahk_id %wowid2%
  113. TrayTip , , Picture In Picture, 3, 1
  114. winactivate, ahk_id %wowid1%
  115. }
  116.  
  117. ;******************* MENU INFORMATION *************************
  118. Menu, tray, add, Window Style #1 [PiP], window1 ; Creates a new menu item.
  119. Menu, tray, add, Window Style #2 [Split View], window2
  120. Menu, tray, add, Window Style #3 [Maximized], window3
  121.  
  122. menu, tray, tip, Elemeno's Dual Boxing Keycloner
  123. return
  124.  
  125. ;**************************************************************
  126. ;**************** START OF ALL THE HOTKEYS ******************
  127. ;**************************************************************
  128.  
  129. ~Pause:: ; Pauses the script
  130. Suspend, Toggle
  131. if A_IsSuspended = 1
  132. {
  133. ToolTip, Elemeno's Dual Boxing Keycloner Suspended, A_ScreenWidth/2, A_ScreenHeight/2, 1
  134. TrayTip, Elemeno's Dual Boxing Keycloner, SUSPENDED, 1, 1
  135. soundplay, *63
  136. }
  137. if A_IsSuspended = 0
  138. {
  139. ToolTip, , 0, 0, 1
  140. TrayTip, Elemeno's Dual Boxing Keycloner, RUNNING, 5, 1
  141. soundplay, *64
  142. }
  143. Return
  144. ;--------------------------------------------------------------
  145. ~ScrollLock:: ; ScrollLock reloads the current script.
  146. Reload
  147. Return
  148. ;--------------------------------------------------------------
  149. ~F1:: ; Sets your defined primary window the the foreground
  150. gosub, alwaysontopoff
  151. if windowstyle = 1
  152. {
  153. gosub, winrestore
  154. winmove, ahk_id %wowid2%, ,%w1%,%h1%,%w2a%,%h2a%
  155. winmaximize, ahk_id %wowid1%
  156. winset, alwaysontop, on, ahk_id %wowid2%
  157. TrayTip , , WINDOW #1 [MAIN], 3, 1
  158. winactivate, ahk_id %wowid1%
  159. }
  160. if windowstyle = 2
  161. {
  162. gosub, winrestore
  163. winmove, ahk_id %wowid1%, ,0,0,%w1a%,%h1a%
  164. winmove, ahk_id %wowid2%, ,%w1%,%h1%,%w2a%,%h2a%
  165. TrayTip , , WINDOW #1 [MAIN], 3, 1
  166. winactivate, ahk_id %wowid1%
  167. }
  168. if windowstyle = 3
  169. {
  170. winmaximize, ahk_id %wowid1%
  171. winminimize, ahk_id %wowid2%
  172. TrayTip , , WINDOW #1 [MAIN], 3, 1
  173. winactivate, ahk_id %wowid1%
  174. }
  175. Return
  176. ;--------------------------------------------------------------
  177. ~F2:: ; Sets your defined secondary window the the foreground
  178. gosub, alwaysontopoff
  179. if windowstyle = 1
  180. {
  181. gosub, winrestore
  182. winmove, ahk_id %wowid1%, ,%w1%,%h1%,%w2a%,%h2a%
  183. winmaximize, ahk_id %wowid2%
  184. winset, alwaysontop, on, ahk_id %wowid1%
  185. TrayTip , , WINDOW #2, 3, 1
  186. winactivate, ahk_id %wowid2%
  187. }
  188. if windowstyle = 2
  189. {
  190. gosub, winrestore
  191. winmove, ahk_id %wowid1%, ,%w1%,%h1%,%w2a%,%h2a%
  192. winmove, ahk_id %wowid2%, ,0,0,%w1a%,%h1a%
  193. TrayTip , , WINDOW #2, 3, 1
  194. winactivate, ahk_id %wowid2%
  195. }
  196. if windowstyle = 3
  197. {
  198. winmaximize, ahk_id %wowid2%
  199. winminimize, ahk_id %wowid1%
  200. TrayTip , , WINDOW #2 [MAIN], 3, 1
  201. winactivate, ahk_id %wowid2%
  202. }
  203. Return
  204. ;--------------------------------------------------------------
  205. window1:
  206. {
  207. ~+F1:: ; Loads Window Profile #1
  208. gosub, alwaysontopoff
  209. gosub, winrestore
  210. windowstyle := 1
  211. winmaximize, ahk_id %wowid1%
  212. winmove, ahk_id %wowid2%, ,%w1%,%h1%,%w2a%,%h2a%
  213. winset, alwaysontop, on, ahk_id %wowid2%
  214. TrayTip , , Picture In Picture, 3, 1
  215. winactivate, ahk_id %wowid1%
  216. Return
  217. }
  218. ;--------------------------------------------------------------
  219. window2:
  220. {
  221. ~+F2:: ; Loads Window Profile #2
  222. gosub, alwaysontopoff
  223. gosub, winrestore
  224. windowstyle := 2
  225. winmove, ahk_id %wowid1%, ,0,0,%w1a%,%h1a%
  226. winmove, ahk_id %wowid2%, ,%w1%,%h1%,%w2a%,%h2a%
  227. TrayTip , , Split View, 3, 1
  228. winactivate, ahk_id %wowid1%
  229. Return
  230. }
  231. ;--------------------------------------------------------------
  232. window3:
  233. {
  234. ~+F3:: ; Loads Window Profile #3
  235. windowstyle := 3
  236. winmaximize, ahk_id %wowid1%
  237. winminimize, ahk_id %wowid2%
  238. TrayTip , , Maximized, 3, 1
  239. winactivate, ahk_id %wowid1%
  240. return
  241. }
  242.  
  243. ;**************************************************************
  244. ;*************** Standard Keyboard Hotkeys ****************
  245. ;**************************************************************
  246.  
  247. ~1::
  248. ~2::
  249. ~3::
  250. ~4::
  251. ~5::
  252. ~6::
  253. ~7::
  254. ~8::
  255. ~9::
  256. ~0::
  257. ~-::
  258. ~=::
  259. ~q::
  260. ~w::
  261. ~e::
  262. ~r::
  263. ~t::
  264. ~y::
  265. ~u::
  266. ~i::
  267. ~o::
  268. ~p::
  269. ~[::
  270. ~]::
  271. ~a::
  272. ~s::
  273. ~d::
  274. ~f::
  275. ~g::
  276. ~h::
  277. ~j::
  278. ~k::
  279. ~l::
  280. ~;::
  281. ~'::
  282. ~z::
  283. ~x::
  284. ~c::
  285. ~v::
  286. ~b::
  287. ~n::
  288. ~m::
  289. ~,::
  290. ~.::
  291. ~`::
  292. ~/::
  293. IfWinActive, ahk_id %wowid1%
  294. {
  295. StringTrimLeft, ThisKey, A_ThisHotKey, 1
  296. ControlSend,, %ThisKey%, ahk_id %wowid2%
  297. Return
  298. }
  299. IfWinActive, ahk_id %wowid2%
  300. {
  301. StringTrimLeft, ThisKey, A_ThisHotKey, 1
  302. ControlSend,, %ThisKey%, ahk_id %wowid1%
  303. Return
  304. }
  305.  
  306. ;**************************************************************
  307. ;************ SHIFT + Standard Keyboard Keys **************
  308. ;**************************************************************
  309.  
  310. ~+1::
  311. ~+2::
  312. ~+3::
  313. ~+4::
  314. ~+5::
  315. ~+6::
  316. ~+7::
  317. ~+8::
  318. ~+9::
  319. ~+0::
  320. ~+-::
  321. ~+=::
  322. ~+q::
  323. ~+w::
  324. ~+e::
  325. ~+r::
  326. ~+t::
  327. ~+y::
  328. ~+u::
  329. ~+i::
  330. ~+o::
  331. ~+p::
  332. ~+[::
  333. ~+]::
  334. ~+a::
  335. ~+s::
  336. ~+d::
  337. ~+f::
  338. ~+g::
  339. ~+h::
  340. ~+j::
  341. ~+k::
  342. ~+l::
  343. ~+;::
  344. ~+'::
  345. ~+z::
  346. ~+x::
  347. ~+c::
  348. ~+v::
  349. ~+b::
  350. ~+n::
  351. ~+m::
  352. ~+,::
  353. ~+.::
  354. ~+`::
  355. ~+/::
  356. IfWinActive, ahk_id %wowid1%
  357. {
  358. StringTrimLeft, ThisKey, A_ThisHotKey, 1
  359. ControlSend,, {shift down}%thiskey%{shift up}, ahk_id %wowid2%
  360. Return
  361. }
  362. IfWinActive, ahk_id %wowid2%
  363. {
  364. StringTrimLeft, ThisKey, A_ThisHotKey, 1
  365. ControlSend,, {shift down}%thiskey%{shift up}, ahk_id %wowid1%
  366. Return
  367. }
  368.  
  369. ;**************************************************************
  370. ;*************** Start of Special Hotkeys *****************
  371. ;**************************************************************
  372.  
  373. ~Enter::
  374. IfWinActive, ahk_id %wowid1%
  375. {
  376. ControlSend,, {Enter}, ahk_id %wowid2%
  377. Return
  378. }
  379. IfWinActive, ahk_id %wowid2%
  380. {
  381. ControlSend,, {Enter}, ahk_id %wowid1%
  382. Return
  383. }
  384. ;--------------------------------------------------------------
  385. ~Tab::
  386. IfWinActive, ahk_id %wowid1%
  387. {
  388. ControlSend,, {Tab}, ahk_id %wowid2%
  389. Return
  390. }
  391. IfWinActive, ahk_id %wowid2%
  392. {
  393. ControlSend,, {Tab}, ahk_id %wowid1%
  394. Return
  395. }
  396. ;--------------------------------------------------------------
  397. ~Delete::
  398. IfWinActive, ahk_id %wowid1%
  399. {
  400. ControlSend,, {Delete}, ahk_id %wowid2%
  401. Return
  402. }
  403. IfWinActive, ahk_id %wowid2%
  404. {
  405. ControlSend,, {Delete}, ahk_id %wowid1%
  406. Return
  407. }
  408. ;--------------------------------------------------------------
  409. ~BackSpace::
  410. IfWinActive, ahk_id %wowid1%
  411. {
  412. ControlSend,, {backspace}, ahk_id %wowid2%
  413. Return
  414. }
  415. IfWinActive, ahk_id %wowid2%
  416. {
  417. ControlSend,, {backspace}, ahk_id %wowid1%
  418. Return
  419. }
  420. ;--------------------------------------------------------------
  421. ~Escape::
  422. IfWinActive, ahk_id %wowid1%
  423. {
  424. ControlSend,, {escape}, ahk_id %wowid2%
  425. Return
  426. }
  427. IfWinActive, ahk_id %wowid2%
  428. {
  429. ControlSend,, {escape}, ahk_id %wowid1%
  430. Return
  431. }
  432.  
  433. ;**************************************************************
  434. ;********************** ARROW Keys ************************
  435. ;**************************************************************
  436.  
  437. ~Up::
  438. IfWinActive, World of Warcraft
  439. {
  440. ControlSend,, {up down}, ahk_id %wowid2%
  441. loop
  442. {
  443. getkeystate, state, up
  444. if state = U
  445. break
  446. }
  447. ControlSend,, {up up}, ahk_id %wowid2%
  448. Return
  449. }
  450. ;--------------------------------------------------------------
  451. ~Down::
  452. IfWinActive, World of Warcraft
  453. {
  454. ControlSend,, {down down}, ahk_id %wowid2%
  455. loop
  456. {
  457. getkeystate, state, down
  458. if state = U
  459. break
  460. }
  461. ControlSend,, {down up}, ahk_id %wowid2%
  462. Return
  463. }
  464. ;--------------------------------------------------------------
  465. ~Left::
  466. IfWinActive, World of Warcraft
  467. {
  468. ControlSend,, {Left down}, ahk_id %wowid2%
  469. loop
  470. {
  471. getkeystate, state, Left
  472. if state = U
  473. break
  474. }
  475. ControlSend,, {Left up}, ahk_id %wowid2%
  476. Return
  477. }
  478. ;--------------------------------------------------------------
  479. ~Right::
  480. IfWinActive, World of Warcraft
  481. {
  482. ControlSend,, {Right down}, ahk_id %wowid2%
  483. loop
  484. {
  485. getkeystate, state, Right
  486. if state = U
  487. break
  488. }
  489. ControlSend,, {Right up}, ahk_id %wowid2%
  490. Return
  491. }
  492.  
  493. ~Space::
  494. IfWinActive, World of Warcraft
  495. {
  496. ControlSend,, {Space down}, ahk_id %wowid2%
  497. loop
  498. {
  499. getkeystate, state, Space
  500. if state = U
  501. break
  502. }
  503. ControlSend,, {Space up}, ahk_id %wowid2%
  504. Return
  505. }
  506.  
  507. ;**************************************************************
  508. ;************************ CLOSE ***************************
  509. ;**************************************************************
  510.  
  511. close:
  512. winset, alwaysontop, off, ahk_id %wowid1%
  513. winset, alwaysontop, off, ahk_id %wowid2%
  514. winmove, ahk_id %wowid1%, ,0,0,640,389
  515. winmove, ahk_id %wowid2%, ,50,50,640,389
  516. exitapp
  517.  
  518.  
  519. ;**************************************************************
  520. ;******************* Windows to Backround ********************
  521. ;**************************************************************
  522.  
  523. alwaysontopoff:
  524. winset, alwaysontop, off, ahk_id %wowid1%
  525. winset, alwaysontop, off, ahk_id %wowid2%
  526. return
  527.  
  528. ;**************************************************************
  529. ;******************* Windows Restored *** ********************
  530. ;**************************************************************
  531.  
  532. winrestore:
  533. winrestore, ahk_id %wowid1%
  534. winrestore, ahk_id %wowid2%
  535. return
  536.  
  537. ;**************************************************************
  538. ;******************* Revision History **********************
  539. ;**************************************************************
  540.  
  541. ; 01/07/2013.1
  542. ; Added Window View #3 [Maximized]
  543. ; Added check for both warcraft windows being open
  544. ; Changed default view to Window View #1
  545. ; Added variables ScreenHeight and ScreenWidth to determine window sizes
  546. ; Added Menu Shortcuts
  547. ; Revised Space hotkey to fix flying issues with second character
  548.  
  549.  
  550. ; 01/03/2013.1
  551. ; Added variable size windows
  552. ; Added use control of main window
  553. ; Fixed minor bugs
  554.  
  555. ; 01/02/2013.1
  556. ; Initial version
Advertisement
Add Comment
Please, Sign In to add comment