Search code examples
autoitnotepadalt-key

How to press "ALT+F4" using AutoIt


I am new in AutoIt. I have run the notepad by using the following code in AutoIt:

Run("notepad.exe")

Now I want to quit the application by using "ALT+F4". How to press "ALT+F4" with AutoIt tool?


Solution

  • You'll want to check out the documentation for AutoIt - which is pretty good.

    The one you're looking for is: https://www.autoitscript.com/autoit3/docs/functions/Send.htm

    Keep in mind that you want to make sure that the window is active or that you're targeting the window.

    With that, I recommend using this : https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm

    ControlSend() works in a similar way to Send() but it can send key strokes directly to a window/control, rather than just to the active window.