Jump to content

How to run a non-executable?


BobbyG66
 Share

Recommended Posts

I am working on this code to start a Visual Pinball game. (vpstart.exe)

HotKeySet("{ESC}", "KillDaWabbit")

Run('"c:\emu\vp\vpinball.exe -Play Pacman.vpt"', @SW_MAXIMIZE)

While 1

Sleep(1000)

WEnd

Func KillDaWabbit()

ProcessClose("VPinball.exe")

ProcessClose("vpstart.exe")

EndFunc

Exit

The program normally runs by running vpinball.exe. Once that opens, you then have to then open the table, select it and run it. I want it to work from one script.

In windows there are icons for each game in a folder, by double clicking them the game launches automaticaly, skipping alll the front end stuff (Just what I want).

The line "c:\emu\vp\vpinball.exe -Play Pacman.vpt" works in a batch file...

Please help

Thanks

BobbyG66

Link to comment
Share on other sites

Run('"c:\emu\vp\vpinball.exe -Play Pacman.vpt"', @SW_MAXIMIZE)
You are trying to run the file "c:\emu\vp\vpinball.exe -Play Pacman.vpt" not the program "c:\emu\vp\vpinball.exe" with the arguments "-Play" and "Pacman.vpt".

By wrapping it in "" you tell windows that everything in it is one filename or one argument instead of a command line consisting of multiple parts.

Link to comment
Share on other sites

Ok, I tried this and numerous variations. Getting Error

"Incorrect number of parameters in function call"

Run("c:\emu\vp\vpinball.exe", "-Play", "Pacman.vpt", @SW_MAXIMIZE)

Is there a way to select multiple functions or arguments?

BobbyG66

Edited by BobbyG66
Link to comment
Share on other sites

  • Developers

You are missing the workdir parameter:

Run ( "filename" [, "workingdir" [, flag]] )

So try:

Run("c:\emu\vp\vpinball.exe -Play Pacman.vpt","", @SW_MAXIMIZE)

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Run("c:\emu\vp\vpinball.exe", "-Play", "Pacman.vpt", @SW_MAXIMIZE)

You're missing the difference between the parameters for the Run() function and the parameters for the program.

As the first parameter Run() requires the command line you want to run. Your command line is 'c:\emu\vp\vpinball.exe -Play Pacman.vpt'.

Usually parts of the command line are seperated by spaces. But If you need a space within one part of the command line you can wrap them in quotes ("a b").

The correct command in AutoIt would be:

Run('"c:\emu\some games\vpinball.exe" -Play "a table.vpt"', '', @SW_MAXIMIZE

(Note where I used "" to tie a part of the command line together)

Link to comment
Share on other sites

  • 1 month later...

OK, I got it working now but would like to set it up for any game using a variable.

Run('"c:\emu\some games\vpinball.exe" -Play "PacMan.vpt"', '', @SW_MAXIMIZE)

This command works but only runs the "PacMan" table.

I have a front end that will send a specific table when launching.

I tried using the variable %1 in the program but it's not working.

Any ideas? Use something other than %1?

Link to comment
Share on other sites

Easy as cake:

Inside Autoit

$sTable = '';Set here the tablename.

Run('"c:\emu\some games\vpinball.exe" -Play "' & $sTable & '"', '', @SW_MAXIMIZE)

With command line...

The command line parameters are set in $CmdLine[]

If $CmdLine[0] > 0 Then
   Run('"c:\emu\some games\vpinball.exe" -Play "' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)
EndIf

Or you can combine both ideas...

If $CmdLine[0] > 0 Then
   Run('"c:\emu\some games\vpinball.exe" -Play "' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)
Else 
$sTable = InputBox('Select tablename','Write the table you want to start')
If @error then Exit

Run('"c:\emu\some games\vpinball.exe" -Play "' & $sTable & '"', '', @SW_MAXIMIZE)

Edit fixed a little error...

Edited by ezzetabi
Link to comment
Share on other sites

Easy as cake:

Inside Autoit

$sTable = '';Set here the tablename.

Run('"c:\emu\some games\vpinball.exe" -Play "' & $sTable & '"', '', @SW_MAXIMIZE)

With command line...

The command line parameters are set in $CmdLine[]

If $CmdLine[0] > 0 Then
   Run('"c:\emu\some games\vpinball.exe" -Play "' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)
EndIf

Or you can combine both ideas...

If $CmdLine[0] > 0 Then
   Run('"c:\emu\some games\vpinball.exe" -Play "' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)
Else 
$sTable = InputBox('Select tablename','Write the table you want to start')
If @error then Exit

Run('"c:\emu\some games\vpinball.exe" -Play "' & $sTable & '"', '', @SW_MAXIMIZE)

Edit fixed a little error...

<{POST_SNAPBACK}>

Thanks!

Will give that a go...

Link to comment
Share on other sites

ezzetabi,

It worked!

I was able to just use this line without the If/Then statement

Run('"c:\emu\some games\vpinball.exe" -Play "' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)

Thanks for everyones help.

Great forum and nice people!

BobbyG66

Link to comment
Share on other sites

That'll work, you just have to be careful because it'll fall over it you run it without and command line parameters and don't have the If/Then statement to trap for it.

<{POST_SNAPBACK}>

OK THANKS.

I had to modify one switch in the command line, until I figured that out, I had removed the If/Then statement.

Now I can add back in.

Link to comment
Share on other sites

OK THANKS.

I had to modify one switch in the command line, until I figured that out, I had removed the If/Then statement.

Now I can add back in.

<{POST_SNAPBACK}>

I thought I had it working... :idiot:

The following script works for table names without spaces.

When I try to launch a table name with spaces, it does not work.

In reading the help file it says to surround the $CmdLine with double quotes.

I have tried adding in those quotes in many places around $CmdLine with no luck.

Not sure what the & is for in the function either. I tried renaming $CmdLine as a variable and plugging into the Run line without any success.

Can anyone see what is wrong?

BobbyG66

HotKeySet("{ESC}", "KillDaWabbit")

If $CmdLine[0] >0 Then

Run('"c:\vpinmame\vpinball.exe" -Play -"' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)

EndIf

While 1

Sleep(100)

WEnd

Func KillDaWabbit()

ProcessClose("VPinball.exe")

ProcessClose("pinball.exe")

ProcessClose("Autoit3.exe")

EndFunc

Exit

Edited by BobbyG66
Link to comment
Share on other sites

I think what's happening is that the command line is actually a number of commands being sent.

Can I combine the $CmdLine[]'s like this?

$table = $CmdLine[1] & $CmdLine[2] & $CmdLine[3] & $CmdLine[4]

If $CmdLine[0] >0 Then

Run('"c:\vpinmame\vpinball.exe" -Play -" $table "', '', @SW_MAXIMIZE)

EndIf

The names of the tables can very in length from one to four or five words in the title.

Let's say the title is "Attack from mars"

If there is no $CmdLine[4] will it just add zero/nothing?

I will have to try tonight when I get home...

BobbyG66

Link to comment
Share on other sites

  • Developers

$table = $CmdLine[1] & $CmdLine[2] & $CmdLine[3] & $CmdLine[4]

<{POST_SNAPBACK}>

Here you will be missing the spaces between the parameters and will give an error when you don't specify 4 parameters ...

Try using $CmdLineRaw which contains the whole commandline.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Here you will be missing the spaces between the parameters and will give an error when you don't specify 4 parameters ...

Try using $CmdLineRaw which contains the whole commandline.

<{POST_SNAPBACK}>

I actually got it working by having my frontend send the command line with quotes. Now all is good! :idiot:

Thanks for the help.

BobbyG66

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...