试图执行特定的python脚本,但执行了另一个脚本

问题描述 投票:-1回答:2

我正在尝试在cmd'python whatsapp.py'中执行以下脚本(不完整)

import time
import pyautogui
import subprocess
from tkinter import * 
# gui begins
class App:
    def main():
        win = Tk()
        win.geometry("300x100")
        win.title("WhatsApp Texter")

        name = Label(win, text = "Name:")
        name.grid(row = 2, column = 2 )

        name_textb = Entry(win, bd = 5)
        name_textb.grid(row = 2, column = 4)

        msg = Label(win, text = "Message:")
        msg.grid(row = 4, column = 2 )

        msg_textb = Entry(win, bd = 5, width = "30")
        msg_textb.grid(row = 4, column = 4)

        # functions for buttons to perform
        def clear_func():
            name_textb.delete(0, 'end')
            msg_textb.delete(0, 'end')

        def send_func():
            receiver = name_textb.get()
            text = msg_textb.get()
            # print(receiver, text)
            subprocess.Popen(r"C:\Users\JasonPC\AppData\Local\WhatsApp\WhatsApp.exe")
            win.destroy()

        def exit_func():
            win.destroy()

        clear_btn = Button(win, text = "Clear", command = clear_func)
        clear_btn.grid(row = 10, column = 2)

        send_btn = Button(win, text = "Send", command = send_func)
        send_btn.grid(row = 10, column = 4)

        exit_btn = Button(win, text = "Exit", command = exit_func)
        exit_btn.grid(row = 10, column = 6)

        win.mainloop()
        # gui ends
class Texter(App): # Texter inherites App (Single Inheritance)
    def mousecontrol():
        time.sleep(10) # waits for WhatsApp to load
        pyautogui.moveTo(97, 134, duration = 0.25) # moves cursor to search bar
        pyautogui.click(97, 134) # clicks on search bar
        keyboardcontrol()
    def keyboardcontrol():
        pass

if __name__ == '__main__':
    App.main()

但是当我在cmd中运行此脚本时,会弹出另一个cmd窗口并运行名为'guiV2.py'的脚本

我不知道是什么问题。enter image description here

这是两个cmd窗口,它们在我运行whatsapp.py脚本时打开。我不确定是否与“ pyautogui软件包”有关。

需要帮助,欢呼声

python automation pyautogui
2个回答
0
投票
如果您看到轨迹的第一行,它是从模块pyautogui中调用的

0
投票
我发现了错误。与脚本相同的目录中有cmd.py,因此pyautogui调用该cmd.py而不是其依赖项模块,该模块也称为cmd.py
© www.soinside.com 2019 - 2024. All rights reserved.