ErinC Posted March 22, 2004 Posted March 22, 2004 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!)
Developers Jos Posted March 22, 2004 Developers Posted March 22, 2004 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} SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Helge Posted March 22, 2004 Posted March 22, 2004 (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.. Edited March 22, 2004 by Helge
Developers Jos Posted March 22, 2004 Developers Posted March 22, 2004 EDIT : Oooh... AutoIt v2.. How quickly we forget ...right ?... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ErinC Posted March 23, 2004 Author Posted March 23, 2004 thank you Helge and JdeB for your replies 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 ?
Helge Posted March 23, 2004 Posted March 23, 2004 Helge, could you please expand upon your suggestion by providing an example ?Sorry... I wasn't thinking when I posted that, as you are usingAutoIt v2, and I was referring to a AutoIt v3 command...
ErinC Posted March 23, 2004 Author Posted March 23, 2004 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.
Helge Posted March 23, 2004 Posted March 23, 2004 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'thave to change to AutoIt v3 just because of this.. 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..
ErinC Posted March 23, 2004 Author Posted March 23, 2004 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 !
Helge Posted March 23, 2004 Posted March 23, 2004 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 ! Hope I didn't confused you now..
ErinC Posted March 23, 2004 Author Posted March 23, 2004 (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 thank you very much for your help ! Erin Carter, Dumfries, Scotland. Edited March 23, 2004 by ErinC
Recommended Posts