Jump to content
Ackerz

Automated msgbox with input box

Recommended Posts

Ackerz

Hi guys,

So I am trying to automate a task and this task has an input box with an already set character "9". 

I have just decided that I don't really need the input as an option but it's good to leave however for this instance I would like it to run past this point automatically. I've tried numerous ways to try and automate the use of the "OK" button using ControlClick and various other options. I just can't seem to see where this point in the script is. Scoured the forums for anything similar but didn't have any luck finding anything. Sorry to be a pain and I hope someone can help, if I haven't explained in enough detail please don't hesitate to ask for more.

Many thanks,

Ackerz

 

Local $len
         Local $n
         Local $buff
         Local $aMyDate

            $Len =  InputBox("Test",$msgPrompt,"9")
            $len =  StringStripWS($len,$STR_STRIPALL)

                           ;Check that user has entered a vaild password length
                           if not StringIsDigit($len) or $len = 0 Then
                              MsgBox(48,"Error","Invaild Integer was entered" & @CRLF & "Program will now exit.")
                              Exit
                           EndIf

                           ;This creates the random password.
                           for $i = 1 to $Len
                              ;Pick a random char between 1 and the pwsMask Length
                              $n = int(random(1,StringLen($pwsMask)))
                              ;Concat each char that has been picked out of pwsMask to $buff
                              $buff = $Buff & StringMid($pwsmask,$n,1)
                            
                           Next

 

Share this post


Link to post
Share on other sites
Subz

Just use the timeout on the InputBox

Share this post


Link to post
Share on other sites
Ackerz
1 hour ago, Subz said:

Just use the timeout on the InputBox

$Len =  InputBox("Test",$msgPrompt,"9", , , , , 5)

Would I have to put a value in the parameters before that? From my understanding I have put the timeout as "1" above and that should then use the default input for that InputBox.

Have I done this correctly?

Reading through the help told me the last one was timeout so that's why I did this. I have also tried adding parameters into the other options so Width, Height etc and it didn't work.

Apologies for my lack of knowledge.

Share this post


Link to post
Share on other sites
Nine

yes you need to put all parameters before the timout...if it still doesnt work post your code here

Share this post


Link to post
Share on other sites
Ackerz
19 hours ago, Nine said:

yes you need to put all parameters before the timout...if it still doesnt work post your code here

Sure thing.

So it perfectly executes the timeout now. However it goes onto the check and returns with invalid integer so that says to me it's not taking the "9" I'm putting in as a parameter for my InputBox. I have tried to skip this check but then well it didn't work at all.

Local $len
         Local $n
         Local $buff
         Local $aMyDate

            $Len =  InputBox("Test",$msgPrompt,"9","",-1,-1,Default,Default,3)
            $len =  StringStripWS($len,$STR_STRIPALL)

                           ;Check that user has entered a valid password length
                           if not StringIsDigit($len) or $len = 0 Then
                              MsgBox(48,"Error","Invalid Integer was entered" & @CRLF & "Program will now exit.")
                              Exit
                           EndIf

                           ;This creates the random password.
                           for $i = 1 to $Len
                              ;Pick a random char between 1 and the pwsMask Length
                              $n = int(random(1,StringLen($pwsMask)))
                              ;Concat each char that has been picked out of pwsMask to $buff
                              $buff = $Buff & StringMid($pwsmask,$n,1)
                            
                           Next

 

Share this post


Link to post
Share on other sites
Nine
17 minutes ago, Ackerz said:

I have tried to skip this check but then well it didn't work at all.

You must check the @error if it is set ....

Return Value

Success: the string that was entered.
Failure: "" (empty string) and sets the @error flag to non-zero.
@error: 1 = The Cancel button was pushed.
2 = The Timeout time was reached.
3 = The InputBox failed to open. This is usually caused by bad arguments.
4 = The InputBox cannot be displayed on any monitor.
5 = Invalid parameters width without height or left without top.

Share this post


Link to post
Share on other sites
Ackerz
20 hours ago, Nine said:

You must check the @error if it is set ....

Return Value

Success: the string that was entered.
Failure: "" (empty string) and sets the @error flag to non-zero.
@error: 1 = The Cancel button was pushed.
2 = The Timeout time was reached.
3 = The InputBox failed to open. This is usually caused by bad arguments.
4 = The InputBox cannot be displayed on any monitor.
5 = Invalid parameters width without height or left without top.

I must apologise not sure what you mean here. @error isn't set. I'm still lost at to what to do next, I'm going to do some more reading in the mean time so I feel stupid.

Share this post


Link to post
Share on other sites
Subz

Sorry didn't read the help correctly, here is how I would write it, you can toggle the input change $bPwdLength to True or False

;~ Toggle InputBox
;~      $bPwdLength = True - Show InputBox
;~      $bPwdLength = False - Hide InputBox (Uses $iPwdLength value as default)
Local $bPwdLength = False

Local $iPwdLength = 9
Local $sPwdLength = "Please enter a number"
If $bPwdLength Then $iPwdLength = InputBox("Test", $sPwdLength, "9")
    $iPwdLength =  StringStripWS($iPwdLength,8)
;~ Check that user has entered a valid password length
    If Not StringIsDigit($iPwdLength) Or $iPwdLength = 0 Then Exit MsgBox(48,"Error","Invalid Integer was entered" & @CRLF & "Program will now exit.")

Local $n
Local $sPwdBuff
Local $sPwdMask = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()01234567890"
;~ This creates the random password.
    For $i = 1 to $iPwdLength
        ;~ Pick a random char between 1 and the pwsMask Length
        $n = Int(Random(1, StringLen($sPwdMask)))
        ;~ Concat each char that has been picked out of pwsMask to $sPwdBuff
        $sPwdBuff &= StringMid($sPwdMask, $n, 1)
        ConsoleWrite($sPwdBuff & @CRLF)
    Next

And as @Nine mentioned you could use @error like so:

$Len =  InputBox("Test",$msgPrompt,"9","",-1,-1,Default,Default,3)
;~ Time out was reached then set the default value
If @error = 2 Then $Len = 9

 

Edited by Subz

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

  • Similar Content

    • editcheck
      By editcheck
      Hi, after years of use autoit i am tired to type all time:
      msgbox('','','Hi')
      So, wanna mod the function for set default values... or some more changes.
      where is the function?
      or there are another modes for debug messages that i do not knowed ? XD [just wanna like alert('text')]
      And is there any place for all integrates functions ?
      Thank. Sry my english =E
    • ramin92003
      By ramin92003
      Hi, 
      Is there any possibility to change the cancel button text to quit in the Inputbox?
    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
    • pixelsearch
      By pixelsearch
      Hi everybody,
      I wanted to share with you this short piece of code where InputBox will always be on top (it's important to have it on top, kind of "MsgBox style") .  It's the shortest way I found to make it happen, with few lines of code :
      Do $sNb_Quest = InputBox("Quiz", "How many questions to answer ? (1-99)", "10", " M2", _ 220, 140, Default, Default, 0, GUICreate("", 0, 0, 0, 0, Default, @SW_SHOWDEFAULT)) If @error = 1 Then MsgBox(4096, "End of script", "You choosed to Quit") Exit EndIf GUIDelete() ; place this line here, not just after InputBox, or @error will be reset to 0 $iNb_Quest = Number($sNb_Quest) Until $iNb_Quest > 0 And IsInt($iNb_Quest) = 1 MsgBox(4096, "Result", "Your choice : " & $iNb_Quest) In the precedent code, the user can't type more than 2 characters. Inputs like "0" or ".5" or "-1" will be automatically rejected, also the Input is mandatory, default is 10. The last parameter, GUICreate, is the key to have this InputBox always on top (in a quick way)

      My question is : should GUIDelete() be present in the code or can we delete that line ?
      It seems to work fine without the GUIDelete() line, but in case the loop repeats several times (because of bad inputs), then we will have several GUICreate() without a single GUIDelete() ?
      Thanks for... your input 
       
    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
×