如何更新 pyautogui 中的按钮
我尝试修改文件来改进程序,直到遇到障碍。
如何更新/重新启动 pyAutoGui 中的按钮?
如果您想修复它,这是迷你代码。 还请介绍一下它是如何工作的。
我想修改这个程序,因为原来的程序是《我的世界》的骗局。我想修复它,以便我可以调整点击延迟并能够更改键绑定,因为默认值是 ALT,仅此而已。
import keyboard
import win32api, win32con
import threading
import pyautogui
import PySimpleGUI as sg
#For default key bind
key = 'alt'
def main():
#To loop everytime you want to change keybind
def keybind(key, Duping):
while True:
return key.hotkeys['\t', '\n', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(',
')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`',
'a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
'accept', 'add', 'alt', 'altleft', 'altright', 'apps', 'backspace',
'browserback', 'browserfavorites', 'browserforward', 'browserhome',
'browserrefresh', 'browsersearch', 'browserstop', 'capslock', 'clear',
'convert', 'ctrl', 'ctrlleft', 'ctrlright', 'decimal', 'del', 'delete',
'divide', 'down', 'end', 'enter', 'esc', 'escape', 'execute', 'f1', 'f10',
'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f2', 'f20',
'f21', 'f22', 'f23', 'f24', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
'final', 'fn', 'hanguel', 'hangul', 'hanja', 'help', 'home', 'insert', 'junja',
'kana', 'kanji', 'launchapp1', 'launchapp2', 'launchmail',
'launchmediaselect', 'left', 'modechange', 'multiply', 'nexttrack',
'nonconvert', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6',
'num7', 'num8', 'num9', 'numlock', 'pagedown', 'pageup', 'pause', 'pgdn',
'pgup', 'playpause', 'prevtrack', 'print', 'printscreen', 'prntscrn',
'prtsc', 'prtscr', 'return', 'right', 'scrolllock', 'select', 'separator',
'shift', 'shiftleft', 'shiftright', 'sleep', 'space', 'stop', 'subtract', 'tab',
'up', 'volumedown', 'volumemute', 'volumeup', 'win', 'winleft', 'winright', 'yen',
'command', 'option', 'optionleft', 'optionright']
#A condition which the program starts, so it needs to be left.
if event == (empty):
break
#For a hotkey and a button
layout = [sg.Text('Set Hotkey to run: '), sg.Button(key.upper())],
#Window and Event
window = sg.Window('Window', layout, size=(450, 250), font='bold')
while True:
event, values = window.read()
if event == 'key.upper()':
key = keybind(key, (empty))
I tried to modify a file to improve the program until I met a roadblock.
How do you update/restart a button in pyAutoGui?
This is the mini-code if you would like to fix it.
Please also present how it works.
I wanted to modify the program since the original is a dupe for Minecraft. I want to fix it so that I can adjust the delay for clicks and be able to change the keybind since the default is ALT and nothing more.
import keyboard
import win32api, win32con
import threading
import pyautogui
import PySimpleGUI as sg
#For default key bind
key = 'alt'
def main():
#To loop everytime you want to change keybind
def keybind(key, Duping):
while True:
return key.hotkeys['\t', '\n', '\r', ' ', '!', '"', '#', '
, '%', '&', "'", '(',
')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`',
'a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
'accept', 'add', 'alt', 'altleft', 'altright', 'apps', 'backspace',
'browserback', 'browserfavorites', 'browserforward', 'browserhome',
'browserrefresh', 'browsersearch', 'browserstop', 'capslock', 'clear',
'convert', 'ctrl', 'ctrlleft', 'ctrlright', 'decimal', 'del', 'delete',
'divide', 'down', 'end', 'enter', 'esc', 'escape', 'execute', 'f1', 'f10',
'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f2', 'f20',
'f21', 'f22', 'f23', 'f24', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
'final', 'fn', 'hanguel', 'hangul', 'hanja', 'help', 'home', 'insert', 'junja',
'kana', 'kanji', 'launchapp1', 'launchapp2', 'launchmail',
'launchmediaselect', 'left', 'modechange', 'multiply', 'nexttrack',
'nonconvert', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6',
'num7', 'num8', 'num9', 'numlock', 'pagedown', 'pageup', 'pause', 'pgdn',
'pgup', 'playpause', 'prevtrack', 'print', 'printscreen', 'prntscrn',
'prtsc', 'prtscr', 'return', 'right', 'scrolllock', 'select', 'separator',
'shift', 'shiftleft', 'shiftright', 'sleep', 'space', 'stop', 'subtract', 'tab',
'up', 'volumedown', 'volumemute', 'volumeup', 'win', 'winleft', 'winright', 'yen',
'command', 'option', 'optionleft', 'optionright']
#A condition which the program starts, so it needs to be left.
if event == (empty):
break
#For a hotkey and a button
layout = [sg.Text('Set Hotkey to run: '), sg.Button(key.upper())],
#Window and Event
window = sg.Window('Window', layout, size=(450, 250), font='bold')
while True:
event, values = window.read()
if event == 'key.upper()':
key = keybind(key, (empty))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
朋友你的代码不完整。
如果要更新按钮使用示例:
我不知道是否是这样,但如果是,它会有所帮助。
Friend your code is not complete.
If to update a button use example:
I don't know if that's it, but if it is, it helps.