Sign in to follow this  
Followers 0
whyme

Input Boxes

4 posts in this topic

#1 ·  Posted (edited)

Return Value

Returns the string that was entered.

If the InputBox was cancelled, then the InputBox will return an empty string ("") and set @error to 1; otherwise @error is 0.

I need it to do just what it claims it does in the help file. If nothing was inputted or cancel was clicked, I need it to close.

It keeps returning @error = 0 no matter if input is added or not, even if cancel is clicked.

Also I need if no is clicked ($UserInput = MsgBox(4,"Is this address Correct?",$answer)

If $UserInput = 7 Then) How to repeat the question until the correct information is inputted and then the ("%system%\Whyme.exe") would be launched.

AutoItSetOption ( "ExpandEnvStrings", 1 )

$UserInput = MsgBox(4,"Site_Recorder","Do you want to write to file?")

If $UserInput = 6 Then

$answer = InputBox("WebSite", "Site Address")

$file = FileOpen("%system%\Whyme.txt",2)

If @error = 1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWriteLine($file, $answer)

FileClose($file)

Else

EXIT

EndIf

$UserInput = MsgBox(4,"Is this address Correct?",$answer)

If $UserInput = 6 Then

Run("%system%\Whyme.exe")

EXIT

Else ;Here I need it to repeat the question until correct address is inputted then launch the exe

ENDIf

Edited by whyme

Share this post


Link to post
Share on other sites



OK I figured out the loop part. I still need the input box to close when clicked cancel, rather than the program finish running.

AutoItSetOption ( "ExpandEnvStrings", 1 )

$UserInput = MsgBox(4,"Site_Recorder","Do you want to write to file?")

If $UserInput = 6 Then

$answer = InputBox("WebSite", "Site Address")

$file = FileOpen("%system%\Whyme.txt",2)

If @error = 1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWriteLine($file, $answer)

FileClose($file)

Else

EXIT

EndIf

$UserInput = MsgBox(4,"Is this address Correct?",$answer)

If $UserInput = 6 Then

Run("%system%\Whyme.exe")

EXIT

Else

While 1

$answer = InputBox("WebSite", "Site Address")

$file = FileOpen("%system%\Whyme.txt",2)

If @error = 1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWriteLine($file, $answer)

FileClose($file)

EndIf

$UserInput = MsgBox(4,"Is this address Correct?",$answer)

If $UserInput = 6 Then

Run("%system%\Whyme.exe")

exit

else

Wend

EndIf

Share this post


Link to post
Share on other sites

I hope i will cover all your questions so let me give it a try...

Inputbox works as described in the help file, just do the test right after the inputbox..

not sure what you want to do with %SYSTEM% do you mean @WINDOWSDIR? . in the example below i replaced it with @scriptdir for testing

the WHILE will continue looping until you press cancel on the first input box or leave the value empty on the first input box or if you click Yes on the last inputbox and the pgm has run..

guess thats it... :whistle:

AutoItSetOption ( "ExpandEnvStrings", 1 )
$UserInput = MsgBox(4,"Site_Recorder","Do you want to write to file?")
If $UserInput = 7 Then Exit
While 1 
   $answer = InputBox("WebSite", "Site Address")
   if @error = 1 or $answer = "" then exit
   $file = FileOpen(@scriptdir & "\Whyme.txt",2)
   If $file = -1 Then
      MsgBox(0, "Error", "Unable to open file.")
      Exit
   EndIf
   $UserInput = MsgBox(4,"Is this address Correct?",$answer)
   if $userinput = 6 then
      FileWriteLine($file, $answer)
      FileClose($file)
      Run(@scriptdir & "\Whyme.exe")
      EXIT
   Endif
Wend

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I don't know if this will help you or not but it works as expected for me. It is simply an Input Box which allows the user to change the Registered owner that shows on the system.

Func ChngRO ()
$CRO=InputBox ($Title,"Enter the new Registered Owner",$RO,"",300,100)
If $CRO = "" Then
    $CRO = $RO
$NC = MSGBOX (4,$Title,"The Registered Owner was not changed" &@LF&@LF &"Do you wish to continue without changes?")
If $NC = 7 Then ChngRO ()


$Chng=MSGBOX (4,$Title,"The Registered Owner will be:  "&$CRO &@LF &"Is this correct?") 
If $Chng=7 Then
    ChngRO ()
    Else
    RegWrite ( $Key, "registeredowner","REG_SZ", $CRO)
    EndIf
EndFunc

Where $RO is simply a Regread of $Key which is the key that contains the value "registeredowner". It should give you the idea anyway.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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