Jump to content

Recommended Posts

Posted

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

 

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

Posted
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

 

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

Posted (edited)

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

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
×
×
  • Create New...