TheLandYacht Posted August 23, 2014 Posted August 23, 2014 So, what I'm trying to do is open a program (exe) with command-line arguments, which...if I'm understanding the helpfile...means I need to use ShellExecute instead of Run? The command line I need to use is... "C:Program FilesMyPhoneExplorerMyPhoneExplorer.exe" action=dial number=012345678 But with a simple text-input box to replace the number, so it asks for user (that's me) input & fills in the line with my result. How hard is something like this?
Moderators Melba23 Posted August 23, 2014 Moderators Posted August 23, 2014 TheLandYacht, Quote How hard is something like this?Very easy - give it a try. I would suggest using InputBox to get the user input and then concatenating the returned data to the basic string. Take care with spaces and quotes though - that is where most such strings fail. Use ConsoleWrite or MsgBox to check that the result is correct before trying to ShellExecute it. Come back if you run into problems - but try and produce something yourself first. 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: Reveal hidden contents 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
TheLandYacht Posted August 23, 2014 Author Posted August 23, 2014 (edited) OK. First attempt met with some success, but ultimate failure. Here's what I got. I copied straight from the InputBox & ConsoleWrite examples for most of this (with some modification) The first line that's commented out at the top, I confirmed working just by dialing my own number...then commented it out. The InputBox looks like it's working, I just had it spit out the result to the ConsoleWrite (which I can read at the bottom of SciTe). Then comes the part where I'm having a bit of trouble. If ALL I include is the result of the InputBox, it spits it out just as expected. But if I try to add the rest in front of it, it errors out. Not just spitting out the wrong results, but errors out before I see an InputBox pop up. What am I doing wrong here? ;~ShellExecute ( "C:\Program Files (x86)\MyPhoneExplorer\MyPhoneExplorer.exe", "action=dial number=51261234567" ) #include <MsgBoxConstants.au3> Example() Func Example() ; Places the input box in the center of the screen displaying the characters as they ; are typed. Local $sAnswer = InputBox("Phone#", "Phone Number?", "512", "", _ - 1, -1, 512, 354) ; Display the result. ConsoleWrite ( $sAnswer & @CRLF) ;-THIS ONE WORKS ;-ConsoleWrite ( "C:\Program Files (x86)\MyPhoneExplorer\MyPhoneExplorer.exe", "action=dial number= $sAnswer & @CRLF) ;-ConsoleWrite ( "C:\Program Files (x86)\MyPhoneExplorer\MyPhoneExplorer.exe", "action=dial number=" $sAnswer & @CRLF) EndFunc Edited August 23, 2014 by TheLandYacht
Moderators Melba23 Posted August 23, 2014 Moderators Posted August 23, 2014 TheLandYacht,You need another concatenation operator to join the input and the string: ConsoleWrite ( "C:\Program Files (x86)\MyPhoneExplorer\MyPhoneExplorer.exe", "action=dial number=" & $sAnswer & @CRLF)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: Reveal hidden contents 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
TheLandYacht Posted August 23, 2014 Author Posted August 23, 2014 OK. I just copied your line verbatim into my script (after commenting out the one that DOES work)...and got... error: ConsoleWrite() [built-in] called with wrong number of args.
Moderators Melba23 Posted August 23, 2014 Moderators Posted August 23, 2014 TheLandYacht,I did tell you that you needed to be careful with quotes! ConsoleWrite("C:\Program Files (x86)\MyPhoneExplorer\MyPhoneExplorer.exe, action=dial number=" & $sAnswer & @CRLF)Now it will display as a single string.If that looks right, then when you actually use the value with ShellExecute you will need:ShellExecute("C:\Program Files (x86)\MyPhoneExplorer\MyPhoneExplorer.exe", "action=dial number=" & $sAnswer)to split it into the 2 required parameters.Command lines are always fun. 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: Reveal hidden contents 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
TheLandYacht Posted August 23, 2014 Author Posted August 23, 2014 That worked perfectly. And yes, you did mention watching spacing. I've just seen that the majority of examples I've viewed include a space between the command and the (, as well as another space inside the ( in most cases...so I thought that was the norm. There was another way to do it (that will probably end up being easier in the long run), but I figured I'd tackle this method too...just so I could say I had understood how/why this works. The other method includes sending a ControlSend to the program, followed by the results of the above InputBox. From a programmer/coder perspective, is there one way or the other that's considered more "elegant"?
Moderators Melba23 Posted August 23, 2014 Moderators Posted August 23, 2014 TheLandYacht,If it works - it works. Personally I would go for the ShellExecute method, but that is purely my preference. 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: Reveal hidden contents 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
TheLandYacht Posted August 23, 2014 Author Posted August 23, 2014 Community here's awesome! Thanks again for your help, M.
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