Jump to content
Sign in to follow this  
Dgameman1

Not sure how to use "If @error then"

Recommended Posts

Dgameman1

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?

Share this post


Link to post
Share on other sites
iamtheky

When closed, check to see if it exists, if so then quit. Rather than quit, then see if quit did anything.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Dgameman1

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

Share this post


Link to post
Share on other sites
iamtheky

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.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Dgameman1

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?

Share this post


Link to post
Share on other sites
Dgameman1
#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 by Dgameman1

Share this post


Link to post
Share on other sites
SadBunny

 

 

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

 

:D


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
Dgameman1

No, it's probably that the dilithium crystals are misaligned in the warp core. Though an error message should provide insight.

 

Also:

 

 

biggrin_22x22@1x.png

 

Lmao I don't want to talk about it.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.