Jump to content
Sign in to follow this  
TheLandYacht

ShellExecute help, simple GUI text-input box.

Recommended Posts

TheLandYacht

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?

Share this post


Link to post
Share on other sites
Melba23

TheLandYacht,

 

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheLandYacht

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 by TheLandYacht

Share this post


Link to post
Share on other sites
Melba23

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheLandYacht

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.

Share this post


Link to post
Share on other sites
Melba23

TheLandYacht,

I did tell you that you needed to be careful with quotes! :D

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheLandYacht

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"?

Share this post


Link to post
Share on other sites
Melba23

TheLandYacht,

If it works - it works. Personally I would go for the ShellExecute method, but that is purely my preference. :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheLandYacht

Community here's awesome!  Thanks again for your help, M.

Share this post


Link to post
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
Sign in to follow this  

×