Jump to content

Automate software install - serial number entry step


DKC
 Share

Recommended Posts

Hi folks. New AutoIt user here. I'm a decent scripter, pretty saavy.

I like this application and look forward to using it extensively.

Have a question. I automating this software that has to be installed on many many PCs.

The install wizard has a window that looks like the attachment. The username slot is prefilled, which is fine.

But it asks the user to enter the serial number as 4 groups of 5 letters or numbers again per the screenshot.

I've got the serials as a list of 20 character strings in a text file.

What I'd like is that the script ask the user for the serial number when it encounters this window, allow the user to paste in the 20 character string, and then the script parses the 20 digits into their 4 5-character groups, pastes then into the boxes, and clicks next below.

I don't exactly know how to do this and I've been reading webpages and documentation but still am very shaky. I couldn't find something appropriate in the examples forum either.

Obviously it'd be cool if I didn't have to paste in toe 20-character string and it could just fetch it from the text file, but That may be asking too much.

Thanks in advance for any help.

post-43566-1228332125_thumb.jpg

Link to comment
Share on other sites

$file = FileOpen("file.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$serial = FileRead($file); or FileReadLine
FileClose($file)


For $i = 1 to 4
    $numbers = StringLeft($serial, 5)
    ConsoleWrite($numbers &@CR); replace with ControlSend() to make the installation invisible.
    $serial = StringTrimLeft($serial, 5)
Next

or take a look at InputBox() to prompt the user for the serial.

For rest of the installation see Tutorial - WinZip

Edited by Pain
Link to comment
Share on other sites

$file = FileOpen("file.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$serial = FileRead($file); or FileReadLine
FileClose($file)


For $i = 1 to 4
    $numbers = StringLeft($serial, 5)
    ConsoleWrite($numbers &@CR); replace with ControlSend() to make the installation invisible.
    $serial = StringTrimLeft($serial, 5)
Next

or take a look at InputBox() to prompt the user for the serial.

For rest of the installation see Tutorial - WinZip

Thanks man.

The first part of the above code looks at the text file with the codes?

Now that I think about it, that may not be the best option as each serial can only be used once, and the logic would have to know to use the next code in sequence. So It may be easier to simply use a input box to have the user paste in the 20 characters.

The actual parsing of the 20 characters into the 4 5-character boxes starts at the "For $1 = 1 to 4" line correct?

Can you explain where I need to alter the code above for my installation?

The input box code would look like this:

InputBox ("serial", "Paste Serial Here" [, "" ])

How do I then modify your code above to grab the 20 characters from the input box named serial?

Thank you again.

Link to comment
Share on other sites

Just the splitting and comtrolsend part:

#include <array.au3>
$sInput = "0123456789abcdefghij"
$aInput = StringRegExp($sInput,"(?:(.{5}))(?:(.{5}))(?:(.{5}))(?:(.{5}))",1)
_ArrayDisplay($aInput)
; get the controlids with the AutoIt wininfo tool
ControlSend("wintitle","","controlid1",$aInput[0])
ControlSend("wintitle","","controlid2",$aInput[1])
ControlSend("wintitle","","controlid3",$aInput[2])
ControlSend("wintitle","","controlid4",$aInput[3])

I see the first line references array.au3

Is this another script I should create?

I still would need to setup the InputBox to pipe the serial inputted by the user into this function, correct?

Link to comment
Share on other sites

I see the first line references array.au3

Is this another script I should create?

I still would need to setup the InputBox to pipe the serial inputted by the user into this function, correct?

Hi,

Array.au3 is an include so if you've no error that's because it exists

all includes files are in autoit3\Includes\ and in includes you have speciales functions and if you call it, all functions of it will be add to your script

Link to comment
Share on other sites

#include <array.au3>; delete this line, if _arraydisplay not wanted
Do
    $sInput = InputBox("serial", "Paste Serial Here", "", " M20")
Until StringLen($sInput) = 20
$aInput = StringRegExp($sInput, "(?:(.{0,5}))(?:(.{0,5}))(?:(.{0,5}))(?:(.{0,5}))", 1)
_ArrayDisplay($aInput);  delete this line, if _arraydisplay not wanted
; get the controlids with the AutoIt wininfo tool
ControlSend("wintitle", "", "controlid1", $aInput[0])
ControlSend("wintitle", "", "controlid2", $aInput[1])
ControlSend("wintitle", "", "controlid3", $aInput[2])
ControlSend("wintitle", "", "controlid4", $aInput[3])

Hubertus, this worked like a charm. I understood what it did and after reading up on ControlSend, I'm in a better way.

Thanks for everyone's help.

Link to comment
Share on other sites

My 2 cents on serial numbers:

Instead of having pre-defined serials and search that long list for a match ... why not use an algorythm and check the serial against that algorythm? If it matches then it's OK and it's a genuine serial - if not, then it's a fake ...

You can create a simple algorythm this way:

example:

-1st character is random (a-g)

- 2nd char is always a number between 6 and 9

- the 3rd character is obtained from 1st character ASCII code +5

- the 4th character is obtained by adding 2nd and 3rd character and dividing the number by 2

- the 5th character is always a number between 0 and 4

... and so on ... you can add as many rules as you want to this algorythm

This way you don't need any serial number database.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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