CaptainBeardsEyesBeard Posted March 26, 2018 Share Posted March 26, 2018 (edited) Hi I'm just trying to figure out error handling in Autoit I'm trying to learn error handling in Autoit and at the moment I'm having trouble with switching to the correct window however it is executing the Else statement not the If statement. I'll also point out it's not switching to the Solcase application WinActivate("SolCase 7 - a LexisNexis Visualsfiles product") ; Focus Elite window If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Switching window") Else MsgBox($MB_SYSTEMMODAL, "Error", "blah blah") EndIf Thanks Edited March 26, 2018 by CaptainBeardsEyesBeard Link to comment Share on other sites More sharing options...
Developers Jos Posted March 26, 2018 Developers Share Posted March 26, 2018 I guess you need: $wHnd=WinActivate("SolCase 7 - a LexisNexis Visualsfiles product") ; Focus Elite window If $wHnd Then MsgBox($MB_SYSTEMMODAL, "Found window", "Switching window") Else MsgBox($MB_SYSTEMMODAL, "Error", "$wHnd is 0 so window not found") EndIf since the helpfile states: Quote Return Value Success: the handle of the window. Failure: 0 if window is not found or cannot be activated. Remarks You can use the WinActive() function to check if WinActivate() succeeded. If multiple windows match the criteria, the window that was most recently active is the one activated. WinActivate() works on minimized windows. However, a window that is "Always On Top" could still cover up a window you Activated. After a successful activation @extended is set to 1 if the the window was already active, 2 if not. 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...
CaptainBeardsEyesBeard Posted March 26, 2018 Author Share Posted March 26, 2018 Nice one thanks. I had read previously that the @error is used as a try/catch method in autoit. In what instance would I use @error? 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