veerendra Posted October 7, 2013 Posted October 7, 2013 (edited) Hi, i tried to declare global function in my script but it was unable to run the script, no error is showing but it is not working here is my code pls help me outexpandcollapse popup Opt("MouseCoordMode",0) Global $first $first=_WinWaitActivate("Web Page Blocked! - Mozilla Firefox","") #region ---Au3Recorder generated code Start (v3.3.7.0) --- #region --- Internal functions Au3Recorder Start --- Func _Au3RecordSetup() Opt('WinWaitDelay',100) Opt('WinDetectHiddenText',1) Opt('MouseCoordMode',0) EndFunc Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc #endregion --- Internal functions Au3Recorder End --- Run('"C:\Program Files (x86)\Fortinet\FortiClient\FortiClient.exe"') Sleep(1000) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",91,249,1) Sleep(1000) MouseClick("left",377,470,1) Sleep(1000) MouseClick("left",490,465,1) Sleep(1000) MouseClick("left",363,241,1) Sleep(1000) MouseClick("left",345,342,1) Sleep(1000) _WinWaitActivate("Add Parental Control Exclusion","") Sleep(1000) MouseClick("left",256,71,1) Sleep(1000) Send("www.yahoo.com") Sleep(1000) MouseClick("left",226,134,1) Sleep(1000) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",274,473,1) Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"') sleep(1000) _WinWaitActivate("Google - Mozilla Firefox","") sleep(1000) MouseClick("left",269,90,1) sleep(1000) Send("{BACKSPACE}www.yahoo.com{DEL}{ENTER}") sleep(1000) _WinWaitActivate("Web Page Blocked! - Mozilla Firefox","") Sleep(1000) If $first<>_WinWaitActivate("Web Page Blocked! - Mozilla Firefox","") Then MouseClick("left",1256,15,1) Sleep(1000) _WinWaitActivate("Confirm close","") Sleep(1000) MouseClick("left",178,115,1) Else _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",274,473,1) EndIf MouseClick("left",273,62,1) sleep(1000) _WinWaitActivate("New Tab - Mozilla Firefox","") sleep(1000) MouseClick("left",306,92,1) sleep(1000) Send("www.google.ca{ENTER}") sleep(1000) MouseClick("left",1256,15,1) Sleep(1000) _WinWaitActivate("Confirm close","") Sleep(1000) MouseClick("left",178,115,1) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",445,789,1) Sleep(1000) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",489,465,1) Sleep(1000) MouseClick("left",351,169,1) Sleep(1000) MouseClick("left",385,347,1) Sleep(1000) _WinWaitActivate("Edit Parental Control Exclusion","") Sleep(1000) MouseClick("left",290,89,1) Sleep(1000) MouseClick("left",211,121,1) Sleep(1000) MouseClick("left",237,143,1) Sleep(1000) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",275,472,1) Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"') Sleep(1000) _WinWaitActivate("Google - Mozilla Firefox","") Sleep(1000) MouseClick("left",236,95,1) Sleep(1000) Send("{BACKSPACE}www.yahoo.com{DEL}{ENTER}") Sleep(1000) _WinWaitActivate("Yahoo Canada - Mozilla Firefox","") Sleep(1000) MouseClick("left",275,59,1) Sleep(1000) _WinWaitActivate("New Tab - Mozilla Firefox","") Sleep(1000) MouseClick("left",297,90,1) Sleep(1000) Send("www.yahoo.com{DEL}{ENTER}") Sleep(1000) MouseClick("left",1256,15,1) Sleep(1000) _WinWaitActivate("Confirm close","") Sleep(1000) MouseClick("left",178,115,1) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",446,793,1) Sleep(1000) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",106,249,1) Sleep(1000) MouseClick("left",386,470,1) Sleep(1000) MouseClick("left",450,780,1) Sleep(1000) _WinWaitActivate("FortiClient","") Sleep(1000) MouseClick("left",463,466,1) Sleep(1000) MouseClick("left",350,169,1) Sleep(1000) MouseClick("left",366,344,1) Sleep(1000) MouseClick("left",262,471,1) Sleep(1000) MouseClick("left",610,-1,1) #endregion --- Au3Recorder generated code End --- Edited October 7, 2013 by Melba23 Added code tags
MilesAhead Posted October 7, 2013 Posted October 7, 2013 Do you mean it hangs or it just quits? My Freeware Page
veerendra Posted October 7, 2013 Author Posted October 7, 2013 it is just startin. But not opening the application it self. If i remove Global=$first $first= example and the IF condition . then it is running normally. But i want the IF conditions in my script.
water Posted October 7, 2013 Posted October 7, 2013 Please enclose your code in AutoIt tags (the blue AutoIt icon in the editor). This greatly enhances readability My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
kylomas Posted October 7, 2013 Posted October 7, 2013 veerendra, Your if condition is comparing the content of $first to the return from the winwaitactivate function (a handle or 0). What are you trying to compare? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
veerendra Posted October 7, 2013 Author Posted October 7, 2013 I am trying to winwaitactive only. I need if that window opens then only I have to run the script
MilesAhead Posted October 7, 2013 Posted October 7, 2013 Your Function does not have a Return statement. Therefore it will always return a value of 0. See Return keyword in the help. My Freeware Page
veerendra Posted October 8, 2013 Author Posted October 8, 2013 I checked the return keyword, but i am not getting an idea how to use it here.
MHz Posted October 8, 2013 Posted October 8, 2013 veerendra, If the expection for the value of $first is a window handle then this may help. Replace the current one with this one. Func _WinWaitActivate($title, $text= "", $timeout = 0) If Not WinWait($title, $text, $timeout) Then Return 0 If Not WinActive($title, $text) Then WinActivate($title, $text) Return WinWaitActive($title, $text, $timeout) EndFunc Returns a window handle on success. Returns 0 on failure, which would be timed out if a timeout is used.
veerendra Posted October 8, 2013 Author Posted October 8, 2013 (edited) Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"') sleep(1000) _WinWaitActivate("Google - Mozilla Firefox","") sleep(1000) MouseClick("left",269,90,1) sleep(1000) Send("{BACKSPACE}www.yahoo.com{DEL}{ENTER}") sleep(1000) _WinWaitActivate("Yahoo Canada - Mozilla Firefox","") Sleep(1000) $first=_WinWaitActivate("Web Page Blocked! - Mozilla Firefox","") If $first<>_WinWaitActivate("Yahoo Canada - Mozilla Firefox","") Then MsgBox(0, "Error", "Please Check your Settings in Forticlient") Exit; Else MouseClick("left",273,62,1) sleep(1000) _WinWaitActivate("New Tab - Mozilla Firefox","") sleep(1000) MouseClick("left",306,92,1) sleep(1000) Send("www.google.ca{ENTER}") sleep(1000) MouseClick("left",1256,15,1) Sleep(1000) _WinWaitActivate("Confirm close","") Sleep(1000) MouseClick("left",178,115,1) EndIf Hi, here is my code, i am trying if Yahoo Canada <> $first then exit the script with msg else should run the script. but even though it is <> to condition it is not processing forward Edited October 8, 2013 by veerendra
somdcomputerguy Posted October 8, 2013 Posted October 8, 2013 (edited) AutoIt does not work well with Firefox. You'll have to use Internet Explorer, and the native IE functions. However, there are Firefox, Chrome, and Opera UDF's available on this Forum. Edited October 8, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Solution MHz Posted October 8, 2013 Solution Posted October 8, 2013 Hi, here is my code, i am trying if Yahoo Canada <> $first then exit the script with msg else should run the script. but even though it is <> to condition it is not processing forward Perhaps the vital part of your code could be like this? Send("{BACKSPACE}www.yahoo.com{DEL}{ENTER}") If WinWait("Yahoo Canada - Mozilla Firefox", "", 3) Then MsgBox(0, "Error", "Please Check your Settings in Forticlient") Exit EndIf _WinWaitActivate("Web Page Blocked! - Mozilla Firefox","") You could also use AdlibRegister to look for certain titles with WinExists and exit if detected.
veerendra Posted October 8, 2013 Author Posted October 8, 2013 Perhaps the vital part of your code could be like this? Send("{BACKSPACE}www.yahoo.com{DEL}{ENTER}") If WinWait("Yahoo Canada - Mozilla Firefox", "", 3) Then MsgBox(0, "Error", "Please Check your Settings in Forticlient") Exit EndIf _WinWaitActivate("Web Page Blocked! - Mozilla Firefox","") You could also use AdlibRegister to look for certain titles with WinExists and exit if detected. Thank you a lot it is working....
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