Start Notepad program and type a text in it a robust way

Share your macros, knowledge, solutions, services, ...
Post Reply
Petr
Posts: 106
Joined: Tue Oct 18, 2016 1:12 pm

Start Notepad program and type a text in it a robust way

Post by Petr » Wed Nov 23, 2016 4:00 pm

This example starts Notepad and waits until its window is open and on top receiving keyboard input before it types text in it.

Code: Select all

<#> Start of the macro
<cmds>
<#> Start Notepad
<execappex>("notepad.exe","","",0,0)

<#> Wait until Notepad is loaded
<waitfor>("WIN","OPEN","[Untitled - Notepad|Notepad|#0|#0]",15,0)

<#> Make Notepad window active
<actwin>("[Untitled - Notepad|Notepad|#0|#0]",0,0)
<#> Make sure the Notepad window is active
<if_win>("[Untitled - Notepad|Notepad|#164|#18]","ACT",0)
   <#> Send keys (text) to Notepad (active window)
   <keys>Hello Notepad!<cmds>  
<endif>

<#> End of the macro

Post Reply