Jump to content

Not sure how to use "If @error then"


Go to solution Solved by Kinshima,

Recommended Posts

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?

Link to comment
Share on other sites

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

Edited by boththose

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

Link to comment
Share on other sites

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.

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

#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
Link to comment
Share on other sites

 

 

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

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