Jump to content

Run script when launching/closing .exe

Stahlmann

Hello good people,

 

i really don't know anything about scripting or programming at all, so i need help here.

 

Basically i have 2 vbs scripts. I want to assign them to a .exe so that when i launch said .exe, automatically the first script will run, and when the .exe is closed the other script should automatically run.

 

The functionality i want is basically when i launch any of my HDR games, the 1st script will enable HDR in the windows display settings as long as i play the game, and when i quit the game, HDR will be disabled again by the 2nd script. Btw I didn't write these myself. I found them after another forum member posted them in another topic of mine.

 

Script 1: (Should automatically run when i launch the .exe)

Spoiler

Set oShell = CreateObject("WScript.Shell")

oShell.Run("""ms-settings:display""")

WScript.Sleep 2000

oShell.AppActivate "settings"

WScript.Sleep 100

oShell.SendKeys "{TAB}"

WScript.Sleep 60

oShell.SendKeys "{TAB}"

WScript.Sleep 60

oShell.SendKeys "{TAB}"

WScript.Sleep 60

oShell.SendKeys " "

WScript.Sleep 3000

oShell.SendKeys "{TAB}"

WScript.Sleep 50

oShell.SendKeys " "

WScript.Sleep 50

oShell.SendKeys "%{F4}"

Script 2: (Should automatically run when the .exe is closed)

Spoiler

Set oShell = CreateObject("WScript.Shell")

oShell.Run("""ms-settings:display""")

WScript.Sleep 2000

oShell.AppActivate "settings"

WScript.Sleep 100

oShell.SendKeys "{TAB}"

WScript.Sleep 60

oShell.SendKeys "{TAB}"

WScript.Sleep 60

oShell.SendKeys " "

WScript.Sleep 3000

oShell.SendKeys "{TAB}"

WScript.Sleep 50

oShell.SendKeys " "

WScript.Sleep 50

oShell.SendKeys "%{F4}"

 

So how can i do that? Any help is apprecciated, as i really don't know what i'm doing/asking or if it's even possible. Thanks in advance.

If someone did not use reason to reach their conclusion in the first place, you cannot use reason to convince them otherwise.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't have a practical solution for this, although if you are up to learning a bit of programming this could be a simple program that you can make in C#.

 

Basically a program that would take a .exe path as input and start it, then you can launch one of your scripts and wait for the program to get closed. When the closed handler is fired, you can call your other script.

 

If that is something that might work for you, I can show you a simple example of a such program, or maybe even guide you trough how to make one and learn programming

Link to comment
Share on other sites

Link to post
Share on other sites

the easy part,

just run the game from the script,

after changing the hdr settings

instead of binding launching the exe to a script

 

for changing it back prob possible cant thing of how off the top of my head 

 

 

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

×