Sign in to follow this  
Followers 0
Program

controls

2 posts in this topic

Hi im a newbie to autoit scripting.

Could someone explain to me about controls. Like what is the edit1 control for notepad??? If you were to use the ControlClick command what would you use this for....? how would you determine a control to send a mouse click to?

What are these controls in terms of??

How can controls be useful and how do you find what the controls are for various applications?

Share this post


Link to post
Share on other sites



Most elements in a window have a control, which is a bit like a "name" for that element in a window. In the case of a notepad window, the main control is called "Edit1". You can find out the name of a control by using the AutoIt spy program, called "AU3_Spy.exe" in your install directory. Just select a window, point to a part of that window, and as you move around, you'll notice different control names listed under "Last Control Under Mouse". You use those control names with the Control_____ Commands.

The advantage to using control functions over the traditional ones is that you can send to windows that are minimized, or even hidden. I have created an example below that uses notepad to send some text. Although I've only used ControlSend, you can also ControlClick to click on a control to give that button or control a click. Again, this is all done without the window needing to be active.

Run("notepad.exe");start notepad
$exists = WinWaitActive("Untitled - Notepad", "", 10);wait up to 10 secs for it
If NOT $exists Then;if $exists is 0, then it failed to appear
  MsgBox(0, "Error", "Notepad failed to appear. Now quitting");tell the user
  Exit;quit, since we don't have a copy of notepad
EndIf

WinSetTitle("Untitled - Notepad", "", "Example");change the title
ControlSend("Example", "", "Edit1", "This is some text that has been sent " &_
 "with ControlSend(){ENTER 2}")
Sleep(2000)
ControlSend("Example", "", "Edit1", "Now we will sent text to the window " &_
 "while it is minimized{ENTER 2}")
Sleep(2000)
WinSetState("Example", "", @SW_MINIMIZE);minimize the window
ControlSend("Example", "", "Edit1", "This text was sent to the window while " &_
 "it was minimized and no longer active{ENTER 2}")
WinSetState("Example", "", @SW_RESTORE)

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0