Shadowspaz

Titan Souls Mouse Support.ahk

Apr 16th, 2015
6,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance, force
  2. DetectHiddenWindows, on
  3. Thread, Interrupt, 0
  4.  
  5. angle := 0
  6. sX := 0
  7. sY := 0
  8. isLeftClick = 0
  9.  
  10. setTimer, checkMouse, 1
  11.  
  12. checkMouse:
  13. if WinActive("TITAN SOULS")
  14. {
  15.   MouseGetPos, mX, mY
  16.   WinGetPos,,,gW,gH
  17.   if (Abs(mX - gW/2) > 5 or Abs(mY - gH/2) > 5)
  18.   {
  19.     sX := gW/2 - mX
  20.     sY := gH/2 - mY
  21.     angle := ATan(sY/sX)
  22.     if (sX < 0)
  23.     {
  24.       if (sY >= 0)
  25.         angle += 3.14159265358979
  26.       else
  27.         angle -= 3.14159265358979
  28.     }
  29.     angle *= 180/3.14159265358979
  30.  
  31.     ;Tooltip, % angle
  32.   }
  33.  
  34.   Key1p = %Key1%
  35.   Key1 =
  36.   Key2p = %Key2%
  37.   Key2 =
  38.  
  39.   if (isLeftClick = 1) {
  40.     if angle between -67.5 and 67.5
  41.       Key1 = Left
  42.     if (angle > 112.5 or angle < -112.5)
  43.       Key1 = Right
  44.     if angle between -157.5 and -22.5
  45.       Key2 = Down
  46.     if angle between 22.5 and 157.5
  47.       Key2 = Up
  48.   }
  49.  
  50.   if (Key1 <> Key1p)
  51.   {
  52.     if Key1 <>
  53.       Send {%Key1% down}
  54.     if Key1p <>
  55.       Send {%Key1p% up}
  56.   }
  57.  
  58.  
  59.   if (Key2 <> Key2p)
  60.   {
  61.     if Key2 <>
  62.       Send {%Key2% down}
  63.     if Key2p <>
  64.       Send {%Key2p% up}
  65.   }
  66.  
  67.   MouseMove, gW/2, gH/2
  68. }
  69.  
  70. return
  71.  
  72. +z::
  73. ExitApp
  74. return
  75.  
  76. #IfWinActive TITAN SOULS
  77.  
  78. LButton::
  79.   send {c down}
  80.   isLeftClick := 1
  81.   return
  82.  
  83. LButton up::
  84.   send {c up}
  85.   isLeftClick := 0
  86.   return
  87.  
  88. RButton::x
  89. Space::x
  90. w::Up
  91. s::Down
  92. a::Left
  93. d::Right
  94.  
  95. ; If you want to add your own keybindings, you can just put them here, following suit.
  96. ; The following code binds numpad2 and j to the x key. You can just add on to it.
  97. ; Be sure to add the 'up' key, as well: "j up" releases the x key when you release j.
  98.  
  99. Numpad2::
  100. j::
  101. send {x down}
  102. return
  103.  
  104. Numpad2 up::
  105. j up::
  106. send {x up}
  107. return
  108.  
  109. Numpad3::
  110. k::
  111. send {c down}
  112. return
  113.  
  114. Numpad3 up::
  115. k up::
  116. send {c up}
  117. return
Advertisement
Add Comment
Please, Sign In to add comment