Advertisement
yclee126

Olive's Art-Venture keyboard control

Mar 6th, 2022
1,249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.25 KB | None | 0 0
  1. # Keyboard macro for the Olive's Art-Venture game
  2. # https://www.newgrounds.com/portal/view/830421
  3.  
  4. import keyboard
  5. import pyautogui as pg
  6. import time
  7.  
  8. pg.PAUSE = 0.0000001
  9.  
  10. # circle, triangle, square, diamond
  11. coords = [[(1292, 627), (1289, 610), (1294, 598), (1305, 585), (1314, 572), (1320, 562), (1331, 550), (1346, 542), (1364, 535), (1383, 533), (1407, 533), (1427, 538), (1448, 549), (1464, 565),
  12. (1479, 582), (1484, 594), (1487, 602), (1489, 616), (1490, 628), (1490, 638), (1488, 651), (1483, 667), (1475, 678), (1466, 694), (1457, 705), (1443, 715), (1428, 719), (1414, 722), (1399, 723), (1381, 724), (1364, 721), (1349, 710), (1335, 701), (1323, 692), (1312, 682), (1300, 669), (1295, 658), (1292, 645), (1291, 636), (1291, 635)], [(1389, 514), (1387, 523), (1376, 542), (1367, 557), (1357, 570), (1346, 586), (1337, 602), (1330, 614), (1325, 622), (1321, 636), (1316, 651), (1309, 673), (1303, 688), (1296, 703), (1288, 723), (1281, 738), (1274, 750), (1272, 754), (1292, 751), (1307, 748), (1324, 746), (1344, 746), (1371, 747), (1381, 747), (1397, 748), (1418, 749), (1435, 750), (1458, 750), (1482, 750), (1499, 750), (1515, 750), (1519, 750), (1504, 734), (1493, 722), (1487, 712), (1480, 699), (1471, 686), (1463, 663), (1460, 650), (1454, 637), (1446, 622), (1437, 603), (1428, 585), (1420, 571), (1414, 559), (1404, 543), (1394, 527), (1388, 515)], [(1267, 490), (1266, 519), (1266, 540), (1266, 558), (1265, 582), (1264, 605), (1262, 620), (1262, 638), (1262, 671), (1262, 700), (1260, 738), (1265, 753), (1281, 756), (1316, 757), (1346, 757), (1370, 757), (1399, 756), (1425, 754), (1457, 754), (1485, 754), (1514, 750), (1520, 744), (1519, 703), (1519, 677), (1519, 651), (1516, 624), (1514, 591), (1518, 561), (1519, 532), (1518, 500), (1517, 489), (1471, 489), (1430, 489), (1397, 492), (1363, 492), (1337, 492), (1312, 492), (1282, 492), (1269, 492)], [(1393, 472), (1383, 486), (1367, 505), (1347, 524), (1321, 553), (1301, 576), (1287, 590), (1271, 609), (1259, 622), (1257, 625), (1265, 630), (1277, 639), (1292, 659), (1308, 681), (1322, 698), (1342, 718), (1358, 738), (1376, 760), (1384, 771), (1393, 766), (1409, 756), (1421, 749), (1432, 740), (1450, 724), (1467, 705), (1476, 693), (1484, 680), (1492, 669), (1505, 649), (1520, 634), (1532, 623), (1527, 619), (1498, 602), (1481, 580), (1468, 560), (1456, 542), (1437, 518), (1421, 500), (1406, 485), (1396, 472), (1389, 466)]]
  13.  
  14. new_coords = [[]]
  15. num = 0
  16.  
  17. def spell(index):
  18.     global num
  19.     if index >= 4:
  20.         if index == 4:
  21.             coord = tuple(pg.position())
  22.             new_coords[num].append(coord)
  23.         elif index == 5:
  24.             new_coords.append([])
  25.             num += 1
  26.         elif index == 6:
  27.             print(new_coords)
  28.         return
  29.  
  30.     init_pos = coords[index][0]
  31.     pg.moveTo(*init_pos)
  32.     pg.mouseDown()
  33.  
  34.     for coord in coords[index]:
  35.         pg.moveTo(*coord)
  36.    
  37.     pg.mouseUp()
  38.  
  39. key_list = ('z', 'x', 'c', 'v', 'i', 'o', 'p')
  40. prev_key = None
  41. pressed = False
  42.  
  43. while True:
  44.     for i, key in enumerate(key_list):
  45.         if keyboard.is_pressed(key):
  46.             if prev_key != key:
  47.                 spell(i)
  48.             prev_key = key
  49.             pressed = True
  50.    
  51.     if not pressed:
  52.         prev_key = None
  53.     pressed = False
  54.     time.sleep(0.001)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement