Driving a Windows GUI program from a script

前端 未结 6 905
滥情空心
滥情空心 2020-12-13 04:59

I have to use a Windows simulation package to perform a repetitive task with slightly different options each time.

Since I hate repetitive clicking, on grounds of b

6条回答
  •  天命终不由人
    2020-12-13 05:53

    You can use PyAutoGUI library for Python which works on Windows, macOS, and Linux.

    Must allow time delays between actions.

    Example to type with quarter-second pause in between each key:

    import pyautogui
    pyautogui.typewrite('Hello world!', interval=0.25)
    

    Here is the example to set up a 2.5-second pause after each PyAutoGUI call:

    pyautogui.PAUSE = 2.5
    

    Must allow composition of complex keyboard input.

    Checkout keyboard control functions where you can use pyautogui.typewrite to type something out. You can pass variables to allow a complex keyboard input.

    Event detection to trigger actions.

    You can use locate functions to visually find something on the screen and make the condition based on that within a simple loop.

    Solution must be free for commercial use.

    It is licensed under the BSD which allows commercial use.


    See also:

    • Which is the easiest way to simulate keyboard and mouse on Python?
    • Python GUI automation library for simulating user interaction in apps.

提交回复
热议问题