Sign in to follow this  
Followers 0
ErinC

Losing Focus

12 posts in this topic

Hi there,

Hopefully someone can help me with this AutoIt problem. I have created an .exe to run through a login script.

The script calls the program install.exe as the user ScriptAdmin on the domain DG from the shared inst folder on the pc called tools

The script looks like this;

Run,runas /user:DG\\ScriptAdmin "\\\\tools\inst\install.exe"

Send,pass123

Send,{ENTER}

My problem is that on some PCs, the script is losing the window focus and the pass123 text is being passed to the app that has focus, and not the login script.

Can anyone think of a workaround ? Or a better way of installing this install.exe file with Admin rights ? (Our domain users don't have admin rights, and aren't getting them!)

:whistle:

Share this post


Link to post
Share on other sites



You can find out the title of the window that is opened by program install and than activate it before typing the password.

It's probably also better to wait a bit for the install program to startup.

Run,runas /user:DG\\ScriptAdmin "\\\\tools\inst\install.exe"
winwait, Title, Text
winactivate,Title,Text
Send,pass123
Send,{ENTER}

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try using the ControlSend command instead..

Example from help-file..

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")

EDIT : Oooh... AutoIt v2.. :whistle:

Edited by Helge

Share this post


Link to post
Share on other sites

Yeah, seems like I'm also losing focus :whistle:

Share this post


Link to post
Share on other sites

thank you Helge and JdeB for your replies :whistle:

Helge, could you please expand upon your suggestion by providing an example ?

and JdeB, how would I ascertain the Title of the window exactly ? Would the title be "RunAs" ? since this is the process being called ?

Share this post


Link to post
Share on other sites

Helge, could you please expand upon your suggestion by providing an example ?

Sorry... I wasn't thinking when I posted that, as you are using

AutoIt v2, and I was referring to a AutoIt v3 command... :whistle:

Share this post


Link to post
Share on other sites

ah, no probs ! Do you think it will be better to use V3 then ?

JdeB's method using the winwait command looks like it may work, but I don't understand what the text name is.

Share this post


Link to post
Share on other sites

Yeah, AutoIt v3 has a lot better functions then AutoIt v2...

BUT what you want to do, is very possible in AutoIt v2, and you don't

have to change to AutoIt v3 just because of this.. :whistle:

And what JdeB meant with text, is the text that is in the window..

A good example for this is notepad, where the title is "Untitled - Notepad",

and the text is the inputted text in the edit-area..

PS !

You don't need to give the text to Winwait....

It's probably enough to just give the title and just forget about the text..

Share this post


Link to post
Share on other sites

Thanks again for your help, I've managed to create something that seems to work fine, though I need to test it more before I implement it on the Domain.

I used the following code;

Run,runas /env /user:DG\\ScriptAdmin "\\\\tools\\inst\\install.exe"

WinGetActiveTitle, myvar

sleep, 3000

winactivate, %myvar%

Send,pass123

Send,{ENTER}

End:

Exit

I'm not sure that I needed the winwait command, so used the sleep command instead ... This seems to work good ! :whistle:

Share this post


Link to post
Share on other sites

It's possible that you don't need the WinWait, but it makes your

script more secure..

What I mean is for example if your computer one day is very slow,

it can make the window to not appear before after the script have

sent the keys.. But then it's too late ! :whistle:

Hope I didn't confused you now.. B)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I follow your thinking Helge, but I think I'll leave it as it is. If it causes any problems then I will look into adding the winwait command later.

edit: Stroke the above. I've added winwait and all is working A-OK :whistle:

thank you very much for your help !

Erin Carter,

Dumfries, Scotland.

Edited by ErinC

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0