Sign in to follow this  
Followers 0
bigbangnet

proper exit when cancel is pressed

3 posts in this topic

Seem pretty simple enough but I can do it properly. So here is the code first:

Local $ordi = InputBox( "VNCViewer - Script", "Entrez votre Addresse Ip ou le nom de hote")

Run( "C:\Program Files\UltraVNC\vncviewer.exe" & " " & $ordi & " " & "-password 1111")
If @error = 1 Then Exit; exit if cancel pressed

What happens: when script is started, I press cancel to exit the script but when I do, vnc pop's up.

What I want to happen: when cancel is pressed, it exits the script without opening vnc.

Again, any help will be appreciated.

Thanks guys


** Warning **Noobie ahead. handle with caution

Share this post


Link to post
Share on other sites



Put the if statement before the run command.

Share this post


Link to post
Share on other sites

... I feel like an idiot. thanks for the help


** Warning **Noobie ahead. handle with caution

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  
Followers 0

  • Similar Content

    • StudioMaker
      By StudioMaker
      Hey anyone knows how i can have a inputbox that is connected to an HotKeySet? Like if u put in like "a" in the inputbox it sets the hotkey to "a"?
       
    • IamKJ
      By IamKJ
      So I have a lot of different functions in the little program I'm making.  Most of them use the Do statement, such as finding images, clicking buttons, etc.
       
      The question I have is how would I be able to both
      1) Create a hotkey to pause whatever I am doing at the moment.  If I have to put something into every function in the program, I don't mind.
      2) Create a hotkey to exit whatever I am doing and stop all loops or commands and bring back the main GUI?
    • ur
      By ur
      I have created an exit function and registered using OnAutoItExitRegister.But it is not running when I close the app from taskbar or even with normal exit during end.
       
      Below is the part of code and the included files.
      #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> #include <file.au3> #include <Array.au3> #include <String.au3> OnAutoItExitRegister("Exit_Program") Func Exit_Program() LoggingMainScr("Entered Exit_Program") Local $exitmethod = ["Natural closing", "close by Exit function", "close by clicking on exit of the systray","close by user logoff","close by Windows shutdown"] ExitProgram("Exit with exit code: "& @exitCode & " And because of: " & $exitmethod[@exitmethod],@exitmethod) EndFunc Func ExitProgram($sReason="Exit by user",$sCode=0) LoggingMainScr($sReason) if $sCode <> 0 then LoggingMainScr("stopped before completion") FileDelete(@ScriptDir&"\Machines*.txt") FileDelete(@ScriptDir&"\PsExec.exe") FileDelete(@ScriptDir&"\HyperVMachines.ps1") FileDelete(@ScriptDir&"\VMwareMachines.ps1") EndFunc Func LoggingMainScr($sMessage) LoggingDefault($sMessage,@ScriptDir&"\MainScr_Logging.log") EndFunc Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log") If $sMessage = "" Then FileWriteLine($sLogFile, "") Else FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF) EndIf EndFunc Any suggestion.
       
    • fopetesl
      By fopetesl
      For some reason my personal notes were omitted when posting.
      Still a Newb it seems! So have attached my slightly modified example.
      If I comment out Exit button references script will not Exit even with windows 'X' button icon.
      If I'm losing GUI/Tab focus I cannot see where is the difference with(out) definition.
      GUI_No_Exit.au3
    • akira2891
      By akira2891
      Hi,
      I was wondering is this all inputs can be done in 1 box with 3 fields and not to use another gui.
      And how can i validate data for example if i don't enter username he prompt me a message box all time until field is empty.
      I try like this but it give me a msgbox and continue on another field.
      $username = InputBox("Add new user", "Username", "", "", 200, 130, Default, Default, 0) if $username <> " " then msgbox(0, "", "Please enter username") endif $email = InputBox("Add new user", "Email", "", "", 200, 130, Default, Default, 0) $password = InputBox("Add new user", "Password", "", "*", 200, 130, Default, Default, 0)