Jump to content

Terminate back to GUI


Recommended Posts

Hi Guys,

My Problem is I am trying to create a GUI that is kind of a dashboard where perform autofill IE forms/auto logins. The problem is when I stop one of this processes from completing itself naturally the script hangs so to speak and the GUI no longer responds. This is because the script doesn't know where to go. My question is, is their a function I could implement into my script that automatically terminates back to the GUI if I interrupt the IECreate and autofill process.

Pseudo Code Example;

GUI()

Launch Func Work()

Func Work()

$oIE = _IECreate ("C:\example.html")

WinSetState("Example", "", @SW_MAXIMIZE)

_$oForm = _IEFormGetObjByName ($oIE, "asdf")

$oQuery1 = _IEFormElementGetObjByName ($oForm, "fdsa") ;

_IEFormElementSetValue ($oQuery1, $temp)

_IEFormSubmit ($oForm)

_IELoadWait ($oIE)

GUI()

End Func

The objective is if I terminate my script in the middle of work() I want to go back to my GUI as normal. Any ideas? Any help would be appreciated. ^_^

Thanks

Frequent sufferer of ID10T Syndrome and CRAFT (Can't Remember A "BLEEP" Thing)
Link to comment
Share on other sites

Create a hotkey that does it...

I think the best way to do it is completely restart the script using this wrapper:

http://www.autoitscript.com/forum/index.ph...st&p=199608

edit: you could also check @Error status after every function: if @Error Then Restart ()

edit2:

HotKeySet ("!a", "Restart")

GUI()

Func Work()
   Local $oIE, $oForm, $oQuery1, $temp; You will get an error with temp as it is not defined

   $oIE = _IECreate ("C:\example.html")
      If @Error Then Restart ()
   WinSetState("Example", "", @SW_MAXIMIZE)
   $oForm = _IEFormGetObjByName ($oIE, "asdf")
      If @Error Then Restart ()
   $oQuery1 = _IEFormElementGetObjByName ($oForm, "fdsa")
      If @Error Then Restart ()
   _IEFormElementSetValue ($oQuery1, $temp)
      If @Error Then Restart ()
   _IEFormSubmit ($oForm)
      If @Error Then Restart ()
   _IELoadWait ($oIE)
      If @Error Then Restart ()
   GUI()
EndFunc; ==> Work

Func Restart()
    If @Compiled = 1 Then
        Run( FileGetShortName(@ScriptFullPath))
    Else
        Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc; ==> Restart
Edited by mdiesel
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...