kilrain

DFscript2.ahk

May 5th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;;;;;;;;;;;;;;;;;;;;;;;; Includes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. if not A_IsAdmin
  3. {
  4.    Run *RunAs "%A_ScriptFullPath%"
  5.    ExitApp
  6. }
  7.  
  8. #SingleInstance force  
  9. #InstallKeybdHook
  10. #InstallMouseHook
  11. #NoEnv
  12. #If !isMouseShown() and WinActive("Darkfall Unholy Wars")
  13.  
  14.  
  15.  
  16. ;;;;;;;;;;;;;;;;;;;;; Text to Speech ;;;;;;;;;;;;;;;;;;;;;;;
  17.  
  18. ttsEnabled = true
  19. ttsVolume = 100
  20. Menu, Tray, Add, Add Hotkeys, run
  21.  
  22. ;;;;;;;;;;;;;;;;;;;;;;;;; Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;
  23.  
  24. config=
  25. (
  26. [Hotkeys]
  27. mountLeft=Left
  28. mountRight=Right
  29.  
  30. [version]
  31. major=2
  32. minor=0
  33.  
  34. [Togglekeys]
  35. autoFire=+^LButton
  36. instaCast=+^RButton
  37. insta=0
  38. auto=0
  39.  
  40. [Filepath]
  41. loc=
  42. )
  43.  
  44. IfNotExist, c:\DFscript\config.ini
  45. {
  46.     FileCreateDir, C:\DFscript
  47.     FileAppend %config%, c:\DFscript\config.ini
  48. }
  49.  
  50. Loop, %A_Appdata%\VideoOptions.cfg, , 1
  51. {
  52.     if(A_LoopFileTimeModified>Rec)
  53.     {
  54.         fileloc=%A_LoopFileFullPath%
  55.                
  56.         Rec=%A_LoopFileTimeModified%
  57.     }
  58. }
  59.     if(fileloc = Error)
  60.     {
  61.         MsgBox, "Could not locate VideoConfig.cfg"  --  Check forums for issues `n Press Ok to close script.
  62.         ExitApp
  63.     }else{
  64.         IniWrite, %fileloc%, c:\DFscript\config.ini, Filepath, Loc
  65.     }
  66.  
  67.  
  68. Loc := getIni("c:\DFscript\config.ini", "Filepath", "Loc")
  69. actionL := "Action.TriggerLeftCurrentAction"
  70. actionR := "Action.TriggerRightCurrentAction"
  71.  
  72. quick5 := "Action.ActivateQuickItem5"
  73.  
  74. Lradial1 := "GUI.SelectLeftRadialSlot1"
  75. Lradial2 := "GUI.SelectLeftRadialSlot2"
  76. Lradial3 := "GUI.SelectLeftRadialSlot3"
  77. Lradial4 := "GUI.SelectLeftRadialSlot4"
  78. Lradial5 := "GUI.SelectLeftRadialSlot5"
  79. Lradial6 := "GUI.SelectLeftRadialSlot6"
  80. Lradial7 := "GUI.SelectLeftRadialSlot7"
  81. Lradial8 := "GUI.SelectLeftRadialSlot8"
  82. Rradial1 := "GUI.SelectRightRadialSlot1"
  83. Rradial2 := "GUI.SelectRightRadialSlot2"
  84. Rradial3 := "GUI.SelectRightRadialSlot3"
  85. Rradial4 := "GUI.SelectRightRadialSlot4"
  86. Rradial5 := "GUI.SelectRightRadialSlot5"
  87. Rradial6 := "GUI.SelectRightRadialSlot6"
  88. Rradial7 := "GUI.SelectRightRadialSlot7"
  89. Rradial8 := "GUI.SelectRightRadialSlot8"
  90.  
  91. FileDelete, c:\DFscript\version.ini
  92. URLDownloadToFile, http://pastebin.com/raw.php?i=EU0zv5nS, c:\DFscript\version.ini
  93.  
  94. global Nmajor := getIni("c:\DFscript\version.ini", "version", "major")
  95. global Nminor := getIni("c:\DFscript\version.ini", "version", "minor")
  96. global major := getIni("c:\DFscript\config.ini", "version", "major")
  97. global minor := getIni("c:\DFscript\config.ini", "version", "minor")
  98.  
  99. update(major, minor)
  100. {
  101.     FileCopy, DFscript.ahk, *.bak
  102.     FileCopy, functions.ahk, *.bak
  103.     URLDownloadToFile, http://pastebin.com/raw.php?i=fNJMTXTc, DFscript.ahk
  104.     URLDownloadToFile, http://pastebin.com/raw.php?i=HaziAzKp, functions.ahk
  105.     IniWrite, %Nmajor%, c:\DFscript\config.ini, version, major
  106.     IniWrite, %Nminor%, c:\DFscript\config.ini, version, minor
  107.     return
  108. }
  109.  
  110. GetKey(bind, fileLoc)
  111. {
  112.     FileRead, configVar, %fileLoc%
  113.     if not ErrorLevel
  114.     {
  115.         StringGetPos, startPos, configVar, %bind%
  116.         StringTrimLeft, newfile1, configVar, startPos
  117.         StringGetPos, startPos, newfile1, `;
  118.         StringTrimLeft, newfile1, newfile1, startPos
  119.         StringGetPos, endPos, newfile1, `,`&
  120.         total := StrLen(newfile1)
  121.         StringTrimRight, newfile1, newfile1, total - endPos
  122.         StringReplace, newfile1, newfile1, `,, +
  123.             Loop, Parse, newfile1, `;
  124.             {
  125.                 keyV := A_LoopField
  126.                 Loop, Parse, keyV, +
  127.                     var%A_Index% := A_LoopField
  128.             }
  129.                 FileRead, keylist, keylist.txt
  130.                 if not ErrorLevel
  131.                 {
  132.                     Loop, Parse, keylist, `~, %A_Space%
  133.                         if RegExMatch(A_LoopField,"^(" var1 ")=(.*)$",found)
  134.                             key1 := found2
  135.                     Loop, Parse, keylist, `~, %A_Space%
  136.                         if RegExMatch(A_LoopField,"^(" var2 ")=(.*)$",found)
  137.                             key2 := found2
  138.                         global key3 := key1 key2
  139.                 }return, %key3%
  140.     }
  141. }
  142.  
  143.  
  144.  
  145. isMouseShown()
  146. {
  147. StructSize := A_PtrSize + 16
  148. VarSetCapacity(InfoStruct, StructSize)
  149. NumPut(StructSize, InfoStruct)
  150. DllCall("GetCursorInfo", UInt, &InfoStruct)
  151. Result := NumGet(InfoStruct, 8)
  152.  
  153. if Result
  154. return 1
  155. else
  156. return 0
  157. }
  158.  
  159. SAPI := ComObjCreate("SAPI.SpVoice")
  160. SAPI.volume := 100
  161.  
  162. say(msg)
  163. {
  164.     global ttsEnabled
  165.     if(ttsEnabled == "true")
  166.     {
  167.         global SAPI
  168.         SAPI.speak(msg,1)
  169.     }
  170. }
  171.  
  172. getIni(config, section, key)
  173. {
  174.     IniRead value, %config%, %section%, %key%
  175.     return value
  176. }
  177.  
  178. ;;;;;;;;;;;;;;;;;;; Update Check ;;;;;;;;;;;;;;;;;;;
  179.  
  180. if (major < Nmajor) or (major = Nmajor and minor < Nminor)
  181. {
  182.     Gui 2: Add, ActiveX, x0 y0 w980 h600 vWB, Shell.Explorer
  183.     WB.Navigate("http://www.ahkgaming.com/changelog.html")
  184.     Gui 2: Add, Button, x0 y600 w327 h40 , View Source (2 files)
  185.     Gui 2: Add, Button, x654 y600 w327 h40 , Download Update
  186.     Gui 2: Add, Button, x327 y600 w327 h40, Cancel
  187.  
  188.     Gui 2: Show, Center h640 w980, New Update Available
  189. return
  190. }
  191.  
  192. 2ButtonCancel:
  193. Gui, 2: Hide
  194.  
  195. ;;;;;;;;;;;;;;;;;;; Welcome Message ;;;;;;;;;;;;;;;;;;;
  196.  
  197. ;welcomeMsg = Welcome to Darkfall.
  198. ;say(welcomeMsg)
  199.  
  200. ;;;;;;;;;;;;;;;;;;;;; ini check ;;;;;;;;;;;;;;;;;;;;;;;;
  201.  
  202. major := getIni("c:\DFscript\config.ini", "version", "major")
  203. minor := getIni("c:\DFscript\config.ini", "version", "minor")
  204.  
  205. ;;;;;;;;;;;;;;;;;;;;;;;;; Variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  206.  
  207. global leftAction  := GetKey(actionL, Loc)
  208. global rightAction := GetKey(actionR, Loc)
  209. spawnMount := GetKey(quick5, Loc)
  210.  
  211. autoFire := getIni("c:\DFscript\config.ini", "Togglekeys", "autoFire")
  212. instaCast := getIni("c:\DFscript\config.ini", "Togglekeys", "instaCast")
  213. auto := getIni("c:\DFscript\config.ini", "Togglekeys", "auto")
  214. insta := getIni("c:\DFscript\config.ini", "Togglekeys", "insta")
  215.  
  216.  
  217. mountLeft := getIni("c:\DFscript\config.ini", "Hotkeys", "mountLeft")
  218. mountRight := getIni("c:\DFscript\config.ini", "Hotkeys", "mountRight")
  219.  
  220. ver := getini("c:\DFscript\config.ini", "version", "ver")
  221. mounted := false
  222.  
  223. if(spawnMount)
  224. {
  225. Hotkey, ~%spawnMount%, spawnMount
  226. }
  227. if(mountLeft)
  228. {
  229. Hotkey, %mountLeft%, mountLeft
  230. }
  231. if(mountRight)
  232. {
  233. Hotkey, %mountRIght%, mountRight
  234. }
  235.  
  236. loop, 8
  237. {
  238.     variables := GetKey(Lradial%A_Index%, Loc)
  239.     Hotkey, ~%variables%, left1
  240. }
  241. loop, 8
  242. {
  243.     variables := GetKey(Rradial%A_Index%, Loc)
  244.     Hotkey, ~%variables%, right1
  245. }
  246.  
  247.  
  248. ;;;;;;;;;;;;;;;;;;;;;;;;; Hotkey Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  249.  
  250. ^+LButton::
  251. if(auto == true)
  252. {
  253.     say("auto fire deactivated")
  254.     auto := false
  255. }else{
  256.     say("auto fire activated")
  257.     auto := true
  258. }
  259. return
  260.  
  261. ^+RButton::
  262. if(insta == true)
  263. {
  264.     say("insta cast deactivated")
  265.     insta := false
  266. }else{
  267.     say("insta cast activated")
  268.     insta := true
  269. }
  270. return
  271.  
  272. spawnMount:
  273. mounted := true
  274. return
  275.  
  276. left1:
  277. wheel = 1
  278. mounted := false
  279. return
  280.  
  281.  
  282. right1:
  283. if(insta)
  284. {
  285.     mounted := false
  286.     wheel = 1
  287.     sleep 250
  288.     send, {%rightAction% down}
  289.     sleep 150
  290.     send, {%rightAction% up}
  291.     return
  292. }else{
  293.     mounted := false
  294.     wheel = 2
  295.     return
  296. }
  297.  
  298. ;;;;;;;;;;;;;;;;;;;;;;;;; Action Center ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  299.  
  300. *RButton::
  301. if(mounted)
  302. {
  303.     if(auto)
  304.     {
  305.         Loop
  306.         {
  307.             GetKeyState, press, RButton, P
  308.             If press = U
  309.                 Break
  310.             Send, {%rightAction% down}
  311.             sleep 150
  312.             Send, {%rightAction% up}
  313.             sleep 20
  314.         }
  315.     }else{
  316.         send, {%rightAction% down}
  317.         KeyWait, Rbutton, Up
  318.         send, {%rightAction% up}
  319.         return
  320.     }
  321. }else{
  322.     Send {Rbutton down}
  323.     KeyWait, Rbutton, Up
  324.     Send {Rbutton up}
  325.     return
  326. }
  327.  
  328. *LButton::
  329. if(wheel = 1)
  330. {
  331.     if(auto)
  332.     {
  333.         Loop
  334.         {
  335.             GetKeyState, press, LButton, P
  336.             If press = U
  337.                 Break
  338.             Send, {%leftAction% down}
  339.             sleep 150
  340.             Send, {%leftAction% up}
  341.             sleep 20
  342.         }
  343.     }else{
  344.         send, {%leftAction% down}
  345.         KeyWait, Lbutton, Up
  346.         send, {%leftAction% up}
  347.         return
  348.     }
  349. }else if (wheel = 2)
  350. {
  351.     send, {%rightAction% down}
  352.     KeyWait, Lbutton, Up
  353.     send, {%rightAction% up}
  354.     wheel = 1
  355.     return
  356. }
  357.  
  358. mountLeft:
  359. send, {%leftAction% down}
  360. sleep 100
  361. send, {%leftAction% up}
  362. return
  363.  
  364. mountRight:
  365. send, {%rightAction% down}
  366. sleep 100
  367. send, {%rightAction% up}
  368. return
  369.  
  370. #if
  371. ~esc::
  372. if (isMouseShown())
  373. {
  374.     IniWrite, %auto%, c:\DFscript\config.ini, Togglekeys, auto
  375.     IniWrite, %insta%, c:\DFscript\config.ini, Togglekeys, insta
  376.     Reload
  377. }
  378. return
  379.  
  380. run:
  381. Gui, Add, GroupBox, x56 y47 w190 h110  , Extra Mount Keys (Optional):
  382. Gui, Add, Text, x66 y67 w90 h20 , Mount Left:
  383. Gui, Add, Text, x66 y97 w90 h20 , Mount Right:
  384. Gui, Add, Hotkey, x166 y67 w70 h23 vmountLeft, %mountLeft% ;left action
  385. Gui, Add, Hotkey,  x166 y97 w70 h23 vmountRight, %mountRight% ;right action
  386. Gui, Add, GroupBox, x56 y167 w320 h150 , Toggle Keys
  387. Gui, Add, Text, x66 y197 w110 h20 , Toggle AutoFire:
  388. Gui, Add, Hotkey, x196 y197 w120 h23 vautoFire, %autoFire%
  389. Gui, Add, Text, x66 y257 w110 h20 , Toggle Inst-Cast:
  390. Gui, Add, Hotkey, x196 y257 w120 h23 vinstaCast, %instaCast%
  391. Gui, Add, Text, x76 y220 w150 h20 , Default: ctrl+shift+Lbutton
  392. Gui, Add, Text, x76 y280 w160 h20 , Default: ctrl+shift+Rbutton
  393. Gui, Show
  394. return
  395.  
  396. 2ButtonDownloadUpdate:
  397. update(Nmajory, Nminor)
  398. Reload
  399. return
  400.  
  401. 2GuiClose:
  402. ExitApp
  403.  
  404. 2ButtonViewSource(2files):
  405. run http://pastebin.com/raw.php?i=fNJMTXTc
  406. run http://pastebin.com/raw.php?i=HaziAzKp
  407. return
  408.  
  409. GuiClose:
  410. Gui,Submit
  411. IniWrite, %mountLeft%, c:\DFscript\config.ini, Hotkeys, mountLeft
  412. IniWrite, %mountRight%, c:\DFscript\config.ini, Hotkeys, mountRight
  413.  
  414. IniWrite, %autoFire%, c:\DFscript\config.ini, Togglekeys, autoFire
  415. IniWrite, %instaCast%, c:\DFscript\config.ini, Togglekeys, instaCast
  416. Gui, Destroy
Advertisement
Add Comment
Please, Sign In to add comment