aarellan Posted July 12, 2017 Share Posted July 12, 2017 Hi all, New member/AutoIT user here. I'm trying to create a simple automation script that will launch a setup file I've created for Kaspersky. When I run the script below, the ShellExecute function runs as intended and brings up my setup file, but does not proceed with any further commands. I've noticed that after my setup file pops up, the script terminates itself shortly afterwards (no Script Pause, it just exits). I've referenced help documentation on AutoIT's site for these commands (WinWaitActive and ControlClick), and it seems like I have the syntax correct. I obtained the information in the commands using the WindowInfo tool. What am I doing wrong here? 2017-07-12_11-00-03.bmp Link to comment Share on other sites More sharing options...
Developers Jos Posted July 12, 2017 Developers Share Posted July 12, 2017 Welcome, Please put the code you like to show in a CodeBox (<>) with cut&Paste in stead of adding an image as that makes it much harder to help. If the code just ends without any errors it means the WinWaitActive(s) were successful and ControlSend(s) were performed. Why aren't you using the Silent option for the installer in the first place as that should be much less error prone? Isn't the installer asking for Admin level or are you shelling the script at that level already? Jos 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. Link to comment Share on other sites More sharing options...
aarellan Posted July 12, 2017 Author Share Posted July 12, 2017 Hi Jos, Thanks for the tip about the CodeBox, didn't realize that was an option: #RequireAdmin ShellExecute ("setup.exe", "", "\\bbna-kasp\KLSHARE\PkgInst\Install Endpoint Security (10.3.0.6294) and Network Agent (10.4.343)") WinWaitActive ("Installing Kaspersky Lab applications", "") ControlClick ("Button1", "Start installation", 6) WinWaitActive ("Installing Kaspersky Lab applications", "Close", 2) ControlClick ("Button1", "Close", 2) Exit I've tried to utilize a silent option with the setup installer, but I can't get that to work either. That's why I wanted to try out AutoIT to automate the mouse clicks I need. It doesn't seem like any of the commands besides ShellExecute are being performed. When my installation window pops up, the "Start installation" button is not clicked, even though I specified that step immediately afterwards. In its current configuration, shouldn't the script wait until my installation window is active, then proceed to click the button I specified? Or did I code that portion wrong? The installer does require administrative privileges by default, I just read a tip from another post that said including this line may resolve my command execution problems, but it doesn't. When I remove this line, the same issue occurs. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 12, 2017 Developers Share Posted July 12, 2017 (edited) Well, your ControlClick() statements are wrong for sure now I look at them. The first 2 parameters should be Title and Text, which are missing! Jos Edited July 12, 2017 by Jos aarellan 1 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. Link to comment Share on other sites More sharing options...
aarellan Posted July 12, 2017 Author Share Posted July 12, 2017 Ahh, that was the problem. I had the title confused with the name of the button I was referencing. I changed that to my installation window title and it worked like a charm. Thanks! Link to comment Share on other sites More sharing options...
Elena Posted August 8, 2017 Share Posted August 8, 2017 Hi, I have similar problem. Looks like I cannot attach my code to correct window. #include <MsgBoxConstants.au3> Func Example () ;$HWND_Installer = WinWait("Installer Language", "Please select a language.", 10) $HWND_Installer = WinGetHandle("Installer Language", "Please select a language.") $btnOK = ControlGetHandle($HWND_Installer, "", "Button1") ControlClick ( $HWND_Installer, "", $btnOK) ControlClick ("Installer Language", "Please select a language.", $btnOK) ;MsgBox (0, "Installer", "$HWND_Installer = " & $HWND_Installer & @CRLF & "$btnOK = " & $btnOK) WinClose($HWND_Installer) WinClose("Installer Language", "Please select a language.") EndFunc ;==>Example Example() I ran my installer before calling this function, and it is already displayed on the desktop. When I de-comment MsgBox fragment, it correctly displays hWnd variables for my installer, the same I can see with AutoIt Info tool. But ControlCLick does not work, as well as WinClose (tried with hWnd and title as you can see from code). Please help. I attach my screen with installer window. Link to comment Share on other sites More sharing options...
Developers Jos Posted August 8, 2017 Developers Share Posted August 8, 2017 Is your script running with the same credentials and elevation (Administrator rights) ? Jos 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. Link to comment Share on other sites More sharing options...
Elena Posted September 5, 2017 Share Posted September 5, 2017 Yes. (If I understand your question correctly). I run program and script with the same user on PC. Link to comment Share on other sites More sharing options...
Elena Posted September 7, 2017 Share Posted September 7, 2017 Here is my call of ShellExecute before trying to ControlClick(). Nothing special: ShellExecute ("Installer.exe", @ScriptDir ) Link to comment Share on other sites More sharing options...
Developers Jos Posted September 7, 2017 Developers Share Posted September 7, 2017 What about you show the whole script as you have now just posted bits and pieces which don't make it clear to me? You could very well have some sort of timing error, meaning the application is still starting when you perform already functions for it. Jos 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. Link to comment Share on other sites More sharing options...
Elena Posted September 7, 2017 Share Posted September 7, 2017 Here it is: #include <MsgBoxConstants.au3> Func Example () Local $iPID = ShellExecute ("Installer.exe", @ScriptDir ) $HWND_Installer = WinWait("Installer Language", "Please select a language.", 10) ;$HWND_Installer = WinGetHandle("Installer Language", "Please select a language.") $btnOK = ControlGetHandle($HWND_Installer, "", "Button1") ControlClick ( $HWND_Installer, "", $btnOK) ControlClick ("Installer Language", "Please select a language.", $btnOK) ;MsgBox (0, "Installer", "$HWND_Installer = " & $HWND_Installer & @CRLF & "$btnOK = " & $btnOK) WinClose($HWND_Installer) WinClose("Installer Language", "Please select a language.") EndFunc ;==>Example Example() Link to comment Share on other sites More sharing options...
Elena Posted September 7, 2017 Share Posted September 7, 2017 I can also provide a link to download installer program if needed. Link to comment Share on other sites More sharing options...
Elena Posted September 7, 2017 Share Posted September 7, 2017 (edited) Jos - I realized that you were right about administrative rights. Now I built .au3 file into .exe and called right-click > Run as administrator - it works. Buttons are clicked and window closes. When asking a question, I just used F5 button (Tools > Go) in SciTE editor to run. Is it possible to run the script with administrative rights without building it into EXE? Edited September 7, 2017 by Elena Link to comment Share on other sites More sharing options...
Developers Jos Posted September 7, 2017 Developers Share Posted September 7, 2017 Sure, just add the #RequireAdmin Directive at the top of your script. Jos 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. Link to comment Share on other sites More sharing options...
Elena Posted September 7, 2017 Share Posted September 7, 2017 Super, it works! Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now