AutoIt notepad script

In this post I am going to explain that how to create auto it script. I have created a AutoIT script for notepad where I open notepad, change font property, type some text and save in machine.

 ;run application
 Run("Notepad.exe")

 ;wait Notepad to be opened
 WinWaitActive("Untitled - Notepad", "", 15)

 ;open font window
 send("!o")
 send("F")

 ;wait font window
 WinWaitActive("Font", "", 15)

 ;change font, font type, size
 ControlCommand("Font", "", "ComboBox1", "SelectString", "Lucida Fax")
 ControlCommand("Font", "", "ComboBox2", "SelectString", 'Italic')
 ControlCommand("Font", "", "ComboBox3", "SelectString", '11')

 ;click on ok button
 Send("{TAB 2}")
 ControlClick("Font", "", "[CLASS:Button; INSTANCE:5]")

 ;write some text on note pad
 ControlSend("Untitled - Notepad", "", "Edit1", "This is firs line")
 Send("{Enter 2}")
 ControlSend("Untitled - Notepad", "", "Edit1", "This is second line")

 ;click control s to save file
 Send("^s")
 WinWaitActive("Save As")

 ;enter file name and path
 Sleep(1000)
 Send("C:\Test.txt")
 Sleep(1000)
 Send("!s")
 Sleep(3000);

 ;close file
 send("!fx")


 Below is description of used AutoIt commands

run(): command open application.
WinWaitActive(): command Wait for windows.
Send(): command send keyword action.
ControlCommand(); command control auto it commands.
!o : press alt + o button
^s : press control + s button
Sleep() :command seep the execution thread

1 comment:

  1. This very nice post for autoIt, its really very helpful and clear some my doubts. I am facing some issue while getting Id of menu bar I got combined id of all menus while I want to click on a particular menu option. How I do this........

    ReplyDelete

Leave your comments, queries, suggestion I will try to provide solution