import time
import keyboard
import pyautogui
import sys
import numpy as np
import matplotlib.pyplot as plt
welcome = "Welcome to the manual multi script (This script is still in developement please be patient.)"
print (welcome.upper())
help = "\nIf you need anyhelp please contact Frame on discord. \n"
print (help.upper())
print('You are about to bind your coords to [ANTI-FREEZE]: \n')
print('Please press [SPACE] to continue\n ')
while True:
if keyboard.is_pressed('SPACE'):
print('Press ENTER on the [ANTI-FREEZE] power to get its location')
time.sleep(1)
if keyboard.is_pressed('ENTER'):
x,y = pyautogui.position()
print("\nYour current X pos: " str(x) "," "\nYour current Y pos: " str(y))
antifX1 = x
antifY1 = y
x = antifX1
y = antifY1
time.sleep(1)
print("\n[ANTIFREEZE]Your current X and Y coord is: " '[ ' str(x) ' , ' str(y) ' ] \n')
break
if keyboard.is_pressed('N'):
print('\nNo Problem! Next Question... ')
break
print('You are about to bind your coords to [PORTAL]: \n')
print('Please press [SPACE] to continue\n ')
while True:
if keyboard.is_pressed('SPACE'):
print('Press ENTER on the PORTAL power to get its location')
time.sleep(1)
if keyboard.is_pressed('ENTER'):
x,y = pyautogui.position()
print("\nYour current X pos: " str(x) "," "\nYour current Y pos: " str(y))
portalfX1 = x
portalfY1 = y
x = portalfX1
y = portalfY1
time.sleep(1)
print("\n[PORTAL]Your current X and Y coord is: " '[ ' str(x) ' , ' str(y) ' ] \n')
break
if keyboard.is_pressed('N'):
print('\nNo Problem! Next Question... ')
break
print('You are about to bind your coords to [FREEZE]: \n')
print('Please press [SPACE] to continue\n ')
while True:
if keyboard.is_pressed('SPACE'):
print('Press ENTER on the antifreeze power to get its location')
time.sleep(1)
if keyboard.is_pressed('ENTER'):
x,y = pyautogui.position()
print("\nYour current X pos: " str(x) "," "\nYour current Y pos: " str(y))
freezefX1 = x
freezefY1 = y
x = freezefX1
y = freezefY1
time.sleep(1)
print("\n[FREEZE]Your current X and Y coord is: " '[ ' str(x) ' , ' str(y) ' ] \n')
break
if keyboard.is_pressed('N'):
print('\nNo Problem! Next Question... ')
break
notice = ('[NOTICE] an input delay on 1 means 1 drop per second\n')
print(notice.upper())
time.sleep(1)
while True:
print('Drop Delay [MAKE SURE YOU INSERT ANSWER ON THIS LINE]: ')
Apause = input()
print('[Script Complete!]')
Apause = pyautogui.PAUSE
break
a = input('\nPlease enter keybind[ANTIFREEZE]: \n')
b = input('Please enter keybind[PORTAL]: \n')
c = input('Please enter keybind[FREEZE]: \n')
while True:
pos = pyautogui.position()
afreezePOS = pyautogui.position(antifX1, antifY1)
portalPOS = pyautogui.position(portalfX1, portalfY1)
freezePOS = pyautogui.position(freezefX1, freezefY1)
if keyboard.is_pressed(a):
pyautogui.click(afreezePOS)
Apause
pyautogui.mouseDown(button='left')
Apause
pyautogui.moveTo(pos)
Apause
pyautogui.mouseUp(button='left')
Apause
print('[ANTI] was pressed. \n')
if keyboard.is_pressed(b):
pyautogui.click(portalPOS)
pyautogui.mouseDown(button='left')
Apause
pyautogui.moveTo(pos)
Apause
pyautogui.mouseUp(button='left')
Apause
print('[PORTAL] was pressed. \n')
if keyboard.is_pressed(c):
pyautogui.click(freezePOS)
Apause
pyautogui.mouseDown(button='left')
Apause
pyautogui.moveTo(pos)
Apause
pyautogui.mouseUp(button='left')
Apause
print('[FREEZE] was pressed. \n')
When I run this code inside the python IDLE program, it works fine. I've tried everything and hope seems to be lost. Is there any other way for users to input their own key bind, like what I'm trying to do here? If there is any other alternative, I would gladly go to that. When I run through the console, I get the error
Traceback (most recent call last):
File "C:\Users\ovosc\Desktop\Multiking\Realmulti.py", line 99, in <module>
if keyboard.is_pressed(a):
File "C:\Users\ovosc\AppData\Local\Programs\Python\Python37\lib\site-packages\keyboard\__init__.py", line 417, in is_pressed
steps = parse_hotkey(hotkey)
File "C:\Users\ovosc\AppData\Local\Programs\Python\Python37\lib\site-packages\keyboard\__init__.py", line 358, in parse_hotkey
steps.append(tuple(key_to_scan_codes(key) for key in keys))
File "C:\Users\ovosc\AppData\Local\Programs\Python\Python37\lib\site-packages\keyboard\__init__.py", line 358, in <genexpr>
steps.append(tuple(key_to_scan_codes(key) for key in keys))
File "C:\Users\ovosc\AppData\Local\Programs\Python\Python37\lib\site-packages\keyboard\__init__.py", line 309, in key_to_scan_codes
normalized = normalize_name(key)
File "C:\Users\ovosc\AppData\Local\Programs\Python\Python37\lib\site-packages\keyboard\_canonical_names.py", line 1239, in normalize_name
raise ValueError('Can only normalize non-empty string names. Unexpected ' repr(name))
ValueError: Can only normalize non-empty string names. Unexpected ''
I'm completely lost and don't know how to fix this. Does anyone have a clue of what the problem even means?
CodePudding user response:
Yea, I understand, but when I do that it sets the binds to this button. I'm trying to have the user input their own binds to run it.
a = input('\nPlease enter keybind[ANTIFREEZE]: \n')
I'm wanting them to input their own hotkey to run this command
if keyboard.is_pressed(a):
pyautogui.click(afreezePOS)
Apause
pyautogui.mouseDown(button='left')
Apause
pyautogui.moveTo(pos)
Apause
pyautogui.mouseUp(button='left')
Apause
print('[ANTI] was pressed. \n')
CodePudding user response:
i think the problem is that you use keybaord.is_pressed(a)
while a is a variable for an input.
#if keyboard.is_pressed(a):
if keyboard.is_pressed('a'): #it should be like this
pyautogui.click(afreezePOS)
Apause
pyautogui.mouseDown(button='left')
Apause
pyautogui.moveTo(pos)
Apause
pyautogui.mouseUp(button='left')
Apause
you should do the same for b and c