tuffgong Posted September 25, 2017 Posted September 25, 2017 I give the user an option to start 5 different web pages through a GUI. Then I want to manipulate the pages they have chosen to open. First, I need to see which pages they have chosen to open. I suppose I could just create a Boolean solution; when they choose a page set it to True, but isn't there a way to check if a page exists? I copied the code below right from the WinExists help file, added IE to it, and it appears to do the opposite! If the page is open the message says "Window does not exist" and for the check that does not exist I get "Window exists"! What is the best way to see if the user has activated $oIE1, $oIE2, $oIE3, etc.? #include <MsgBoxConstants.au3> #include <IE.au3> Global $oIE2, $oIE3 Example() Func Example() $oIE3 = _IECreate("www.google.com") ; Wait 10 seconds for the Notepad window to appear. Sleep(10000) ; Test if the window exists and display the results. If WinExists($oIE3) Then MsgBox($MB_SYSTEMMODAL, "1", "Window exists") Else MsgBox($MB_SYSTEMMODAL, "1", "Window does not exist") EndIf If WinExists($oIE2) Then MsgBox($MB_SYSTEMMODAL, "2", "Window exists") Else MsgBox($MB_SYSTEMMODAL, "2", "Window does not exist") EndIf EndFunc ;==>Example
Floops Posted September 26, 2017 Posted September 26, 2017 _IECreate returns an object, however WinExists requires a handle. As to your second problem, it seems that calling WinExists with an empty string (or an unassigned variable in your case) for the Window Name always returns True. If you set it to 0 it won't say that the window exists. #include <MsgBoxConstants.au3> #include <IE.au3> Global $oIE2 = 0, $oIE3 = 0 Example() Func Example() $oIE3 = _IECreate("www.google.com") $hWnd = _IEPropertyGet($oIE3, "hwnd") ; Wait 10 seconds for the Notepad window to appear. Sleep(10000) ; Test if the window exists and display the results. If WinExists($hWnd) Then MsgBox($MB_SYSTEMMODAL, "1", "Window exists") Else MsgBox($MB_SYSTEMMODAL, "1", "Window does not exist") EndIf If WinExists($oIE2) Then MsgBox($MB_SYSTEMMODAL, "2", "Window exists") Else MsgBox($MB_SYSTEMMODAL, "2", "Window does not exist") EndIf EndFunc ;==>Example
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