Jump to content
Sign in to follow this  

Activating Window and setting text on the text box

Recommended Posts

Good day:

I'm a newbie on AutoIt and I don't know if my post has been answered before. If in case it was, my apologies. (I was not able to see it inside the forum)

I assume that my question would be basic. What I wanted to do are 2 things:

1. Activate the window in order to

2. Set the text in the text box

My problem is I can't activate the window where the text\edit box is found.

Follow-up problem would be how to place text on the textbox (Will I use ControlSend).

Below are my code and the window information about the executable I want to run automatically:

*** CODE *** :

Run('"C:\Program Files\Sandboxie\Start.exe" /box:__ask__ run_dialog')

_WinWaitActivate("Run Sandboxed", "Select the sandbox i")


_WinWaitActivate("[#] Run Sandboxed - DefaultBox [#]", "&OK")

if WinWait("[#] Run Sandboxed - DefaultBox [#]", "&OK", 10) Then

ControlSend($title, "", "Edit1", "c:\WINDOWS\system32\calc.exe")


Func _WinWaitActivate($title, $text)

WinWait($title, $text)

if not WinActive($title, $text) Then

WinActivate($title, $text)


WinWaitActive($title, $text)


****** END OF CODE *******


>>>> Window <<<<

Title: [#] Run Sandboxed - DefaultBox [#]

Class: #32770

Position: 100, 100

Size: 531, 156

Style: 0x94C800C4

ExStyle: 0x00010101

Handle: 0x00AD01E0

>>>> Control <<<<





Advanced (Class):





ControlClick Coords:




>>>> Mouse <<<<

Position: 246, 115

Cursor ID: 0

Color: 0x7B99E1

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<




Type the name of a program or folder and Sandboxie will open it for you.

Type . (the point character) to explore your desktop with Sandboxie.

>>>> Hidden Text <<<<


Any feedback is greatly appreciated


Share this post

Link to post
Share on other sites

Try this

ControlSend("Run Sandboxed", "", "", "{TAB}{ENTER}")

When controlID="" then it will send it to active control inside window


in your code

ControlSend($title, "", "Edit1", "c:\WINDOWS\system32\calc.exe")

there is not defined variable $title

so try this

ControlSend("[#] Run Sandboxed - DefaultBox [#]", "", "Edit1", "c:\WINDOWS\system32\calc.exe")

Edited by Zedna

Share this post

Link to post
Share on other sites

Thank you very much for the reply Zedna. :unsure:

Actually I just forgot to place the hard-coded string in the $title variable.

Anyways, I tried to do what you suggested but still no luck.

What I observed is even though I am trying to reactivate the Window (code snippet below), still the Window is not focused.

if not WinWait("[#] Run Sandboxed - DefaultBox [#]", "Type the name of a", 10) Then

WinActivate("[#] Run Sandboxed - DefaultBox [#]", "Type the name of a")

ControlSend("[#] Run Sandboxed - DefaultBox [#]", "", "Edit", "c:\WINDOWS\system32\calc.exe")


In case you need window information, you may still reference the window information on my original post.

Again, thanks for the feedback :>

Share this post

Link to post
Share on other sites

Try If WinWait, instead of If Not WinWait. I might be wrong, but I'm reading you're code as saying: if the window isn't there, activate it (give it focus). You could leave it the way it is, and put a Run statement before the WinActivate, actually, you probably won't even need to give it focus, unless another program takes focus from it right away, after the Run.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...