Stugist Posted October 20, 2015 Share Posted October 20, 2015 (edited) 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. 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! Edited October 20, 2015 by Stugist Added info Link to comment Share on other sites More sharing options...
MuffinMan Posted October 20, 2015 Share Posted October 20, 2015 This should work for you...If StringLeft(@ComputerName,3) = "KJH" Then Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 20, 2015 Moderators Share Posted October 20, 2015 (edited) 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 October 20, 2015 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 More sharing options...
MuffinMan Posted October 20, 2015 Share Posted October 20, 2015 This should work for you...If StringLeft(@ComputerName,3) = "KJH" Then Link to comment Share on other sites More sharing options...
Stugist Posted October 20, 2015 Author Share Posted October 20, 2015 >>>> Window <<<<Title: VCarve Pro - License InformationClass: #32770Position: 788, 318Size: 521, 308Style: 0x94C800CEExStyle: 0x00010109Handle: 0x00060246>>>> Control <<<<Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<<Position: 968, 328Cursor ID: 0Color: 0xD4D0C8>>>> StatusBar <<<<>>>> ToolsBar <<<<>>>> Visible Text <<<<Paste license code from clipboardEnter license code manuallyOKCancelRegistered User Name:License Code:>>>> Hidden Text <<<< Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 20, 2015 Moderators Share Posted October 20, 2015 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 More sharing options...
Stugist Posted October 20, 2015 Author Share Posted October 20, 2015 Class: EditInstance: 1 Is this the information you need? I'm afraid I don't quite follow otherwise. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 20, 2015 Moderators Share Posted October 20, 2015 (edited) 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 October 20, 2015 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 More sharing options...
Stugist Posted October 20, 2015 Author Share Posted October 20, 2015 (edited) 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 October 20, 2015 by Stugist Link to comment Share on other sites More sharing options...
Stugist Posted October 20, 2015 Author Share Posted October 20, 2015 Well I'm an idiot. I just realized the machine I was testing this on did not fit the @ComputerName criteria specified in this script. D'oh!Changed one of the lines, testing now successful. Will work on the production script and test that. Thanks for the help guys! JohnOne 1 Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted October 20, 2015 Share Posted October 20, 2015 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 EndIfSomething like that, up to you what should be there. Link to comment Share on other sites More sharing options...
Bert Posted October 21, 2015 Share Posted October 21, 2015 two other suggestions1. Does the app support command line switches for setup?2. Have you looked at the Vollatran project? (link in my signature) You may find it to be helpful for your techs. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now