728x90
๋ฐ์ํ
๊ธฐ๋ณธ PyAutoGUI๋ ๊ฐ์ ํค(VK)์ mouse_event() ๋ฐ keybd_event() win32 ํจ์๋ฅผ ์ฌ์ฉํ๊ณ ์๋๋ฐ ์ด๋ ์ผ๋ถ ์์ฉ ํ๋ก๊ทธ๋จ๋ค, ๋น๋์ค ๊ฒ์์ด๋ DirectX์ ์ง์ํ์ง ์์ ์ ๋๋ก ์๋ํ์ง ์์ ์ ์๋ค. ๊ทธ๋์ PyDirectInput ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ DirectInput ์ค์บ ์ฝ๋์ SendInput() win32 ๊ฐ์ ์ต์ ๋ฐฉ์์ ์ฌ์ฉํด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๋ค.
PyPi - PyDirectInput
https://pypi.org/project/PyDirectInput/
PyDirectInput
Python mouse and keyboard input automation for Windows using Direct Input.
pypi.org
์ฝ๋ ์์
>>> import pyautogui
>>> import pydirectinput
>>> pydirectinput.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.
>>> pydirectinput.click() # Click the mouse at its current location.
>>> pydirectinput.click(200, 220) # Click the mouse at the x, y coordinates 200, 220.
>>> pydirectinput.move(None, 10) # Move mouse 10 pixels down, that is, move the mouse relative to its current position.
>>> pydirectinput.doubleClick() # Double click the mouse at the
>>> pydirectinput.press('esc') # Simulate pressing the Escape key.
>>> pydirectinput.keyDown('shift')
>>> pydirectinput.keyUp('shift')
๋์ ์ด๋งฅ์ค ์๋ ๋ ๋ ๋งคํฌ๋ก
import pyautogui
import pydirectinput
import time
ready_delay = 3
while True:
time.sleep(0.5)
result1 = pyautogui.locateCenterOnScreen('ready.png')
print("๋ ๋ ์ํ ์๋.")
if result1 != None:
for i in range(1, ready_delay+1):
print( "๋ ๋ ๋๊ธฐ " + str(i) + "์ด ๊ฒฝ๊ณผ " )
result2 = pyautogui.locateCenterOnScreen('ready.png')
if result2 == None:
break
if i >= (ready_delay) and result2 != None:
pydirectinput.press('f5')
print("F5 ๋๋ฆ.")
for j in range(1, 300+1):
time.sleep(1)
print( "๋ ๋ ํ " + str(j) + "์ด ๊ฒฝ๊ณผ " )
result3 = pyautogui.locateCenterOnScreen('ready.png')
if result3 == None:
print('๋ ๋ ํด์ ๋จ.')
break
time.sleep(1)
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ด์ฉํด์ pyautogui๊ฐ ์๋ํ์ง ์๋ ๋์ ์ด๋งฅ์ค์ ์๋ ๋ ๋๋ฅผ ํ๋ ๋งคํฌ๋ก๋ฅผ ์์ฑํด ๋ณด์๋ค.
728x90
๋ฐ์ํ
'๐จ๐ผโ๐ป๊ฐ๋ฐ > ํ์ด์ฌ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ์ด์ฌ - ์คํฌ๋ฆฝํธ ํ์ผ ์คํ ๋์ค ์ธํฐ๋ํฐ๋ธ ๋ชจ๋๋ก ์ ํํ๊ธฐ (0) | 2023.07.29 |
---|---|
ํ์ด์ฌ - ๋ก๋ฉ๋ฐ(Progress Bar) ๊ตฌํ ๋ชจ๋(tqdm) (0) | 2023.07.17 |
ํ์ด์ฌ - ๋ฆฌ๋ ์ค์์ GPT ๋ช ๋ น์ด ์ฌ์ฉํ๊ธฐ (0) | 2023.05.22 |
ํ์ด์ฌ - ๋ ์ง์คํธ๋ฆฌ ์กฐ์(winreg) (0) | 2023.05.05 |
ํ์ด์ฌ - pyinstaller ๊ด๋ฆฌ์ ๊ถํ์ผ๋ก ์คํ ํ๊ธฐ (0) | 2023.05.05 |