-1
これは、自動的にチャットウィンドウに貼り付けることができますし、マウスでクリックすると小さなスクリプトを送信する予定です。pythonスクリプトを使用して終了する方法pyhookショートカットキーを使用しますか?
ただし、このスクリプトは実行後に停止するまで実行できません。
私の質問は、F12などのショートカットキーを設定してスクリプトを停止する方法です。次のように
スクリプトコードは次のとおりです。
# _*_ coding:UTF-8 _*_
import win32api
import win32con
import win32gui
from ctypes import *
import time
import msvcrt
import threading
from time import sleep
stop = 2
def mouse_click(x=None,y=None):
if not x is None and not y is None:
mouse_move(x,y)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_move(x,y):
windll.user32.SetCursorPos(x, y)
def baozou():
global stop
for event in range(1,50):
mouse_click(1150,665)
win32api.keybd_event(17,0,0,0)
win32api.keybd_event(86,0,0,0)
win32api.keybd_event(86,0,win32con.KEYEVENTF_KEYUP,0)
win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0)
mouse_click(1272,669)
time.sleep(0.1)
if stop == 1:
sys.exit()
def Break():
global stop
if ord(msvcrt.getch()) == 123:
stop = 1
if __name__ == "__main__":
t = threading.Thread(target = baozou)
f = threading.Thread(target = Break)
t.start()
f.start()
私の手を与えてください!