jdicerch Posted July 5, 2013 Share Posted July 5, 2013 (edited) Hi everyone, first post here so take it easy on me. I am new to AutoIt and trying to write a script that will download malwarebytes, install it, update, then run a quick scan. Everything works flawlessly except when it updates, there is an OK dialog that I cannot seem to automate. The script wont continue until I click OK, and I have tried multiple ways but none seem to work. Any help is greatly appreciated. Here is my code so far: #RequireAdmin InetGet("http://www.malwarebytes.org/mbam/program/mbam-setup.exe", @ScriptDir & "mb.exe", 0) RunWait("mb.exe /SILENT") ProcessWaitClose("mbam.exe") If FileExists("C:\Program Files (x86)") Then RunWait("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /updateshowdialog") ControlClick("Malwarebytes Anti-Malware","The database was successfully updated ",2) Run("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /quickscan") ElseIf FileExists("C:\Program Files") Then RunWait("C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe /updateshowdialog") ControlClick("Malwarebytes Anti-Malware","The database was successfully updated ",2) Run("C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe /quickscan") Else MsgBox(0,"MBAM not found","Malwarebytes Installation failed") EndIf Besides for the ControlClick, I have tried activating the window as well, WinWait, WinActivate, etc. EDIT: sorry, I should have been more specific...It appears when I update after this line "RunWait("C:Program FilesMalwarebytes' Anti-Malwarembam.exe /updateshowdialog")" Here is the box that appears: Edited July 5, 2013 by jdicerch Link to comment Share on other sites More sharing options...
BrewManNH Posted July 5, 2013 Share Posted July 5, 2013 What is the dialog box, and where in your script does it appear? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jdicerch Posted July 5, 2013 Author Share Posted July 5, 2013 I edited my above post! Thank you for the quick reply Link to comment Share on other sites More sharing options...
BrewManNH Posted July 5, 2013 Share Posted July 5, 2013 Don't use RunWait, as that pauses the script until the program you started ends. In this case it won't end until you click that box away, so your script never sees it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jdicerch Posted July 5, 2013 Author Share Posted July 5, 2013 If I don't use runwait, the scan will start before the program is updated. Is there a way around that? Link to comment Share on other sites More sharing options...
Solution BrewManNH Posted July 5, 2013 Solution Share Posted July 5, 2013 Untested, but should work. #RequireAdmin InetGet("http://www.malwarebytes.org/mbam/program/mbam-setup.exe", @ScriptDir & "mb.exe", 0) RunWait("mb.exe /SILENT") ProcessWaitClose("mbam.exe") If FileExists("C:\Program Files (x86)") Then Run("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /updateshowdialog") ; <<<<<<<<<<<<< WinWait("Malwarebytes Anti-Malware", "The database was successfully updated ") ; <<<<<<<<<<<<<< WinActivate("Malwarebytes Anti-Malware", "The database was successfully updated ") ; not sure if this is needed or not ControlClick("Malwarebytes Anti-Malware", "The database was successfully updated ", 2) Run("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /quickscan") ElseIf FileExists("C:\Program Files") Then RunWait("C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe /updateshowdialog") ControlClick("Malwarebytes Anti-Malware", "The database was successfully updated ", 2) Run("C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe /quickscan") Else MsgBox(0, "MBAM not found", "Malwarebytes Installation failed") EndIf See the lines that were added/changed, marked by "; <<<<<<<<<<<<<<". If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jdicerch Posted July 5, 2013 Author Share Posted July 5, 2013 I thought that would work too, but for some reason it doesn't. Maybe malwarebytes blocked it from being seen? I tried just popping up a MsgBox if the window was seen by winExists or WinActive and nothing. It doesn't even recognize it : / Link to comment Share on other sites More sharing options...
jdicerch Posted July 5, 2013 Author Share Posted July 5, 2013 Oh wait! I still had one runWait left in there...THANK YOU! A combination of removing the runWait, and adding a WinWaitActive solved the problem. thank you for all your help, here is the working code if anyone stumbles upon this problem. #RequireAdmin InetGet("http://www.malwarebytes.org/mbam/program/mbam-setup.exe", @ScriptDir & "mb.exe", 0) RunWait("mb.exe /SILENT") ProcessWaitClose("mbam.exe") If FileExists("C:\Program Files (x86)") Then Run("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /updateshowdialog") ; <<<<<<<<<<<<< WinWait("Malwarebytes Anti-Malware", "The database was successfully updated ") ; <<<<<<<<<<<<<< ControlClick("Malwarebytes Anti-Malware","The database was successfully updated ",2) WinActivate("Malwarebytes Anti-Malware", "The database was successfully updated ") ; not sure if this is needed or notControlClick("Malwarebytes Anti-Malware","The database was successfully updated ",2) Run("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /quickscan") ElseIf FileExists("C:\Program Files") Then Run("C:\Program Files (x86)\Malwarebytes' Anti-Malware\mbam.exe /updateshowdialog") ; <<<<<<<<<<<<< WinWait("Malwarebytes Anti-Malware", "The database was successfully updated ") ; <<<<<<<<<<<<<< WinActivate("Malwarebytes Anti-Malware", "The database was successfully updated ") ; not sure if this is needed or not ControlClick("Malwarebytes Anti-Malware","The database was successfully updated ",2) Run("C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe /quickscan") Else MsgBox(0,"MBAM not found","Malwarebytes Installation failed") EndIf 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