Jump to content

Not sure how to use "If @error then"


Go to solution Solved by Kinshima,

Recommended Posts

Posted

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?

Posted (edited)

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

Edited by boththose

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

Posted

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

Posted

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.

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

Posted

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?

Posted (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 by Dgameman1
Posted

 

 

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.

Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...