Advertisement
Guest User

DotA 2_FreeFog_Self Cast Modifier

a guest
Jul 30th, 2013
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  2. ; Metadata
  3. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  4. /*
  5.     Script:
  6.         Version=1
  7.         Name=FreeFog DotA 2 Self Cast Modifier
  8.         Author=FreeFog
  9.         Date=28/Jul/2013
  10.         Purpose:
  11.             Add a modifier key which targets the player's current selected unit.
  12.     File:
  13.         Name=FF_DotA2_SelfCast.ahk
  14. */
  15. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  16. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  18. ; Notes
  19. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  20. /*
  21.     Hotkeys:
  22.         Self Cast Modifier Key.
  23.         Hide Cursor.
  24.         *F10 Reload Script.
  25.         Shift F10 Close Script.
  26.         Measure Tool.
  27.     User:
  28.         Prerequisites:
  29.             DotA 2.
  30.             Text Editor.
  31.             AutoHotkey:
  32.                 Variant=L
  33.                 Web=http://www.autohotkey.com/
  34.                 File Name=AutoHotkey_L_Install.exe
  35.                 VirusTotal:
  36.                     Results=4/46
  37.                     Date=29/Jul/2013
  38.                     Link=https://www.virustotal.com/en/file/aab0c5b9cadec99dcfe8e7cb141bf63c672015c85c5d19a1c1bdb5c80ebe1e63/analysis/1375141798/
  39.        
  40.         Setup:
  41.             Starting in the Desktop run this script.
  42.             Press the desired key to be used.
  43.            
  44.             Go to the taskbar                                                                         (Next to the clock).
  45.                 Open the script's windows                                                            (Double Click).
  46.                 Menu Bar > View > Key history and script info                                        (Ctrl K).
  47.                 Scroll down and locate the corresponding line.
  48.                 If the desired key is among English standard alphabet or keyboard modifiers
  49.                     Copy the name under the Column "Key"                                            (tutSelfCast).
  50.                 Else
  51.                     Copy the vk and sc values to form the string=vkXXscYYY, ex=vkC0sc027 for ñ        (tutSelfCast).
  52.                         Source=http://www.autohotkey.com/docs/KeyList.htm#SpecialKeys
  53.                 Exit the script                                                                        (Right Click > Exit).
  54.            
  55.             Open the script on the Text Editor.
  56.                 Scroll to Mark: Measure Tool                                                        (Find=Mark: Measure Tool).
  57.                 Erase /* and */, note their placement.
  58.                 Save the edits                                                                        (Ctrl S).
  59.            
  60.             Start the script                                                                        (Double Click).
  61.             Run DotA 2.
  62.                 Create a Practice with Bots Game.
  63.                 Center your mouse cursor in the Character Portrait and press F5.
  64.                 Copy the values from the pop-out window then close it                                (tutX, tutY).
  65.                 Close DotA 2 and the script.
  66.            
  67.             Back to the Text Editor.
  68.                 Scroll to Section: Main > Mark: Measure Tool                                        (Find=Mark: Measure Tool).
  69.                     Add /* and */ as they were before                                                (Ctrl Z).
  70.                
  71.                 Scroll to Section: Config                                                            (Find=; Config).
  72.                     kKeySelfCast    :=    "tutSelfCast"
  73.                     xkPortraitX        :=    tutX
  74.                     xkPortraitY        :=    tutY
  75.                
  76.                 Scroll to Section: Main    > Mark: Self Cast Key                                        (Find=Mark: Self Cast Key).
  77.                     If the desired key performs is NOT limited to this script, i.e. performs
  78.                      another action such as key f writes f or is shared among scripts
  79.                         Replace *RShift:: with ~*tutSelfCast::                                        (Ctrl H).
  80.                         Explanation:
  81.                            Prefixing a hotkey with ~ will preserve its native function, i.e.
  82.                              the key adds the behavior defined on its hotkey to its own.
  83.                             Source=http://www.autohotkey.com/docs/Hotkeys.htm
  84.                     Else
  85.                         Replace *RShift:: with *tutSelfCast::                                        (Ctrl H).
  86.                
  87.                 Save the edits                                                                        (Ctrl S).
  88.        
  89.         Setup Optionals:
  90.            Hide the Cursor while holding down:
  91.                 On the script uncomment and modify Section: Config:
  92.                    kKeyHideCursor := "Numpad9"
  93.                
  94.                 On DotA 2 autoexec.cfg:
  95.                    // Toggle Cursor Visibility
  96.                     alias "ToggleCursorVisibility" "ToggleCursorVisibility_Hide"
  97.                     alias "ToggleCursorVisibility_Hide" "dota_hide_cursor 1;alias ToggleCursorVisibility ToggleCursorVisibility_Show"
  98.                     alias "ToggleCursorVisibility_Show" "dota_hide_cursor 0;alias ToggleCursorVisibility ToggleCursorVisibility_Hide"
  99.                    
  100.                     bind "KP_9" "ToggleCursorVisibility"
  101.                
  102.                 Find out a DotA 2 key alias:
  103.                    Open DotA 2 and assign the key to Control Group 1.
  104.                     Go to config.cfg
  105.                         ...\Steam\steamapps\common\dota 2 beta\dota\cfg\
  106.                     Search for dota_control_group 1 and extract the key alias.
  107.            
  108.             Start this script from another:
  109.                run H:\AHk_Scripts\Dota2\FF_DotA2_SelfCast.ahk
  110.            
  111.             Start this script and DotA 2:
  112.                 Create a file named:
  113.                    DotA2Ini.bat
  114.                 Open it with the Text Editor and place:
  115.                    @echo off
  116.                     rem Switch to drive H
  117.                     H:
  118.  
  119.                     rem DotA 2 AutoHotkey Script
  120.                     cd "H:\AHk_Scripts\Dota2\"
  121.                     start FF_DotA2_SelfCast.ahk
  122.  
  123.                     rem Steam Loaded DotA 2
  124.                     start steam://rungameid/570
  125.  
  126.                     exit
  127.                 Edit to fit your setup.
  128.                     Find out DotA 2 Steam ID:
  129.                        Steam Library > Right Click DotA 2 > Create Desktop Shortcut.
  130.                         Open the shortcut's properties and extract the values.
  131.                 Save edits.
  132.    
  133.         Emergency Kill Switch:
  134.            Section: Main
  135.             Pressing Shift F10 will close the script.
  136.             Pressing F10 alone or with any other key modifier will reload it.
  137.        
  138.         Measure Tool:
  139.            Erase comments, using /* */ does not seam to work. You might need to manually refresh the script if u use /* */.
  140.             Assign a free hotkey to trigger the script, i.e. not used by other Autohotkey Script.
  141.        
  142.         Windows Detection:
  143.            On this script I use DotA'2 windows title, therefore events will be send to any windows whose name matches exactly the string "DOTA 2".
  144.        
  145.     Self:
  146.        Uncomment the Measure Tool in the Main section to build boundaries.
  147.         Emergency Hotkeys should be shared across scripts thru an include.
  148.        
  149.         "if !w" causes an error, it modifies w, use if !(w) or (!w) instead.
  150. */
  151. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  152. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  153. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  154. ; Config
  155. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  156. kKeySelfCast := "RShift"
  157. ;    Manually mod "Mark: Self Cast Key".
  158. xkPortraitX := 373
  159. xkPortraitY := 795
  160.  
  161. ; kKeyHideCursor := "Numpad9"
  162. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  163. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  164. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  165. ; Ini
  166. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  167. #NoEnv
  168. #SingleInstance Ignore
  169. SetBatchLines -1
  170. Process, Priority,, Realtime
  171. SetTitleMatchMode, 3
  172.  
  173. #InstallKeybdHook
  174. #InstallMouseHook
  175. CoordMode Mouse, Screen
  176. SetMouseDelay -1
  177. SetKeyDelay -1
  178. BlockInput Mouse
  179. SendMode Input
  180.  
  181. return    ; Header End
  182. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  183. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  184. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  185. ; Main
  186. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  187. #IfWinActive DOTA 2
  188.     ; Emergency Exit
  189.     ~+F10::ExitApp
  190.     ; Emergency Reset
  191.     ~*F10::Reload
  192.  
  193.     ; Mark: Measure Tool
  194.     /*
  195.     ~*F5::
  196.         MouseGetPos Sx, Sy
  197.         MsgBox % "X:" Sx . " | " . "Y:" . Sy ; %
  198.         Sx := "", Sy := ""
  199.     return
  200.     */
  201.  
  202.     ; Mark: Self Cast Key
  203.     *RShift::
  204.         if GetKeyState(kKeySelfCast, "P") {
  205.             if (kKeyHideCursor) {
  206.                 SendInput {Blind}{%kKeyHideCursor%}
  207.                 Sleep 10
  208.             }
  209.             MouseGetPos x, y
  210.             Xp := x
  211.             Yp := y
  212.             BlockInput MouseMove
  213.             MouseMove xkPortraitX, xkPortraitY, 0
  214.         }
  215.         while GetKeyState(kKeySelfCast, "P")
  216.             Sleep 10
  217.         MouseMove Xp, Yp, 0
  218.         BlockInput MouseMoveOff
  219.         if (kKeyHideCursor) {
  220.             SendInput {Blind}{%kKeyHideCursor%}
  221.             Sleep 10
  222.         }
  223.     return
  224.  
  225. #IfWinActive
  226. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  227. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  228. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  240. ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  241. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  242. ; ---------------------------------------------------------------------------------------------------------------------------------------------------
  243. ; --------------------------------------------------------------------------
  244. ; --------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement