joeloyzaga Posted November 1, 2013 Share Posted November 1, 2013 using the help I can call this script(see below) : like this from QTP (Quick test professional - automation tool) Set oAutoIt = CreateObject("AutoItX3.Control") oAutoIt.Run("C:PWCOnlineQTPtraytip.exe") Call ("traytipme, "This is a title", "This is a message") Func traytipme($param1, $param2) TrayTip($param1 & @CRLF , $param2, 5, 1) Sleep(5000) EndFunc but what I want to do is call it with parameters so that the autoit script (which needs changing and I don 't know how to do this) so I can send the values that i want to correspond to "This is a title", "This is a message" I'll also need to change my Run statement to have 2 paramaters - I guess it will be oAutoIt.Run("C:PWCOnlineQTPtraytip.exe ""This is a TITLE"" ""This is a message"") But I'm not sure can anyone help me? Thanks Joe Link to comment Share on other sites More sharing options...
orbs Posted November 1, 2013 Share Posted November 1, 2013 AutoIt easily supports command line parameters - search CmdLine in the help. as for the QTP syntax - you'll have to consult QTP help or forum. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
joeloyzaga Posted November 1, 2013 Author Share Posted November 1, 2013 searched the help in autoit and cannot find CmdLine explanation that I can understand. As I am unsure that my autoit script is correct I cannot understand how my script would work with the cmdline Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 1, 2013 Moderators Share Posted November 1, 2013 joeloyzaga,AutoIt has an internal array $CmdLine which always exists so there is never a problem accessing it. The [0] element holds the number of command line parameters used to call the script - it will be set to 0 if there were none. To access the parameters just loop through the $CmdLine array from 1 to the value in the [0] element. Clear enough?M23P.S. This is the rewrite in the current Beta Help file:Command Line ParametersPassing command line parameters to your own executable is achievable in AutoIt. Passed commandline parameters can be viewed by using the constant variables $CmdLine and $CmdLineRaw. Assigning these variables with new data will cause AutoIt to return an error, as these cannot be changed during the script's execution. Note that both variables exist whether commandline parameters are passed or not.The special array $CmdLine is initialized at the start of the script with the command line parameters passed to your AutoIt script. If running your script instead of the executable, then the ScriptName.au3 willl be ignored as a parameter.If you're passing strings with spaces, then you will need to escape these using "double quotes" in your commandline string.$CmdLine[0] ; Contains the total number of items in the array. $CmdLine[1] ; The first parameter. $CmdLine[2] ; The second parameter. ... $CmdLine[nth] ; The nth parameter e.g. 10 if the array contains 10 items.So if you were to run your script directly using AutoIt3.exe:AutoIt3.exe myScript.au3 param1 "This is a string parameter" 99 $CmdLine[0] ; This contains 3 parameters. $CmdLine[1] ; This contains param1 and not myScript.au3 as this is ignored when running non-compiled. $CmdLine[2] ; This contains This is a string parameter. $CmdLine[3] ; This contains 99. $CmdLineRaw ; This contains myScript.au3 param1 "This is a string parameter" 99.So if you were to use the compiled executable by passing commandline parameters:myProg.exe param1 "This is a string parameter" 99 $CmdLine[0] ; This contains 3 parameters. $CmdLine[1] ; This contains param1. $CmdLine[2] ; This contains This is a string parameter. $CmdLine[3] ; This contains 99.Note: A maximum of 63 parameters can be returned by the array $CmdLine[]. If you would like to see the entire commandline string passed to an AutoIt executable, then use $CmdLineRaw for the entire parameter string.#include <WinAPIShPath.au3> #include <Array.au3> ; An alternative to the limitation of $CmdLine[] only being able to return a maximum of 63 parameters. Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw) _ArrayDisplay($aCmdLine) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Gianni Posted November 1, 2013 Share Posted November 1, 2013 to make use in your case of what Melba23 clearly explained, try to compile this simple script If @Compiled Then If $CmdLine[0] = 2 Then ; are 2 parameters passed to the executable? TrayTip($CmdLine[1], $CmdLine[2], 5, 1) Sleep(5000) Else MsgBox(0, "debug", "wrong nr. of parameters") EndIf Else MsgBox(0, "debug", "scripr must be compiled") EndIf then execute it from a dos prompt passing 2 parameters example: script.exe Hello Welcome a tooltip should appear with the 2 parameters displayed Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
junkew Posted November 1, 2013 Share Posted November 1, 2013 Why do you want to use QTP in combination with AutoIT? Both tools are in many ways comparable (QTP has a nicer UI and IDE compared to AutoiIT) But I feel regarding recognizing objects AutoIT comes close to QTP With some additional UDF like '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> and IE.UDF You can do the same things as in QTP FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
joeloyzaga Posted November 1, 2013 Author Share Posted November 1, 2013 junkew - its themanagement reporting that i have coded that makes qtp the winner here - and I've got a readymade framework Link to comment Share on other sites More sharing options...
joeloyzaga Posted November 1, 2013 Author Share Posted November 1, 2013 melba 23 - how does my script as supplied work with this ? is the script right or does it need changing? Link to comment Share on other sites More sharing options...
joeloyzaga Posted November 1, 2013 Author Share Posted November 1, 2013 melba 23 - how does my script as supplied work with this ? is the script right or does it need changing? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2013 Moderators Share Posted November 2, 2013 joeloyzaga,I do not use AutoItX so this is a complete WAG. From QTP:oAutoIt.Run("C:\PWCOnlineQTP\traytip.exe param1 param2")Then in AutoIt; Check there are the correct number of parameters If $CmdLine[0] = 2 Then ; No need to use "Call" - just name the function and pass the parameters traytipme($CmdLine[1], $CmdLine[2]) EndIf Func traytipme($param1, $param2) TrayTip($param1 & @CRLF, $param2, 5, 1) Sleep(5000) EndFuncTry that and see if it works. M23P.S. WAG - Wild Ass Guess! joeloyzaga 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Solution MHz Posted November 2, 2013 Solution Share Posted November 2, 2013 I'll also need to change my Run statement to have 2 paramaters - I guess it will be oAutoIt.Run("C:PWCOnlineQTPtraytip.exe ""This is a TITLE"" ""This is a message"") So this is VBS in QTP? If so then double up the double quotes and use braces only if you retrieve the return value. Try this line oAutoIt.Run """C:\PWCOnlineQTP\traytip.exe"" ""This is a TITLE"" ""This is a message""" Link to comment Share on other sites More sharing options...
joeloyzaga Posted November 3, 2013 Author Share Posted November 3, 2013 Thanks Guys its all working great - Melba23 - you have been a great help especially!!!!! Link to comment Share on other sites More sharing options...
Mahesh123 Posted May 8, 2017 Share Posted May 8, 2017 Hi, In continuation with this script. I have the following problem Desperately looking for a solution here. I have the following script in UFT which is working fine. However I want to substitute this hard coded parameter by variables rpdate & date. I have tried with lot of options here. but not able to call the autoit exe file. Dim rpdateDim LegalEntity LegalEntity = 36004367 rpdate = "28-02-2017"'Legal_entity_Id = "36000586" path = "H:\Sprint\Automation\Corepautomate.exe"Set oAutoIt = CreateObject("AutoItX3.Control") oAutoIt.Run("H:\Sprint\Automation\Corepautomate.exe 28-02-2017 36004367") The autoit script is which is also working fine. If $CmdLine[0] = 2 Then ; No need to use "Call" - just name the function and pass the parameters corep_reports($CmdLine[1], $CmdLine[2]) EndIf Func corep_reports($rpdate, $legalentity) ------------------------------ ------------------------- EndFunc Link to comment Share on other sites More sharing options...
junkew Posted May 9, 2017 Share Posted May 9, 2017 Why do you need AutoIt in between as you can do this from hp uft directly Anyway this should work vSpace=chr(32) RunStr="H:\Sprint\Automation\Corepautomate.exe" & vSpace Runstr=runstr & rpdate & vspace & LegalEntity oAutoIt.Run(runstr) FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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