Jump to content

Automating Software Activation Screen


Stugist
 Share

Recommended Posts

Hello all.

I'm relatively new to the AutoIt scripting world. A bit a background: I work for a K12 school district imaging machines and deploying software. IE, I script. A lot. :D I always know exactly what I want to do, however syntax is never my strong suite. Asking for some newbish help here.

Problem: I want to automate a software activation screen for a particular program (VCarve Pro by Vectric). The reason I want to do this is to automate the deployment of this software and reduce the "hand-on" time for my techs responsible for making it happen. Here is my current code:

; Script to activate VCarve Pro
; *Run this script immediately after installing VCarve Pro 8*

WinActivate ("VCarve Pro - License Information")

If @ComputerName = "KJH*" Then
    Global $RegUserName = "Registered Name 1"
    Global $LicNum = "License Key 1"
ElseIf @ComputerName = "SJH*" Then
    Global $RegUserName = "Registered Name 2"
    Global $LicNum = "License Key 2"
EndIf

Send ($RegUserName)
Send ("{TAB}")
Send ("{TAB}")
Send ($LicNum)
Send ("{ENTER}")

First line is making sure the license window (attached in screenshot) is active on the desktop.

The following function (I think?) -should- query the computer name of the machine this is being run on. If the name of the computer starts with "KJH", then it will set the two needed variables accordingly. Same deal with the next function. This is where I'm lost. I have no idea if I can wildcard the @ComputerName bit. Generally, I'm lost on it all. I -think- I have the right idea. When I try to run the script, I get an error that says I'm trying to use an undeclared variable.

Any help would be appreciated!

Capture.JPG

Edited by Stugist
Added info
Link to comment
Share on other sites

  • Moderators

Hi, @Stugist welcome to the forum. Can you please post the output from the AutoIt Window Info Tool (in the same directory where you installed AutoIt) when you drag it over that application window? You may be able to skip all the Sends and make things easier on yourself.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

>>>> Window <<<<
Title:    VCarve Pro - License Information
Class:    #32770
Position:    788, 318
Size:    521, 308
Style:    0x94C800CE
ExStyle:    0x00010109
Handle:    0x00060246

>>>> Control <<<<
Class:    
Instance:    
ClassnameNN:    
Name:    
Advanced (Class):    
ID:    
Text:    
Position:    
Size:    
ControlClick Coords:    
Style:    
ExStyle:    
Handle:    

>>>> Mouse <<<<
Position:    968, 328
Cursor ID:    0
Color:    0xD4D0C8

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Paste license code from clipboard
Enter license code manually
OK
Cancel
Registered User Name:
License Code:


>>>> Hidden Text <<<<

Link to comment
Share on other sites

  • Moderators

When you hover the Window Info icon right over the input box where you would put in the Registered User Name, what is returned?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

So you could do something like this, rather than Send (which can be unreliable)

WinWait("VCarve Pro - License Information", "Paste license code")
ControlSend("VCarve Pro - License Information", "Paste license code", "Edit1", $RegUserName)

Take a look at the Control commands in the help file. The benefits include being able to interact with the specific window you want as long as it exists; it does not have to be active (or even visible). Send, on the other hand, is something of a shotgun approach.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

So you could do something like this, rather than Send (which can be unreliable)

WinWait("VCarve Pro - License Information", "Paste license code")
ControlSend("VCarve Pro - License Information", "Paste license code", "Edit1", $RegUserName)

Take a look at the Control commands in the help file. The benefits include being able to interact with the specific window you want as long as it exists; it does not have to be active (or even visible). Send, on the other hand, is something of a shotgun approach.

I'm still getting an error on run, though. I'll compile the script to run as an EXE, but when I try to run it I will get an undeclared variable error.

 

Here is the revised script. Note the error occurs on line 7:

; Script to activate VCarve Pro
; *Run this script immediately after installing VCarve Pro 8*

WinWait("VCarve Pro - License Information")

If StringLeft(@ComputerName,3) = "KJH" Then
    Local $RegUserName = "Registered Name 1"
    Local $LicNum = "License Key 1"
ElseIf StringLeft(@ComputerName,3) = "SJH" Then
    Local $RegUserName = "Registered Name 2"
    Local $LicNum = "License Key 2"
EndIf

ControlSend("VCarve Pro - License Information", "Registered User Name", "Edit1", $RegUserName)
ControlSend("VCarve Pro - License Information", "Paste license code from clipboard", "Edit2", $LicNum)

 

Edited by Stugist
Link to comment
Share on other sites

Yeah you might want an "Else" line as a failsafe so that you always have a path for the script to take.

 

If StringLeft(@ComputerName,3) = "KJH" Then
    Local $RegUserName = "Registered Name 1"
    Local $LicNum = "License Key 1"
ElseIf StringLeft(@ComputerName,3) = "SJH" Then
    Local $RegUserName = "Registered Name 2"
    Local $LicNum = "License Key 2"
Else
    MsgBox(0, "", "Computer Name Does Not Match Standard")
    WinClose("VCarve Pro - License Information", "")
    Exit
EndIf

Something like that, up to you what should be there.

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