Jump to content

Creating a script

Ryouichi Kiriyami
Go to solution Solved by MatthewEnderle,

Download the program called Autohotkey. A batch file won't cut it. Create a script and paste this in and run.

#SingleInstance, forceSendMode InputSetWorkingDir %A_ScriptDir%iTC_EXE = C:\Program Files (x86)\Phase Shift\phase_shift.exeiTC_Path = C:\Program Files (x86)\Phase ShiftiTC_imgName = phase_shift.exeloop {    sleep 15000 ; Check if running every 15 seconds.    Process, Exist, %iTC_imgName%    If (ErrorLevel = 0)     {     Run, %iTC_EXE%, %iTC_Path%, hide     }    Else     {        sleep 5     }}

 

for windows 7. What i want the script to do...either its a .bat or VBS or w/e it takes.

i need a script to look to see if a game is open (DWSK) and if it is. do nothing and wait.

and if the game ISNT open it needs to launch said game (DWSK) and then wait 30 seconds and run another check. then return to normal and keep that forever.

what i plan to do is make a computer a permanant game. so if someone closes out of said game. itll just reopen soon as its closed. there are ways around it yeah...but there will be no keyboard or mouse connected to it for said game. just a controller. sooo. ideas?

"1 shot 1 kill. or in my case 500 shots and a questionable death" ~ Carlos Hathcock + Ryouichi

"Because its windows... it just happens..." ~ G33k 4 L1F3

My Build....sorta. close enough http://pcpartpicker.com/p/YMG4mG

Link to comment
Share on other sites

Link to post
Share on other sites

Can you post the path to the executable, as in c:/programfiles/games/derpsimulator?

Link to comment
Share on other sites

Link to post
Share on other sites

Download the program called Autohotkey. A batch file won't cut it. Create a script and paste this in and run.

#SingleInstance, forceSendMode InputSetWorkingDir %A_ScriptDir%iTC_EXE = C:\Program Files (x86)\Phase Shift\phase_shift.exeiTC_Path = C:\Program Files (x86)\Phase ShiftiTC_imgName = phase_shift.exeloop {    sleep 15000 ; Check if running every 15 seconds.    Process, Exist, %iTC_imgName%    If (ErrorLevel = 0)     {     Run, %iTC_EXE%, %iTC_Path%, hide     }    Else     {        sleep 5     }}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Use AutoIt, Autohotkey ceased development years ago. If you want I can compile you some software that will do said task much more efficiently than scripting languages plus allow the freedom of changing the game with a configuration file. Below I compiled a quick piece of software that might work for you.

 

Download

 

Put RunGame.exe into your Windows startup folder.

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

You might need to unblock the execution of the binary by right clicking on it and going to properties (bottom of first tab unblock).

 

And then put config.ini into your home directory.

C:\Users\Opcode

From there you can edit config.ini to the path of the game that you want to run endlessly.

Link to comment
Share on other sites

Link to post
Share on other sites

Well i still want to be able to alt tab out of it when i DO hook up a keyboard to it to work on the computer if there is a problem i dont want it to take COMPLETE control. the file path will be

 

D:\Games\Phase Shift\phase_shift.exe

 

and im famillier with autohotkey..id be very comfterable using it. i use it for many scripts. just didnt know how to write one for this specific task

 

"1 shot 1 kill. or in my case 500 shots and a questionable death" ~ Carlos Hathcock + Ryouichi

"Because its windows... it just happens..." ~ G33k 4 L1F3

My Build....sorta. close enough http://pcpartpicker.com/p/YMG4mG

Link to comment
Share on other sites

Link to post
Share on other sites

Well i still want to be able to alt tab out of it when i DO hook up a keyboard to it to work on the computer if there is a problem i dont want it to take COMPLETE control. the file path will be

 

D:\Games\Phase Shift\phase_shift.exe

 

and im famillier with autohotkey..id be very comfterable using it. i use it for many scripts. just didnt know how to write one for this specific task

What I posted above should work, you can make a kill batch file if you wish to ever end the game and to keep it from running again until next reboot.

@[member=Echo] offtaskkill /f /im RunGame.exetaskkill /f /im Game.exe
Link to comment
Share on other sites

Link to post
Share on other sites

 

What I posted above should work, you can make a kill batch file if you wish to ever end the game and to keep it from running again until next reboot.

@[member='Echo'] offtaskkill /f /im RunGame.exetaskkill /f /im Game.exe

i really do appriciate the help :P i might use this for something else. but for phaseshift. ima use auto hot key. it doesnt utalize the f keys at all really. least in my control config. so i can set up stop for f codes.

 

 

Download the program called Autohotkey. A batch file won't cut it. Create a script and paste this in and run.

-snip-

im gonna edit this a little bit. but thank you very much.

 

i wanna break the loop if i press f9. its not auto forcing it to start either. im trying some  edits.

^ fck that. just made a hotkey pause the script itsself.

 

heres what i have so far

 

#SingleInstance, forceSendMode InputSetWorkingDir %Phaseshift_Loop%iTC_EXE = D:\Games\Phase Shift\phase_shift.exeiTC_Path = D:\Games\Phase Shift\iTC_imgName = phase_shift.exeloop {    sleep 30000 ; Check if running every 30 seconds.    Process, Exist, %iTC_imgName%    If (ErrorLevel = 0)     {     Run, %iTC_EXE%, %iTC_Path%, hide     }    Else     {        sleep 5     }}
Edited by colonel_mortis
Code tags

"1 shot 1 kill. or in my case 500 shots and a questionable death" ~ Carlos Hathcock + Ryouichi

"Because its windows... it just happens..." ~ G33k 4 L1F3

My Build....sorta. close enough http://pcpartpicker.com/p/YMG4mG

Link to comment
Share on other sites

Link to post
Share on other sites

Basic Power Shell script I put together in 30 seconds:

function Test-Process{    if(!(Get-Process -Name mspaint))    {        Start-Process -FilePath C:\Windows\System32\mspaint.exe        Test-Process    }     else    {        Sleep -Seconds 30        Test-Process    }}

change the Process name and the path from the ones for paint. you could easily modify this so you could pass parameters to the function.

Link to comment
Share on other sites

Link to post
Share on other sites

That all seems so complicated. Here's a .bat that will restart a program when it closes, it'll work as long as there is no special launcher for the game.

:start"path to .exe"echo restartinggoto start

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

fizzle you're awesome. but im already using auto hot key :P i need to mark this solved. but i was on a shitty 10$ flip phone...

"1 shot 1 kill. or in my case 500 shots and a questionable death" ~ Carlos Hathcock + Ryouichi

"Because its windows... it just happens..." ~ G33k 4 L1F3

My Build....sorta. close enough http://pcpartpicker.com/p/YMG4mG

Link to comment
Share on other sites

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

×