Guest User

AHK script

a guest
Feb 19th, 2016
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. #NoEnv
  2. #Warn All, Off
  3. #singleinstance force
  4. SendMode Input
  5. SetWorkingDir %A_ScriptDir%
  6.  
  7. steam_activate_key(key){
  8. if(key = ""){
  9. return
  10. }
  11. FormatTime, Time,, dd/MM/yyyy HH:mm:ss tt
  12. steam_close_all()
  13. steam_open_activation_window()
  14. steam_move_window()
  15. steam_click_next()
  16. steam_click_next()
  17. steam_activate_product_code_field()
  18. steam_send_input(key)
  19. steam_click_next()
  20. steam_wait_until_done()
  21. steam_click_cancel()
  22. return
  23. }
  24.  
  25. steam_click_next(){
  26. steam_activate_window()
  27. MouseClick, left, 320, 375
  28. Sleep,100
  29. return
  30. }
  31. steam_click_cancel(){
  32. steam_activate_window()
  33. MouseClick, left, 422, 375
  34. Sleep,100
  35. return
  36. }
  37. steam_click_back(){
  38. steam_activate_window()
  39. MouseClick, left, 212, 375
  40. Sleep,100
  41. return
  42. }
  43. steam_click_print(){
  44. steam_activate_window()
  45. MouseClick, left, 221, 407
  46. Sleep,100
  47. return
  48. }
  49. steam_install_click_back(){
  50. steam_activate_install()
  51. MouseClick, left, 212, 375
  52. Sleep,100
  53. return
  54.  
  55. }
  56. steam_install_click_cancel(){
  57. steam_activate_install()
  58. MouseClick, left, 422, 375
  59. Sleep,100
  60. return
  61. }
  62. steam_install_click_next(){
  63. steam_activate_install()
  64. MouseClick, left, 320, 375
  65. Sleep,100
  66. return
  67. }
  68. steam_activate_product_code_field(){
  69. steam_activate_window()
  70. MouseClick, left, 40, 190
  71. Sleep, 100
  72. return
  73. }
  74. steam_send_input(input){
  75. steam_activate_window()
  76. SendInput {Raw}%input%
  77. Sleep,100
  78. return
  79. }
  80.  
  81. steam_activate_window(){
  82. WinWait, Product Activation,
  83. IfWinNotActive, Product Activation, , WinActivate, Product Activation,
  84. WinWaitActive, Product Activation,
  85. Sleep, 100 ;
  86. }
  87. steam_activate_install(){
  88. WinWait, Install -,
  89. IfWinNotActive, Install -, , WinActivate, Install -,
  90. WinWaitActive, Install -,
  91. Sleep,100
  92. }
  93. steam_wait_until_done(){
  94. Sleep,1000
  95. WinWaitNotActive,Steam - Working
  96. }
  97. steam_move_window(){
  98. steam_activate_window()
  99. WinMove, 0, 0
  100. Sleep,100
  101. return
  102. }
  103. steam_open_activation_window(){
  104. Run steam://open/activateproduct
  105. Sleep,100
  106. return
  107. }
  108. steam_close_all(){
  109. IfWinExist,Product Activation,
  110. {
  111. steam_activate_window()
  112. steam_click_back()
  113. steam_click_back()
  114. steam_click_cancel()
  115. WinKill,Product Activation,
  116. Sleep,1000
  117. }
  118. IfWinExist,Install -,
  119. {
  120. steam_activate_install()
  121. steam_install_click_cancel()
  122. WinKill,Install -,
  123. Sleep,1000
  124.  
  125. }
  126. IfWinExist,Print,
  127. {
  128. WinKill,Print,
  129. Sleep,1000
  130. }
  131. return
  132. }
  133. steam_check_if_key_worked(){
  134. if(steam_check_invalid_or_too_many_attempts()){
  135. steam_click_cancel()
  136. return false
  137. }else{
  138. steam_click_print()
  139. steam_click_next()
  140. steam_check_if_on_install_screen()
  141. steam_install_click_cancel()
  142.  
  143. }
  144. }
  145. steam_check_invalid_or_too_many_attempts(){
  146. steam_activate_window()
  147. MouseMove, 61, 207
  148. Sleep,100
  149. If(A_Cursor = "Unknown"){
  150. return true
  151. }else{
  152. return false
  153. }
  154. }
  155. steam_check_if_on_install_screen(){
  156. steam_activate_install()
  157. WinMove, 100, 100
  158. Sleep,100
  159. WinGetTitle, WindowTitle,
  160. StringTrimLeft,gameTitle,WindowTitle,10
  161. }
  162. is_print_window(){
  163. WinWait, Print,,5 ;wait 5 seconds.
  164. if ErrorLevel
  165. {
  166. return false
  167. }else{
  168. IfWinNotActive, Print, WinActivate, Print,
  169. WinWaitActive, Print,
  170. WinKill,Print,
  171. Sleep,100
  172. return true
  173. }
  174. }
  175.  
  176. Loop %0%
  177. {
  178. steam_activate_key(%A_Index%)
  179. Sleep,1000
  180. }
  181. Return
Add Comment
Please, Sign In to add comment