Jump to content

Recommended Posts

Posted

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")

Send("{TAB}{ENTER}")

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

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

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

EndIf

Func _WinWaitActivate($title, $text)

WinWait($title, $text)

if not WinActive($title, $text) Then

WinActivate($title, $text)

EndIf

WinWaitActive($title, $text)

EndFunc

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

***** WINDOW INFORMATION ******

>>>> Window <<<<

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

Class: #32770

Position: 100, 100

Size: 531, 156

Style: 0x94C800C4

ExStyle: 0x00010101

Handle: 0x00AD01E0

>>>> Control <<<<

Class:

Instance:

ClassnameNN:

Name:

Advanced (Class):

ID:

Text:

Position:

Size:

ControlClick Coords:

Style:

ExStyle:

Handle:

>>>> Mouse <<<<

Position: 246, 115

Cursor ID: 0

Color: 0x7B99E1

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

&OK

&Cancel

&Browse...

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 <<<<

****** END OF INFORMATION *****

Any feedback is greatly appreciated

jaysonp

Posted (edited)

Try this

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

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

EDIT:

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
Posted

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")

EndIf

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

Again, thanks for the feedback :>

Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...