kris00l Posted October 24, 2012 Posted October 24, 2012 (edited) I need to run a AutoIT exe within VBScript to pass and get value from it meaning: I have AutoIT function with accepts parameters to create two radio buttons with captions value being parameters passed and return radio button selected caption. I have created Exe and calling this exe in Vbscript as return = ObjShell.Run("cmd /c " & pathexefilename & " Radio1Value Radio2Value") If return = "Radio1Value" Then ' do something else ' do something end if AutoIT script: Func ($Option1, $Option2) ;i'm not posting all the script details here but case $msg = $Radio1 $RadioSel = $option1 case $msg = $Radio2 $RadioSel = $option2 case $msg = $OK_Btn Return $RadioSel EndFunc Edited October 24, 2012 by kris00l
stormbreaker Posted October 24, 2012 Posted October 24, 2012 See Exit() function in help-file. Now, you could do the following: 1. If someone selects radio 1 then Exit(1) 2. If someone selecs radio 2 then Exit(2) 3. Catch the exit return code with VBS. ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
kris00l Posted October 24, 2012 Author Posted October 24, 2012 (edited) 1. why not function return the value? 2. Error $cmdline Here's complete code: <job id="Z-Test"> <script language="VBScript"> Set objShell = CreateObject("Wscript.Shell") OSMig = ObjShell.Run("cmd /c C:UsersAdministratorDesktoptest.exe ""Are you migrating XP 32bit to XP 32bit?"" ""Are you migrating XP 32bit to Win 7 32bit?""") If OSMig = "Are you migrating XP 32bit to XP 32bit?" Then Msgbox "migrating XP 32bit to XP 32bit" Else Msgbox "migrating XP 32bit to Win 7 32bit" End If </script> </job> AutoIT Script - compiled to EXE as Test.exe expandcollapse popup#include <GUIConstantsEx.au3> $Return = CreateWindowOptions($CmdLine[1], $CmdLine[2]) ; errors here why Func CreateWindowOptions($Option1, $Option2) ;Initialize variables Local $GUIWidth = 300, $GUIHeight = 250 Local $Edit_1, $OK_Btn, $Cancel_Btn, $msg Local $RadioSel #forceref $Edit_1 ;Create window GUICreate("New GUI", $GUIWidth, $GUIHeight) $Radio1 = GUICtrlCreateRadio($Option1, 96, 64, 105, 41) $Radio2 = GUICtrlCreateRadio($Option2, 96, 112, 73, 25) ;Create an "OK" button $OK_Btn = GUICtrlCreateButton("OK", 72, 152, 105, 33) ;Show window/Make the window visible GUISetState(@SW_SHOW) ;Loop until: ;- user presses Esc ;- user presses Alt+F4 ;- user clicks the close button While 1 ;After every loop check if the user clicked something in the GUI window $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE Return $RadioSel ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit ;Check if user clicked on the "OK" button Case $msg = $OK_Btn MsgBox(64, "New GUI", "You clicked on the OK button! - " & $RadioSel) Return $RadioSel ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit Case $msg = $Radio1 $RadioSel = $Option1 case $msg = $Radio2 $RadioSel = $Option2 EndSelect WEnd EndFunc ;==>_Main Edited October 24, 2012 by Melba23 Added code tags
Moderators Melba23 Posted October 24, 2012 Moderators Posted October 24, 2012 kris00l,When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. Then you get the scrolling box you can now see in your post above. M23 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
kris00l Posted October 24, 2012 Author Posted October 24, 2012 Error I figured it out. You need to use $CmdLine[0] in the code. So: If $CmdLine[0] > 0 Then $Return = CreateWindowOptions($CmdLine[1], $CmdLine[2]) EndIf
kris00l Posted October 24, 2012 Author Posted October 24, 2012 (edited) kris00l, When you post code please use Code tags - put before and after your posted code. Then you get the scrolling box you can now see in your post above. M23 I'm new here I also noticed that I cannot edit my post after few mins. Is there a specific reason its locked? Thanks Edited October 24, 2012 by kris00l
Moderators Melba23 Posted October 24, 2012 Moderators Posted October 24, 2012 kris00l,After you have 5 posts, you get full "Edit" permissions - so be patient. M23 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
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