Jump to content

$_IEStatus_Success error?


Recommended Posts

Part of the large script below, the bit called "_ReminderBoxWithAniGIF()", works perfectly when it's in a script all by itself. Once I incorporated it into the larger script below, that's when I got this error:

---------------------------
AutoIt Error
---------------------------
Line 4136  (File "K:\AutoIt\APP- AutoIt v3.2.10.0\Include\IE.au3"):

SetError($_IEStatus_Success)
SetError(^ ERROR

Error: Variable used without being declared.
---------------------------
OK   
---------------------------

Here's the main script:

;
; AutoIt 3x
;
;#include <GUIConstants.au3>     ; not needed since I extracted $GUI_EVENT_CLOSE syntax below from the appropriate UDF
;#include <WindowsConstants.au3>     ; not needed since I extracted $WS_EX_TOPMOST syntax below from the appropriate UDF
#NoTrayIcon     ; AutoIt's icon doesn't show in systray
TraySetIcon(@ScriptDir & "\Shutdown PC1.ico")
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!



;///////////////////////////////////////////////////////////////////////
;  Edit only this part below.  No need to change anything else in
;  script, except frequency.  It is set to say string below twice.
$ReminderMessage = "Don't forget to take your USB drive with you."
;///////////////////////////////////////////////////////////////////////



SoundPlay(@ScriptDir & "\Shutdown PC.wav")
Sleep(5000)
;=========================================================================
Global Const $GUI_EVENT_CLOSE = -3     ; by using this constant, could leave out reference to "#include <GUIConstants.au3>", which in turn referenced this variable, with this exact value, from "GUIConstantsEx.au3"
Global Const $WS_EX_TOPMOST    = 0x00000008     ;   put this in so that no need to have UDF present when compiling
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Shutdown ...", 350, 100, 600, 70, -1, $WS_EX_TOPMOST)     ; width, height, left, top, "-1, $WS_EX_TOPMOST" makes GUI ontop
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)     ;   put this in so that no need to have UDF present when compiling
GUISetIcon(@ScriptDir & "\Shutdown PC1.ico")     ; this changes icon in upper left-hand corner to your chosen icon
;----------------------------------------------------------
$Label2 = GUICtrlCreateLabel("Initiate PC shutdown?", 60, 15, 575, 25);  Left, Right, Width, Height of inside text box.
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
;----------------------------------------------------------
$Icon1 = GUICtrlCreateIcon(@ScriptDir & "\Shutdown PC2.ico", "Shutdown Icon", 20, 12, 32, 32)     ; filename, iconName, left, top, width, height
;----------------------------------------------------------
$OK = GUICtrlCreateButton("OK, go.", 60, 55, 70, 25, 0)     ; left, top, width, height    [SNOOZE button]
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")     ; controlID, size, weight
GUICtrlSetOnEvent(-1, "Click_OK")
GUICtrlSetTip(-1, "Shut down the PC.")     ; button tooltip
;----------------------------------------------------------
$Snooze = GUICtrlCreateButton("Snooze", 140, 55, 70, 25, 0)     ; left, top, width, height    [SNOOZE button]
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")     ; controlID, size, weight
GUICtrlSetOnEvent(-1, "Click_Snooze")
GUICtrlSetTip(-1, "Set time to delay doing this.")     ; button tooltip
;----------------------------------------------------------
$Cancel = GUICtrlCreateButton("Cancel", 220, 55, 70, 25, 0)     ; left, top, width, height    [CANCEL button]
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")     ; controlID, size, weight
GUICtrlSetOnEvent(-1, "Click_Cancel")
GUICtrlSetTip(-1, "Exit this box.")     ; button tooltip
; ---------------------------------------------------------
; CLOSE BUTTON on upper right-hand corner:
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")     ; "X" closes app, line "Global Const $GUI_EVENT_CLOSE = -3" above.  / You need to have a "Func Close()" below
; ----------------------
GUISetState(@SW_SHOW)
;=========================================================================

While 1
    Sleep(100)
WEnd

Func Click_OK()
    Sleep(1000)
    GUISetState(@SW_HIDE)
    Sleep(150)
    _ReminderBoxWithAniGIF()     ; box with animaged GIF
    Sleep(1500)
    ControlSend("Program Manager","",1,"{ALTDOWN}{F4}{ALTUP}")
EndFunc     ; End "Click_OK"

Func Click_Snooze()
    GUISetState(@SW_HIDE)
    $input = InputBox("PC Shutdown ...!", "Snooze for how many minutes?", 15)
    $time = $input*1000*60
    Sleep($time)
    #NoTrayIcon     ; AutoIt's icon doesn't show in systray
    GUISetState(@SW_SHOW)
    Beep(1250,75)
EndFunc     ;  End "Click_Snooze"

Func Click_Cancel()
    Exit
EndFunc     ;  End "Click_Cancel".


Func Close()
    Exit     ; finished
EndFunc  ;==>close


;--------



Opt("MustDeclareVars", 1)
#include <IE.au3>
#include <GUIConstants.au3>
#include <_AnimatedGIF.au3>

Func _ReminderBoxWithAniGIF()
    Local $pheight = 50, $pwidth = 50, $gif, $gif_control, $Label1, $Form1, $OK_Button, $msg
    $gif = @ScriptDir & "\Box with animated GIF + OK button.gif"
    If @error Then Exit
    $Form1 = GUICreate("Reminder!", 180, 85, 700, 120, -1, $WS_EX_TOPMOST)     ; width, height, left, top, "-1, $WS_EX_TOPMOST" makes GUI ontop
    $Label1 = GUICtrlCreateLabel("Don't forget ...", 60, 15, 575, 25);  Left, Right, Width, Height of inside text box.
    $OK_Button = GUICtrlCreateButton("OK", 60, 50, 65, 25)     ; left, top, width, height
    $gif_control=_GUICtrlCreateGIF($gif,15,15,0)     ; width, height, left, top
    GUISetState(@SW_SHOW)
    While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg=$OK_Button
            Exit     ; finished
        Case Else
            ;;;;;;;
        EndSelect
    WEnd
    Exit
EndFunc

Does anyone know what the conflict might be, or did I just do something wrong? Each part of the script works well by itself; it's together that they don't. Before putting in the box with the AniGIF, I had just a simple message box and it worked then. It just needed the extra pizzazz of a good animated exclamation point gif.

Thanks. :P

p.s., oh, and pls ignore my idiosyncratic syntax at times. I have my reasons for extracting snippets from UDFs, even though this script is not finished, or completely tidy in that way. Thx!

Edited by Diana (Cda)
Link to comment
Share on other sites

$_IEStatus_Success is defined in the prologue section of IE.au3 (the section before the function definitions).

By convention, you should have your #include statements at the top of your code.

If you are slicing and dicing the standard UDFs, you are on your own.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...