在程序中输入减号

时间:2019-06-04 03:29:34

标签: user-interface python-3.x

我有一个用于自动化键盘和鼠标的脚本。 to_type = -0.2并且它仅写入0.2。我有英文键盘。它写的不带负号

pyautogui.typewrite(to_type)

您是否知道问题出在哪里?

我尝试过

pyautogui.typewrite(-0.2)

pyautogui.press('-')
pyautogui.typewrite(-0.2)

pyautogui.typewrite("-" + str(to_type))

pyautogui.typewrite(str(to_type))

谢谢

代码

import pyautogui 
import time 
for i in range(1, 3): 
    pyautogui.click(509, 679) # move to field 
    pyautogui.typewrite(['backspace', 'backspace', 'backspace', 'backspace', 'backspace', 'backspace', 'backspace', 'backspace']) 
    value = -0.5 + (i - 1) * 0.3 # computation numbers that will be write in field 
    to_type = "%f" % value 
    print(to_type) 
    #pyautogui.press('-')
    pyautogui.typewrite(to_type) # writing previous number 
    time.sleep(2) 
    pyautogui.typewrite(['enter']) # enter the input of number 
    pyautogui.PAUSE = 0.5
    pyautogui.click(169, 681) # plot
    pyautogui.PAUSE = 0.5
    pyautogui.click(330, 685) # save 
    pyautogui.click(448, 174) # file name 
    to_type = "data{}".format(i) 
    print(to_type) 
    pyautogui.typewrite(to_type) # writing name of file 
    pyautogui.click(978, 664) # save file
    pyautogui.PAUSE = 0.5

0 个答案:

没有答案