Jump to content

Running autoit executables with arguments from C#


dushkin
 Share

Recommended Posts

Hi.

I don't know if it is possible, so I am asking your help...

I would like to execute an autoit executable from some C# client.

If the autoit exe does not use arguments there is no problem.

But if It does, how can I know what are they?

Can I define them in the scripts in some kind of a meatdata and read it in my C# client?

Is there another way?

Thanks!

Link to comment
Share on other sites

  • Moderators

dushkin,

Look in the Help file under <Using AutoIt - Command Line Parameters> to find out how to recognize what parameters have been passed to to an AutoIt script/executable. :)

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

 

Link to comment
Share on other sites

Thanks M23.

I searched there. I couldn't any relevant information.

I would like to clarify my problem:

I need that the autoit scriptexe will expose the arguments it uses, so other modules, like my C# program, will be able to use them.

I would like that my client will be generic and be able to execute every exe file, but then, it needs to know the exe arguments types if exixts (string, int, etc.) to display them to the user so he can set their values.

Thanks!

Link to comment
Share on other sites

If you are asking how do you know what parameters an exe takes, then apart from you really ought to know them

since you wrote the script, I think it's usual practice to make a 'usage' function to call when incorrect params are

entered.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@Duschkin, i made a test script demonstrating how autoit recognize the the passed parameters

Switch $cmdline[0]
Case 1
MsgBox("","","was passed " &amp; $cmdline[0] &amp; " parameter to the script",3)
IniWrite(".parameters passed.txt","information passed","1º parameter (teste 1)",$cmdline[1])
FileWriteLine(".parameters passed.txt","")
Case 2
MsgBox("","","were passed " &amp; $cmdline[0] &amp; " parameters to the script",3)
IniWrite(".parameters passed.txt","information passed","1º parameter (teste 2)",$cmdline[1])
IniWrite(".parameters passed.txt","information passed","2º parameter (teste 2)",$cmdline[2])
FileWriteLine(".parameters passed.txt","")
Case 3
MsgBox("","","were passed " &amp; $cmdline[0] &amp; " parameters to the script",3)
IniWrite(".parameters passed.txt","information passed","1º parameter (teste 3)",$cmdline[1])
IniWrite(".parameters passed.txt","information passed","2º parameter (teste 3)",$cmdline[2])
IniWrite(".parameters passed.txt","information passed","3º parameter (teste 3)",$cmdline[3])
FileWriteLine(".parameters passed.txt","")
case else
MsgBox("","","There was no parameter passed to the script.",3)
IniWrite(".parameters passed.txt","information passed","Nenhum parameter","0")
FileWriteLine(".parameters passed.txt","")
EndSwitch
exit

Instructions:

- Compile the script and let this same folder

- Create 4 bat files with the content below

1st Bat (With no parameter)

@echo off

start == .teste.exe

2nd Bat (passing a parameter)

@echo off

start == .teste.exe teste1

3rd Bat (passing 2 parameters)

@echo off

start == .teste.exe teste1 teste2

3rd Bat (passing 3 parameters)

@echo off

start == .teste.exe teste1 teste2 teste3

- Run each bat file you created and see the recorded file parameters intormações passados.txt

Edited by Belini
Link to comment
Share on other sites

Of course I know the parameters of my scripts.

But I won't necessarily know the parameters of the scripts others wrote :-)

My aim is to select an autoit exe file in file open browser and then display the relevant GUI for each parameter it requires.

If it will not be possible I will have to think of something less generic, but I stillwould prefer this way which is transparent to the user.

Link to comment
Share on other sites

Thanks Belini. But I don't need the script to recognize the parameters passed to it.

I need that a C# program will be able to know which parameters an autoit exe file needs before it (the C# client) runs it using Process.Start() for example .

Link to comment
Share on other sites

Was it?

ShellExecute("teste.exe", "test1 test2 test3",@ScriptDir)

Edited by Belini
Link to comment
Share on other sites

Belini,

I would like, in my C# ui client, to select a file using a file open dialog, in my case and autoit script exe file, and by selecting it, automatically reveal it's list of arguments it accepts, so I can display this list to the end user. Then he will give them values, and with those values I will be able to use ShellExecute.

Link to comment
Share on other sites

  • Moderators

dushkin,

select a file using a file open dialog, in my case and autoit script exe file, and by selecting it, automatically reveal it's list of arguments it accepts, so I can display this list to the end user

How on earth do you expect to be able to do this in any language? Simply selecting a random executable file does not expose the arguments it takes! :)

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

 

Link to comment
Share on other sites

:-)

I didn't say it is possible. I asked if it is possible. It seems to be reasonable to me because it is obvious that the exe file holds this information somewhere.

Also I thought that maybe we can add metadata to the script, just as html files that have metadata that the search engines uses.

Link to comment
Share on other sites

Well there you have it, it is not possible.

Normal procedure to find and applications command line parameters is to read it's documentation, or ask its author.

Any other possible methods are hacks and I doubt they are allowed to be discussed here.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

dushkin,

You could add something about the required parameters in the resource table of a compiled file and then use a script to read it. But that would require the author to add the metadata and the use of a script to extract it. It would not be available on simple selection of any old exe file. :)

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...