Guest User

Untitled

a guest
Jun 21st, 2017
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.83 KB | None | 0 0
  1. #SingleInstance Force
  2.  
  3. while true
  4. {
  5. loopStart:
  6. sleep, 5000
  7. loopStart2:
  8.  
  9. square1 = 0
  10. square2 = 0
  11. square3 = 0
  12. square4 = 0
  13. square5 = 0
  14. square6 = 0
  15. square7 = 0
  16. square8 = 0
  17. square9 = 0
  18.  
  19. ;shut down end game windows
  20. IfWinExist Match ahk_class Shell_Dialog
  21. {
  22. WinActivate, Match ahk_class Shell_Dialog
  23. MouseMove, 621, 140
  24. MouseClick, left
  25. goto loopStart
  26. }
  27.  
  28. IfWinExist You lost ahk_class Shell_Dialog
  29. {
  30. WinActivate, lost ahk_class Shell_Dialog
  31. MouseMove, 621, 140
  32. MouseClick, left
  33. goto loopStart
  34. }
  35.  
  36. IfWinExist Tie ahk_class Shell_Dialog
  37. {
  38. WinActivate, Tie ahk_class Shell_Dialog
  39. MouseMove, 621, 140
  40. MouseClick, left
  41. goto loopStart
  42. }
  43.  
  44. WinActivate, Tic Tac Toe ahk_class ApplicationFrameWindow
  45.  
  46. ;check for turn
  47. PixelGetColor, OutputVar, 583, 861
  48. PixelSearch, OutputVarX, OutputVarY, 583, 861, 583, 861, OutputVar
  49. if ErrorLevel = 1
  50. {
  51. goto loopStart2
  52. }
  53.  
  54. ;search for oh's
  55. ImageSearch, X, Y, 250, 200, 350, 380, testCards\tictactoe\oh.png
  56. if ErrorLevel = 0
  57. {
  58. square1 = 1
  59. }
  60. ImageSearch, X, Y, 450, 200, 550, 380, testCards\tictactoe\oh.png
  61. if ErrorLevel = 0
  62. {
  63. square2 = 1
  64. }
  65. ImageSearch, X, Y, 650, 200, 750, 380, testCards\tictactoe\oh.png
  66. if ErrorLevel = 0
  67. {
  68. square3 = 1
  69. }
  70. ImageSearch, X, Y, 250, 400, 350, 580, testCards\tictactoe\oh.png
  71. if ErrorLevel = 0
  72. {
  73. square4 = 1
  74. }
  75. ImageSearch, X, Y, 450, 400, 550, 580, testCards\tictactoe\oh.png
  76. if ErrorLevel = 0
  77. {
  78. square5 = 1
  79. }
  80. ImageSearch, X, Y, 650, 400, 750, 580, testCards\tictactoe\oh.png
  81. if ErrorLevel = 0
  82. {
  83. square6 = 1
  84. }
  85. ImageSearch, X, Y, 250, 600, 350, 780, testCards\tictactoe\oh.png
  86. if ErrorLevel = 0
  87. {
  88. square7 = 1
  89. }
  90. ImageSearch, X, Y, 450, 600, 550, 780, testCards\tictactoe\oh.png
  91. if ErrorLevel = 0
  92. {
  93. square8 = 1
  94. }
  95. ImageSearch, X, Y, 650, 600, 750, 780, testCards\tictactoe\oh.png
  96. if ErrorLevel = 0
  97. {
  98. square9 = 1
  99. }
  100.  
  101. ;Search for x's
  102.  
  103. ImageSearch, X, Y, 180, 240, 320, 350, testCards\tictactoe\xs.png
  104. if ErrorLevel = 0
  105. {
  106. square1 = 2
  107. }
  108. ImageSearch, X, Y, 380, 240, 520, 350, testCards\tictactoe\xs.png
  109. if ErrorLevel = 0
  110. {
  111. square2 = 2
  112. }
  113. ImageSearch, X, Y, 580, 240, 720, 350, testCards\tictactoe\xs.png
  114. if ErrorLevel = 0
  115. {
  116. square3 = 2
  117. }
  118. ImageSearch, X, Y, 180, 440, 320, 550, testCards\tictactoe\xs.png
  119. if ErrorLevel = 0
  120. {
  121. square4 = 2
  122. }
  123. ImageSearch, X, Y, 380, 440, 520, 550, testCards\tictactoe\xs.png
  124. if ErrorLevel = 0
  125. {
  126. square5 = 2
  127. }
  128. ImageSearch, X, Y, 580, 440, 720, 550, testCards\tictactoe\xs.png
  129. if ErrorLevel = 0
  130. {
  131. square6 = 2
  132. }
  133. ImageSearch, X, Y, 180, 640, 320, 750, testCards\tictactoe\xs.png
  134. if ErrorLevel = 0
  135. {
  136. square7 = 2
  137. }
  138. ImageSearch, X, Y, 380, 640, 520, 750, testCards\tictactoe\xs.png
  139. if ErrorLevel = 0
  140. {
  141. square8 = 2
  142. }
  143. ImageSearch, X, Y, 580, 640, 720, 750, testCards\tictactoe\xs.png
  144. if ErrorLevel = 0
  145. {
  146. square9 = 2
  147. }
  148.  
  149. ;MsgBox, Square1 %square1% Square2 %square2% Square3 %square3% Square4 %square4% Square5 %square5% Square6 %square6% Square7 %square7% Square8 %square8% Square9 %square9%
  150.  
  151. ;check for winning moves
  152. if (square1 == 2)
  153. {
  154. if ((square2 == 2) and (square3 == 0))
  155. {
  156.  
  157. MouseMove, 653, 277
  158. MouseClick, Left
  159. goto loopStart
  160. }
  161. if ((square3 == 2) and (square2 == 0))
  162. {
  163. MouseMove, 453, 277
  164. MouseClick, Left
  165. goto loopStart
  166. }
  167.  
  168. if ((square4 == 2) and (square7 == 0))
  169. {
  170.  
  171. MouseMove, 253, 677
  172. MouseClick, Left
  173. goto loopStart
  174. }
  175. if ((square5 == 2) and (square9 == 0))
  176. {
  177.  
  178. MouseMove, 653, 677
  179. MouseClick, Left
  180. goto loopStart
  181. }
  182. if ((square7 == 2) and (square4 == 0))
  183. {
  184.  
  185. MouseMove, 253, 477
  186. MouseClick, Left
  187. goto loopStart
  188.  
  189. }
  190. if ((square9 == 2) and (square5 == 0))
  191. {
  192. MouseMove, 453, 477
  193. MouseClick, Left
  194. goto loopStart
  195. }
  196. }
  197.  
  198. if (square2 == 2)
  199. {
  200. if ((square3 == 2) and (square1 == 0))
  201. {
  202. MouseMove, 253, 277
  203. MouseClick, Left
  204. goto loopStart
  205. }
  206. if ((square5 == 2) and (square8 == 0))
  207. {
  208. MouseMove, 453, 677
  209. MouseClick, Left
  210. goto loopStart
  211. }
  212.  
  213. if ((square8 == 2) and (square5 == 0))
  214. {
  215. MouseMove, 453, 477
  216. MouseClick, Left
  217. goto loopStart
  218. }
  219. }
  220.  
  221. if (square3 == 2)
  222. {
  223. if ((square5 == 2) and (square7 == 0))
  224. {
  225. MouseMove, 253, 677
  226. MouseClick, Left
  227. goto loopStart
  228. }
  229. if ((square6 == 2) and (square9 == 0))
  230. {
  231. MouseMove, 653, 677
  232. MouseClick, Left
  233. goto loopStart
  234. }
  235.  
  236. if ((square9 == 2) and (square6 == 0))
  237. {
  238. MouseMove, 453, 477
  239. MouseClick, Left
  240. goto loopStart
  241. }
  242. }
  243.  
  244. if (square4 == 2)
  245. {
  246. if ((square5 == 2) and (square6 == 0))
  247. {
  248. MouseMove, 653, 477
  249. MouseClick, Left
  250. goto loopStart
  251. }
  252. if ((square6 == 2) and (square5 == 0))
  253. {
  254. MouseMove, 453, 477
  255. MouseClick, Left
  256. goto loopStart
  257. }
  258. if ((square7 == 2) and (square1 == 0))
  259. {
  260. MouseMove, 253, 277
  261. MouseClick, Left
  262. goto loopStart
  263. }
  264. }
  265.  
  266. if (square5 == 2)
  267. {
  268. if ((square6 == 2) and (square4 == 0))
  269. {
  270. MouseMove, 253, 477
  271. MouseClick, Left
  272. goto loopStart
  273. }
  274. if ((square7 == 2) and (square3 == 0))
  275. {
  276. MouseMove, 653, 277
  277. MouseClick, Left
  278. goto loopStart
  279. }
  280. if ((square8 == 2) and (square2 == 0))
  281. {
  282. MouseMove, 453, 277
  283. MouseClick, Left
  284. goto loopStart
  285. }
  286. if ((square9 == 2) and (square2 == 0))
  287. {
  288. MouseMove, 453, 277
  289. MouseClick, Left
  290. goto loopStart
  291. }
  292. }
  293.  
  294.  
  295. if (square6 == 2)
  296. {
  297. if ((square9 == 2) and (square3 == 0))
  298. {
  299. MouseMove, 653, 277
  300. MouseClick, Left
  301. goto loopStart
  302. }
  303. }
  304.  
  305.  
  306. if (square7 == 2)
  307. {
  308. if ((square8 == 2) and (square9 == 0))
  309. {
  310. MouseMove, 653, 677
  311. MouseClick, Left
  312. goto loopStart
  313. }
  314. if ((square9 == 2) and (square8 == 0))
  315. {
  316. MouseMove, 453, 477
  317. MouseClick, Left
  318. goto loopStart
  319. }
  320. }
  321.  
  322. if (square8 == 2)
  323. {
  324. if ((square9 == 2) and (square7 == 0))
  325. {
  326. MouseMove, 253, 677
  327. MouseClick, Left
  328. goto loopStart
  329. }
  330. }
  331.  
  332. ;Check to block opponents win
  333. if (square1 == 1)
  334. {
  335. if ((square2 == 1) and (square3 == 0))
  336. {
  337.  
  338. MouseMove, 653, 277
  339. MouseClick, Left
  340. goto loopStart
  341.  
  342. }
  343. if ((square3 == 1) and (square2 == 0))
  344. {
  345.  
  346. MouseMove, 453, 277
  347. MouseClick, Left
  348. goto loopStart
  349. }
  350.  
  351. if ((square4 == 1) and (square7 == 0))
  352. {
  353.  
  354. MouseMove, 253, 677
  355. MouseClick, Left
  356. goto loopStart
  357. }
  358. if ((square5 == 1) and (square9 == 0))
  359. {
  360.  
  361. MouseMove, 653, 677
  362. MouseClick, Left
  363. goto loopStart
  364. }
  365. if ((square7 == 1) and (square4 == 0))
  366. {
  367.  
  368. MouseMove, 253, 477
  369. MouseClick, Left
  370. goto loopStart
  371. }
  372. if ((square9 == 1) and (square5 == 0))
  373. {
  374. MouseMove, 453, 477
  375. MouseClick, Left
  376. goto loopStart
  377. }
  378. }
  379.  
  380. if (square2 == 1)
  381. {
  382. if ((square3 == 1) and (square1 == 0))
  383. {
  384. MouseMove, 253, 277
  385. MouseClick, Left
  386. goto loopStart
  387. }
  388. if ((square5 == 1) and (square8 == 0))
  389. {
  390. MouseMove, 453, 677
  391. MouseClick,
  392. goto loopStart
  393. }
  394.  
  395. if ((square8 == 1) and (square5 == 0))
  396. {
  397.  
  398. MouseMove, 453, 477
  399. MouseClick, Left
  400. goto loopStart
  401. }
  402. }
  403.  
  404. if (square3 == 1)
  405. {
  406. if ((square5 == 1) and (square7 == 0))
  407. {
  408. MouseMove, 253, 677
  409. MouseClick, Left
  410. goto loopStart
  411. }
  412. if ((square6 == 1) and (square9 == 0))
  413. {
  414. MouseMove, 653, 677
  415. MouseClick, Left
  416. goto loopStart
  417. }
  418.  
  419. if ((square9 == 1) and (square6 == 0))
  420. {
  421. MouseMove, 653, 477
  422. MouseClick, Left
  423. goto loopStart
  424. }
  425. }
  426.  
  427. if (square4 == 1)
  428. {
  429. if ((square5 == 1) and (square6 == 0))
  430. {
  431. MouseMove, 653, 477
  432. MouseClick, Left
  433. goto loopStart
  434. }
  435. if ((square6 == 1) and (square5 == 0))
  436. {
  437. MouseMove, 453, 477
  438. MouseClick, Left
  439. goto loopStart
  440. }
  441. if ((square7 == 1) and (square1 == 0))
  442. {
  443. MouseMove, 253, 277
  444. MouseClick, Left
  445. goto loopStart
  446. }
  447. }
  448. if (square5 == 1)
  449. {
  450. if ((square6 == 1) and (square4 == 0))
  451. {
  452. MouseMove, 253, 477
  453. MouseClick, Left
  454. goto loopStart
  455. }
  456. if ((square7 == 1) and (square3 == 0))
  457. {
  458. MouseMove, 653, 277
  459. MouseClick, Left
  460. goto loopStart
  461. }
  462. if ((square8 == 1) and (square2 == 0))
  463. {
  464. MouseMove, 453, 277
  465. MouseClick, Left
  466. goto loopStart
  467. }
  468. if ((square9 == 1) and (square2 == 0))
  469. {
  470. MouseMove, 453, 277
  471. MouseClick, Left
  472. goto loopStart
  473. }
  474. }
  475. if (square6 == 1)
  476. {
  477. if ((square9 == 1) and (square3 == 0))
  478. {
  479. MouseMove, 653, 277
  480. MouseClick, Left
  481. goto loopStart
  482. }
  483. }
  484.  
  485.  
  486. if (square7 == 1)
  487. {
  488. if ((square8 == 1) and (square9 == 0))
  489. {
  490. MouseMove, 653, 677
  491. MouseClick, Left
  492. goto loopStart
  493. }
  494. if ((square9 == 1) and (square8 == 0))
  495. {
  496. MouseMove, 453, 677
  497. MouseClick, Left
  498. goto loopStart
  499. }
  500. }
  501.  
  502. if (square8 == 1)
  503. {
  504. if ((square9 == 1) and (square7 == 0))
  505. {
  506. MouseMove, 253, 677
  507. MouseClick, Left
  508. goto loopStart
  509. }
  510. }
  511.  
  512. ;take center
  513.  
  514. if (square5 == 0)
  515. {
  516. MouseMove, 453, 477
  517. MouseClick, Left
  518. goto loopStart
  519. }
  520.  
  521. ;take corner
  522.  
  523. if (square1 == 0)
  524. {
  525. MouseMove, 253, 277
  526. MouseClick, Left
  527. goto loopStart
  528. }
  529. if (square3 == 0)
  530. {
  531. MouseMove, 653, 277
  532. MouseClick, Left
  533. goto loopStart
  534. }
  535. if (square7 == 0)
  536. {
  537. MouseMove, 253, 677
  538. MouseClick, Left
  539. goto loopStart
  540. }
  541. if (square9 == 0)
  542. {
  543. MouseMove, 653, 677
  544. MouseClick, Left
  545. goto loopStart
  546. }
  547.  
  548. ;else take middle side squares
  549.  
  550. if (square2 == 0)
  551. {
  552. MouseMove, 453, 277
  553. MouseClick, Left
  554. goto loopStart
  555. }
  556. if (square4 == 0)
  557. {
  558. MouseMove, 253, 477
  559. MouseClick, Left
  560. goto loopStart
  561. }
  562. if (square6 == 0)
  563. {
  564. MouseMove, 653, 477
  565. MouseClick, Left
  566. goto loopStart
  567. }
  568. if (square8 == 0)
  569. {
  570. MouseMove, 453, 677
  571. MouseClick, Left
  572. goto loopStart
  573. }
  574. }
  575. x::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment