Jump to content

Insert digits automatically after selection on startup


 Share

Recommended Posts

Hi Everybody,

and thanks in advance for any help ... but most of all for being patient with a total newbie  (i'm a doctor... this is TOTALLY not my field)

I tried to find the answer in old posts ... so i beg my pardon if this is an already solved problem!

I realized this script (it's a part of it):

MouseClick("left", 419, 809, 1, 25)
MouseClick("left", 230, 720, 1, 30)
MouseClick("left", 566, 536, 2, 30)
Send("{NUMPAD1}")
Send("{NUMPAD0}")
Send("{NUMPAD0}")
Send("{NUMPAD0}")
MouseClick("left", 806, 534, 1, 25)
MouseClick("left", 673, 641, 1, 8)

 

It actually click on some buttons, double clicks on a field and insert four digits. Pressing enter afterwards.

Is there any chance to ask the user when starting up the EXE what digits to insert, and change automatically the script according to user'selection?

THANK YOU!!!!

Alessandro

DEFINITIVO.au3

Link to comment
Share on other sites

Try this?

It could probably be a lot simpler, but it works.

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $sTyped=''

GetInput()

Func GetInput()
    GUICreate(" Get user input ", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, $WS_EX_ACCEPTFILES)
    $sTyped = GUICtrlCreateInput("1,2,3,4", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)

    Local $idBtn = GUICtrlCreateButton("Okay", 40, 75, 60, 20)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn
                ExitLoop
        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "drag drop file", GUICtrlRead($sTyped)) ; just shows whats in the input
EndFunc   ;==>Example

Local $nUsrNums = GUICtrlRead($sTyped) ; put input into a variable

Local $aNumbers = StringSplit($nUsrNums,",",2) ; split text in variable into array

_ArrayDisplay($aNumbers)



Local $i = UBound($aNumbers)
ConsoleWrite("$i " & $i & @CRLF)
For $j = 0 to $i -1
    ConsoleWrite("$j " & $j & @CRLF)
    Local $ToSend = '"{NUMPAD' & $aNumbers[$j]&'}"'
    Send($ToSend) ;-- was: Send("{NUMPAD1}")
    ConsoleWrite("Sent! " & $ToSend & @CRLF)
Next

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

$sInput = InputBox("Startup Script", "Enter your numaric code")
MouseClick("left", 419, 809, 1, 25)
MouseClick("left", 230, 720, 1, 30)
MouseClick("left", 566, 536, 2, 30)
Send($sInput)
MouseClick("left", 806, 534, 1, 25)
MouseClick("left", 673, 641, 1, 8)

You can send your numbers in a single send, no need to break them apart.

This is the most simple way I can think to take what you have and prep it for user input.

A GUI would definitely be the "more professional" way IMO but before I would bother going that road I would probably get rid of all the MouseClicks() as well because that would be your first point of failure (changing resolution, position, etc)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...