Jump to content
Ackerz

Automated msgbox with input box

Recommended Posts

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

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

    • By robertocm
      I'm trying to use some inputboxes as radio buttons.
      This code seems to work ok, but don't know if there's is a better 'option'
      #include <GUIConstantsEx.au3> #include <GuiConstants.au3> GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Global $aInput[4] $hGUI = GUICreate("Test", 500, 500) $aInput[0] = GUICtrlCreateInput("Some text 1a", 10, 10, 200, 24) $aInput[1] = GUICtrlCreateInput("Some text 1b", 10, 40, 200, 24) $aInput[2] = GUICtrlCreateInput("Some text 2a", 10, 80, 200, 24) $aInput[3] = GUICtrlCreateInput("Some text 2b", 10, 110, 200, 24) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) ; high word Local $nID = BitAND($wParam, 0xFFFF) ; low word Local $hCtrl = $lParam Switch $nID Case $aInput[0] Switch $nNotifyCode Case $EN_SETFOCUS GUICtrlSetBkColor($aInput[0], 0x98FB98) GUICtrlSetBkColor($aInput[1], 0xD3D3D3) EndSwitch Case $aInput[1] Switch $nNotifyCode Case $EN_SETFOCUS GUICtrlSetBkColor($aInput[0], 0xD3D3D3) GUICtrlSetBkColor($aInput[1], 0x98FB98) EndSwitch Case $aInput[2] Switch $nNotifyCode Case $EN_SETFOCUS GUICtrlSetBkColor($aInput[2], 0x98FB98) GUICtrlSetBkColor($aInput[3], 0xD3D3D3) EndSwitch Case $aInput[3] Switch $nNotifyCode Case $EN_SETFOCUS GUICtrlSetBkColor($aInput[2], 0xD3D3D3) GUICtrlSetBkColor($aInput[3], 0x98FB98) EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Would you recommend using _WinAPI_GetFocus instead?
       
       
      Thanks,
       
    • By matwachich
      HI everybody! It's been a (very) long time since I posted something useful!
      Here I come with a new functions that I needed in a project that needs many different forms to insert different data into a database. Instead of creating a different Koda form for each data type, I decided to create this function, inspired by this one (from the excellent IUP GUI library).
      To create an input dialog, you first must create a JSON definition of this dialog. Simple example of a login form:
      { title: "Dialog Title", controls: [ {type:"label", value:"Please login"}, {type:"input", id:"user", label:"User name"}, {type:"input", id:"pass", label:"Password", style:$ES_PASSWORD}, {type:"check", id:"remember", label:"Remember me", value:true} ] } Then pass it to the advInputBox function:
      #include "advInputBox.au3" Dim $oRet = advInputBox($sJSON) If @error Then MsgBox(64, "Example1", "Dialog canceled") Else MsgBox(64, "Example1", "Return: " & Json_Encode($oRet, 128)) ; you can access individual values by ids: ; Json_ObjGet($oRet, "username") ; Json_ObjGet($oRet, "password") ; Json_ObjGet($oRet, "remember") EndIf And you will get an InputBox like this one:

      The code is on GutHub
      Enjoy!
       
    • By lee321987
      Sometimes when I call several MsgBox's they start popping up under other windows, which the requires ALT + TAB or click the taskbar icon.
      I just wanted to share this workaround:
      Just add a simple GUI in your program:
      #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 1, 1, 0, 0) GUISetState(@SW_SHOW) The GUI window size here is 1x1 so it will be nearly invisible, and at the top-left of your screen.
      It seems as long as that GUI is there all MsgBox's appear on top!
      I only tend to create several MsgBox's in a row when I'm actually writing and testing scripts, so the GUI being there is no big deal (I just remove/comment the GUI creation right before I build the .EXE).
      Have a great day!!!
       
       
    • 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
    • By ramin92003
      Hi, 
      Is there any possibility to change the cancel button text to quit in the Inputbox?
×
×
  • Create New...