BobbyG66 Posted November 23, 2004 Share Posted November 23, 2004 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 More sharing options...
sugi Posted November 23, 2004 Share Posted November 23, 2004 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 More sharing options...
BobbyG66 Posted November 23, 2004 Author Share Posted November 23, 2004 (edited) 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 November 23, 2004 by BobbyG66 Link to comment Share on other sites More sharing options...
Developers Jos Posted November 23, 2004 Developers Share Posted November 23, 2004 (edited) You are missing the workdir parameter:Run ( "filename" [, "workingdir" [, flag]] )So try:Run("c:\emu\vp\vpinball.exe -Play Pacman.vpt","", @SW_MAXIMIZE) Edited November 23, 2004 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 More sharing options...
sugi Posted November 23, 2004 Share Posted November 23, 2004 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 More sharing options...
BobbyG66 Posted November 23, 2004 Author Share Posted November 23, 2004 Thank Sugi! It worked. The other problem I had, which I just figured out was that the .VPT files were not in the same directory as vpinball.exe. Thanks for everyones help and have a great holiday! BobbyG66 Link to comment Share on other sites More sharing options...
BobbyG66 Posted January 4, 2005 Author Share Posted January 4, 2005 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 More sharing options...
ezzetabi Posted January 4, 2005 Share Posted January 4, 2005 (edited) 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 January 4, 2005 by ezzetabi Link to comment Share on other sites More sharing options...
BobbyG66 Posted January 4, 2005 Author Share Posted January 4, 2005 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) EndIfOr 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 More sharing options...
BobbyG66 Posted January 5, 2005 Author Share Posted January 5, 2005 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 More sharing options...
Chris_1013 Posted January 5, 2005 Share Posted January 5, 2005 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. Link to comment Share on other sites More sharing options...
BobbyG66 Posted January 5, 2005 Author Share Posted January 5, 2005 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 More sharing options...
BobbyG66 Posted January 7, 2005 Author Share Posted January 7, 2005 (edited) 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... 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?BobbyG66HotKeySet("{ESC}", "KillDaWabbit")If $CmdLine[0] >0 ThenRun('"c:\vpinmame\vpinball.exe" -Play -"' & $CmdLine[1] & '"', '', @SW_MAXIMIZE)EndIfWhile 1 Sleep(100)WEndFunc KillDaWabbit() ProcessClose("VPinball.exe") ProcessClose("pinball.exe") ProcessClose("Autoit3.exe")EndFuncExit Edited January 7, 2005 by BobbyG66 Link to comment Share on other sites More sharing options...
BobbyG66 Posted January 7, 2005 Author Share Posted January 7, 2005 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 ThenRun('"c:\vpinmame\vpinball.exe" -Play -" $table "', '', @SW_MAXIMIZE)EndIfThe 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 More sharing options...
Developers Jos Posted January 7, 2005 Developers Share Posted January 7, 2005 $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 More sharing options...
BobbyG66 Posted January 8, 2005 Author Share Posted January 8, 2005 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! Thanks for the help.BobbyG66 Link to comment Share on other sites More sharing options...
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