Dgameman1 Posted April 19, 2015 Posted April 19, 2015 I have a program, that when closed runs this script.. _IEQuit($browser) But sometimes, the $browser that was created with Local $browser = _IECreate("http://google.com/") was closed by the user, which is fine. But then how can I prevent an error from occurring if the $browser is already closed?
iamtheky Posted April 19, 2015 Posted April 19, 2015 (edited) When closed, check to see if it exists, if so then quit. Rather than quit, then see if quit did anything. Edited April 19, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Dgameman1 Posted April 19, 2015 Author Posted April 19, 2015 When closed, check to see if it exists, if so then quit. Rather than quit, then see if quit did anything. I know how to check if a process exists but I'm not sure how to check to see if $browser exists
iamtheky Posted April 19, 2015 Posted April 19, 2015 Are there many internet explorer windows? maybe getting the handle directly after creation, then winexists before quitting? I was totally thinking that checking to see if the object still exists would work, but no. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Dgameman1 Posted April 19, 2015 Author Posted April 19, 2015 Are there many internet explorer windows? maybe getting the handle directly after creation, then winexists before quitting? I was totally thinking that checking to see if the object still exists would work, but no. Ah, well I feel like there's no need to get too complicated because it doesn't really matter if there's an error or not. Like if the browser is already closed then great. Is there a way to just attempt it and if it doesn't work then it ignores the error and continues on with the code?
Solution Kinshima Posted April 19, 2015 Solution Posted April 19, 2015 #include <ie.au3> Local $browser = _IECreate("http://google.com/") $handle = _IEPropertyGet($browser , "hwnd") If WinExists($handle) Then _IEQuit($browser) EndIf Dgameman1 1
Dgameman1 Posted April 19, 2015 Author Posted April 19, 2015 (edited) #include <ie.au3> Local $browser = _IECreate("http://google.com/") $handle = _IEPropertyGet($browser , "hwnd") If WinExists($handle) Then _IEQuit($browser) EndIf I get an error with that. I think it's because the variable $handle is not found. Here is part of my code While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If WinExists($handle) Then _IEQuit($browser) EndIf If GUICtrlRead($clearhistoryCheckBox) = $GUI_CHECKED Then Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & "255") EndIf Exit Case $Awkward Case $Button Local $browser = _IECreate("google.com") $handle = _IEPropertyGet($browser , "hwnd") EndSwitch WEnd Edited April 20, 2015 by Dgameman1
JohnOne Posted April 19, 2015 Posted April 19, 2015 Use an error handler. Also, give details of the error. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
SadBunny Posted April 20, 2015 Posted April 20, 2015 I get an error with that. I think it's because the variable $handle is not found. No, it's probably that the dilithium crystals are misaligned in the warp core. Though an error message should provide insight. Also: Case $pornviewerForm Roses are FF0000, violets are 0000FF... All my base are belong to you.
Dgameman1 Posted April 20, 2015 Author Posted April 20, 2015 No, it's probably that the dilithium crystals are misaligned in the warp core. Though an error message should provide insight. Also: Lmao I don't want to talk about it.
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