xuzo Posted July 15, 2012 Posted July 15, 2012 I'm starting to be able to create short scripts, but the execution is erratic, some pop ups and sounds show up to quick or to slow. I have set some win wait and sleeps but still I can't seem to get a good flow between steps, any suggestions welcome. This happens with this example: ;WinSetState("[CLASS:SciTEWindow]", "", @SW_MINIMIZE) Opt("WinTitleMatchMode", 2) If WinExists ("Mozilla") Then MsgBox(0, "", "Firefox is now running") Sleep(1000) Else MsgBox(0, "", "Please Start Firefox") EndIf WinWaitActive("Mozilla") If WinExists ("Mozilla") Then MsgBox(0, "", "Firefox is now running") Sleep(1000) Else MsgBox(0, "", "Please Start Firefox") EndIf PS. Do I need to repeat my Opt("WinTitleMatchMode", 2) before EVERY Window or just leave it at the beginning of the script? Thanks
Skitty Posted July 15, 2012 Posted July 15, 2012 (edited) Not quite sure what the problem could be, I haven't played much with handling windows, but this would be how I would probably start. HotKeySet("{ESC}","Escape") Global $FFClass = "[CLASS:MozillaWindowClass]" While Not WinExists($FFClass) Switch MsgBox(16+5+262144, "Error!", "Please Start Firefox.") Case 4 ContinueLoop Case 2 Escape() EndSwitch WEnd If WinExists($FFClass) Then WinActivate($FFClass) MsgBox(64, "Info!", "here's where you can do stuff with FF") Else MsgBox(16,"","") EndIf Func Escape() Exit EndFunc P.S. To get the "CLASS" name of windows, use the "AU3Info" tool under the tools menu in the SciTE editor. Edited July 15, 2012 by ApudAngelorum
xuzo Posted July 15, 2012 Author Posted July 15, 2012 (edited) Thank you Apud,Actually your script is much better than mine!But still on my machine, the Windows Chime sound comes before the pop up, how can I make sure everything is in synch everytime?Sometimes it works, and sometimes not, depending on what windows are open ect...For example:The sound comes firstThen maybe half second later the pop up:MsgBox(64, "Info!", "here's where you can do stuff with FF")I hope I'm being clear! Edited July 15, 2012 by xuzo
Skitty Posted July 15, 2012 Posted July 15, 2012 No, that sounds more like a problem with some kind of antivirus intercepting activity in your script. Try to add an exception for the autoit interpreter, autoit3.exe.
xuzo Posted July 15, 2012 Author Posted July 15, 2012 (edited) Actually that might just be it, I just installed Ad-Aware yesterday, causing all kinds of slow downs and crashes.. will add exeption or switch to any anther anti virus program. P.S. To get the "CLASS" name of windows, use the "AU3Info" tool under the tools menu in the SciTE editor. Problem with that is browser backwards compatibility, for example: Firefox 2.0 MozillaUIWindowClass Firefox 12.0 MozillaWindowClass Can I use operators 1,2,3 and 4 for Windows Class as I do for titles to be compatible with more broswers? Like these?: Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Edited July 15, 2012 by xuzo
Skitty Posted July 15, 2012 Posted July 15, 2012 Actually that might just be it, I just installed Ad-Aware yesterday, causing all kinds of slow downs and crashes.. will add exeption or switch to any anther anti virus program. Problem with that is browser backwards compatibility, for example: Firefox 2.0 MozillaUIWindowClass Firefox 12.0 MozillaWindowClass Can I use operators 1,2,3 and 4 for Windows Class as I do for titles to be compatible with more broswers? Like these?: Nope. If you want backwards compatibility, I recommend you do it the way you were with option 2 for the opt statement.
GNGNUT Posted July 16, 2012 Posted July 16, 2012 (edited) Dont know if this will help I use this when im waiting for windows to popup form an action all the info i get from the info finder Opt("WinTitleMatchMode", 2) ;=> Matchs a string with in the title (ie Google - Mozilla Firefox) Opt("WinTextMatchMode", 2) ;=> Matchs a string with in the Text Func _WinWaitActivate($vWintitle, $vWinText, $timeout) WinWait($vWintitle, $vWinText, $timeout) If Not WinActive($vWintitle, $vWinText) Then WinActivate($vWintitle, $vWinText) WinWaitActive($vWintitle, $vWinText, $timeout) EndFunc ;==>_WinWaitActivate $timeout = 3 ;=> acts as a sleep using whole numbers, 3 second wait if the window doesnot show up will continue script 0 is unlimited $vWintitle = "Mozilla Firefox" ;=> title of the window $vWinText = "" $Controlid = "Button1" _WinWaitActivate($vWintitle, $vWinText, $timeout) ;=> will wait for the window to showup and then activate that window ready for you action in this case click a button Controlclick($vWintitle,$vWinText,$controlid) _WinWaitActivate($vWintitle, $vWinText, $timeout) <<< this will not work if your computer is locked Edited July 16, 2012 by GNGNUT
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