Jump to content
LaunchBox Community Forums

Mouse Cursor reset after exiting game launched by LaunchBox


Dimitri

Recommended Posts

20 minutes ago, neil9000 said:

Awesome, thanks everyone here for coming up with this script, its working great. Only question now is how do i get it to launch automatically when i start Launchbox/Bigbox? Is there a AHK, that i could use to launch them both at the same time?

 

I could try to answer this and then we can get @JoeViking245 to fix it for us ?

I think the basic AHK for Bigbox would be 

Run, full pathway to bigbox.exe

Run, full pathway to whichever version of the 3 you have download.exe

Exitapp

 

You would need a separate one for Launchbox I think. Just replacing the pathway to Launchbox.exe instead. 

Edited by Kiinkyfoxx
Link to comment
Share on other sites

ya, ya. lol

I can think of 3 options:

1) (as mentioned) create a whole new AHK script to launch LB and then the "Both options.ahk" script.

2) At the beginning of the "Both options.ahk", launch LB.

3) create a batch file

@echo off
start "D:\LaunchBox\LaunchBox.exe"
start "D:\LaunchBox\ThirdParty\AutoHotkey\Autohotkey.exe" "D:\LaunchBox\ThirdParty\AutoHotkey\MyAHKs\Both options.ahk"

4) (for good measure) have @jayjay write you  a plugin that catches the event LaunchBoxStartupCompleted and then runs the script.

5) better yet, as he suggested, have it catch the event GameExited and then in C#, do the mousy thing.

Link to comment
Share on other sites

2 hours ago, JoeViking245 said:

I can think of 3 options:

You gave 5 options haha.

This plugin: LaunchScript.zip 

All it does is launch the .ahk using LB built in autohotkey so dont need to compile the ahk.

Unblock the zip and extract the dll to Launchbox/Plugins.

You need to place your script in Launchbox/Third Party/Autohotkey/.

If you want the script to launch when BB/LB starts up rename your script to "OnStartupCompleted.ahk".

If you want the script to launch on game exit rename your script to "OnGameExit.ahk".

If you want the script to launch on BB/LB closing rename your script to "OnAppExit.ahk".

If you want you can use all 3 at the same time.

 

Also I keep forgetting, when using onGameExit... if you play a windows or steam etc game, where you launch an exe that passes on to another exe, on game exit wont work correctly. The game exit event fires when the first exe closes. Im not sure what effect it will have on your mouse. If you want to get a bit fancy (hacky?) with your game exit script you can capture the launching games platform, games application path and emulator path with the following:

args = %1%
Array := StrSplit(args , "|")

platform := Array[1]
gamePath := Array[2]
emuPath := Array[3]

Also if using one of the on exit options you might want the script to sleep for a few seconds until LB/BB unhides the mouse.

Edited by jayjay
Link to comment
Share on other sites

@jayjay-thank you for your plugin and information

 I think that if the "BigBox and LaunchBox.ahk" is renamed to "OnStartupCompleted.ahk" it should work as it currently does, on my system it worked on the manual tests it if launched before or after BigBox/LaunchBox. This is the only one I use on my system as it auto launches.

I think for the other two versions I may need to adjust the ahk, which I am happy to do as we learn by doing. (at this point JoeViking245 is shaking their head and thinking yet more work for them when I fail)

I can see the advantage of only having it occur when the game closes or the app closes rather than having it run all the time, so happy to put the effort it.

May I ask 2 questions please.

1) Would the "OnAppExit.ahk" happen if the user was to switch between BB and LB using menus or key combo?

2) When would the "OnGameExit.ahk" happen - I think from your description it is whenever the emulator/loading script closes, in which case it would happen when the Game Over screen is showing, if so I should only need to adapt the ahk a little to work.  The exception to this being the Steam/Windows bit but I will try to get  bit hacky with it and see how that goes (JoeViking245 is now sobbing in the corner and cursing Neil9000 for tagging them in this thread)

Thank you for all your help and guidance.

Link to comment
Share on other sites

The last plugin has "script not found" error message pop up when it doesnt find one of the scripts. Sorry about that use this one instead: LaunchScript.zip

1. Yeah the OnAppExit does fire when switching between LB and BB.

2. I think OnGameExit happens as soon as you exit the game. I dont think LB unhides the mouse until the game over screen disappears. 

 @DrGrizzPHD posted a method for the steam/windows games, should work for all games, with the OnGameExit issue over here,: 

So if we nick that script and add the stuff you need it should look something like this:

Sleep, 3000 ; Wait three seconds for the game to launch
MouseMove, 1920, 500 ; move the mouse to the middle of the screen instead of the corner to prevent the title/start bar from appearing
Sleep, 10000 ; wait 10 seconds for good measure to make sure the game is loaded and is the active window, this could probably be reduced
WinGet, active_id, ID, A ; get the ID of the active window
WinWaitClose, ahk_id %active_id% ; wait for the active window to close
Sleep, 500 ; wait half a second, this might not be needed either
if WinExist("LaunchBox Game Startup")
{

		WinActivate
	WinWaitClose, LaunchBox Game Startup
}

if WinExist("LaunchBox")
{
	;maybe add another sleep here
    	WinActivate
	Goto, ChangeItBack
}

if WinExist("LaunchBox Big Box")
{
	;maybe add another sleep here
    WinActivate
	Goto, ChangeItBack
}

return

ChangeItBack:                                               ;************* here
	RegRead, output, HKEY_CURRENT_USER\Control Panel\Cursors,
	ChangeCursorScheme("%output%")
	ChangeCursorScheme(Scheme){
		KeyNames := ["Arrow", "Help", "AppStarting", "Wait", "Crosshair", "IBeam", "NWPen", "No", "SizeNS", "SizeWE", "SizeNWSE", "SizeNESW", "SizeAll", "UpArrow", "Hand"]
		KEYpath := "HKEY_CURRENT_USER\Control Panel\Cursors"
		
		RegRead, SchemeVals, HKEY_CURRENT_USER\Control Panel\Cursors\Schemes, %Scheme%
		if(!SchemeVals){
			RegRead, SchemeVals, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cursors\Schemes, %Scheme%
		}
		SchemeVals := StrSplit(SchemeVals, ",")
		
		if(SchemeVals.Length() > 0){
			RegWrite, Reg_SZ, %KEYpath%, , %Scheme%
		}
		
		for index, val in SchemeVals {
			if(index < KeyNames.Length()){
				RegWrite, Reg_Expand_SZ, %KEYpath%, % KeyNames[index], %val%
			}
		}
		DllCall("SystemParametersInfo", "UInt",0x0057, "UInt","0", "UInt",0, "UInt","0")
	}
	ExitApp                                         ;*********************** and don't forget this

Rename this script to OnGameExit.ahk and see if it works for all games.

Edited by jayjay
Link to comment
Share on other sites

@jayjay and @JoeViking245

Before I go any further I would just like to give a heartfelt thank you to both of you. I started this hoping to try to give something back to this excellent community, but I did not mean to make work for anyone, and I am very grateful for your help and effort, especially as this may not be something of any importance to either of you.

The negative of this is that actually very little of my original work is left from this, the mouse cursor changing part I found online, the getting it to work completely belongs to JoeViking245 and the plugin that makes it nice and tidy belongs to JayJay, I have at this rate maybe contributed one line to the ahk. But in all seriousness thank you for everything.

With this plugin I think the ahk that tries to be a one size fits all (OnStartUpCompleted.ahk) can be done away with as it always had the flaw that if people had the mouse showing in BB it didn't work well, but I thought most people would have hidden, but by using the other 2 ahks together it can be used across LB and BB no matter what settings the end user has. 

By keeping the option of OnStartUpCompleted.ahk within the plugin I suppose people could add their own ahk to start up anything else they wanted running.

I have downloaded the Launchscript.zip above and tested it with a modified OnAppExit.ahk and it fires and works for changing the cursor whenever LB or BB closes back to Windows or the user swaps from LB to BB (and vice versa) via hotkeys or menu selections.

21 hours ago, jayjay said:

Also I keep forgetting, when using onGameExit... if you play a windows or steam etc game, where you launch an exe that passes on to another exe, on game exit wont work correctly. The game exit event fires when the first exe closes. Im not sure what effect it will have on your mouse. If you want to get a bit fancy (hacky?) with your game exit script you can capture the launching games platform, games application path and emulator path with the following:

 

6 hours ago, jayjay said:

@DrGrizzPHD posted a method for the steam/windows games, should work for all games, with the OnGameExit issue over here,: 

Looking at the thread above I may be misunderstanding this and sorry to question you, but that original ahk was put as an additional app against games that where having an issue with BB regaining focus on game exit, so loaded up when the game started rather than when it closed, thus when it grabs the name of the active window it would be the game/emulator name.

Using the ahk you gave as an example the active window is actually the LB/BB game selection screen as it picks up the active screen 13 seconds after the ahk starts which is after the game has closed. I imagine this would work if the ahk started at game start up rather than shut down, but I am not expecting you to rewrite the plugin.

I have modified the original version of OnGameExit.ahk - the game startup screen closes and then changes the mouse cursor which is working perfectly. As I load Steam/Windows games through a bat file which stays open until game closes the normal OnGameExit.ahk works here, so I will remove my current bat file and have a play with it to see what happens, may I just clarify if this passing issue would arise it I was just using the normal way to load Steam games through LB. 

Edit-removed bat file and direct loaded steam games and they all worked on exit I had an exit screen and the cursor changed back.

Edit-There is only one game on my setup where I don't get an exit screen, and I think this is when one exe passes info to a second one-first exe is a game selection screen Eg type of game and team selection. Once chosen and play selected the game opens in a second window, if I pause this game the mouse shows up in pause screen but doesn't in any other game and no game exiting screen, however with this ahk and plugin combination it still changes the cursor on game exit-or is this not an example of what you meant? 

With the two modified ahks and the plugin it is working great here on what I have tested, but with other people having other setups I would like to try to make it work for the possible issue mentioned above by JayJay. 

I am not trying to get anyone else to do the work, I just want to make sure I understand so I can try to work on it, as you have already done much more then expected.

Thank you and sorry for the essay.

Edited by Kiinkyfoxx
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, Kiinkyfoxx said:

Edit-There is only one game on my setup where I don't get an exit screen, and I think this is when one exe passes info to a second one-first exe is a game selection screen Eg type of game and team selection. Once chosen and play selected the game opens in a second window, if I pause this game the mouse shows up in pause screen but doesn't in any other game and no game exiting screen, however with this ahk and plugin combination it still changes the cursor on game exit-or is this not an example of what you meant? 

I guess from your explanation the way this currently behaves is:

LB/BB hides/changes the mouse on game start up.

When you exit the first .exe the plugin + ahk combination changes the mouse back.

Having the mouse show on pause screen would annoy me. Maybe if the mouse isnt to big you could use a move mouse command to hide the mouse in the corner of screen.... i dunno. Might be tricky trying to have 1 script catch all.

 

6 hours ago, Kiinkyfoxx said:

Using the ahk you gave as an example the active window is actually the LB/BB game selection screen as it picks up the active screen 13 seconds after the ahk starts which is after the game has closed.

Yeah your right. Sorry was being a bit thick.

LaunchScript.zip This plugin you can have the following scripts:

OnAppExit.ahk - will work for both LB/BB

OnAppExitBB.ahk

OnAppExitLB.ahk

OnStartupCompleted.ahk - will work for both LB/BB

OnStartupCompletedBB.ahk

OnStartupCompletedLB.ahk

OnAfterGameLaunched.ahk - will work for both LB/BB

OnAfterGameLaunchedBB.ahk

OnAfterGameLaunchedLB.ahk

OnGameExit.ahk  - will work for both LB/BB

OnGameExitBB.ahk

OnGameExitLB.ahk

If you have say OnGameExit.ahk and you have OnGameExitBB.ahk in your Autohotkey directory, both scripts will launch when a game is exited. 

If you have say OnGameExitLB.ahk and you have OnGameExitBB.ahk in your Autohotkey directory, only 1 script will launch depending on if your using BB or LB. 

Maybe overkill for what your trying to achieve but figured others could use it for something different.

 

If you do need to handle it differently for BB/LB, it would prob be better to do it in ahk:

args = %1%
Array := StrSplit(args , "|")

platform := Array[1]
gamePath := Array[2]
emuPath := Array[3]
isBigBox := Array[4]

if (isBigBox == "true")
{
	;is bigbox
}
else
{
	;is launchbox
}

Can capture the above using the GameExit and AfterGameLaunch scripts.

Anyway theres a few options, i'll leave it to you to come up with the best method.

 

Edited by jayjay
Link to comment
Share on other sites

@jayjay I can only say thank you so many times, but to do that really was above and beyond, so thank you again-I hope you don't mind but I have bundled your plugin into the downloads below so it can all be downloaded from one place

By using the "OnAfterGameLaunched" I have come up with a way that works so far

I have also been able to trim the ahks down quite a lot as they are being launched at specific times now.

@neil9000 as you seem to be the only other person that has actually downloaded this and used it, would you mind testing the new version for me please.

I have tried it across several platforms and games, and also by swapping in and out of LB and BB and so far it has worked.

I however admit I have a small collection of platforms and games compared to others and therefore would appreciate you trying it on your system

This new method should in theory work for the following

For users who use BigBox and hide their mouse across everything the only thing they will notice is the mouse cursor returning to their original selection on exit of BigBox

For users who use BigBox or Launchbox but only hide their mouse in game and on load up screens they will notice the mouse cursor returning to their original selection on return to the game selection screen and on exit of BigBox.

I imagine if you never hide the mouse then this was never an issue?

Cheers

cursor change.zip

Edited by Kiinkyfoxx
  • Like 1
Link to comment
Share on other sites

Wow.  Wasn't expecting this much of a response.

I confirmed in my case it was indeed the startup/shutdown screens resetting the mouse cursor. I have tried the above plugin and scripts and have confirmed both the size and theme of mouse cursor appear unchanged after launching and exiting games from multiple platforms, including Windows and MS-DOS games that both directly launch and indirectly launch via an additional menu selection window.

Thank you to those involved with the plugin and scripting to make this relatively painless and elegant workaround happen. The effort and knowledge is much appreciated.

Link to comment
Share on other sites

7 hours ago, Kiinkyfoxx said:

@neil9000 as you seem to be the only other person that has actually downloaded this and used it, would you mind testing the new version for me please.

Sorry for the late reply, ill take a look. Quick question though, so this is a plugin now that launches when LB/BB do? If so thats perfect.

Link to comment
Share on other sites

9 minutes ago, neil9000 said:

Sorry for the late reply, ill take a look. Quick question though, so this is a plugin now that launches when LB/BB do? If so thats perfect.

Yes thanks to JayJay and their amazing plugin, all the end user needs to do is set it up once per the instructions and then can just load LB/BB like normal and it will take care of itself-they might need to adjust a sleep or two depending on their system, but I have commented it so can be done easily. 

Due to the extra work JayJay put in if end user needs/wants to add extra bits specific for LB or BB or other ahks that they also want to always have running when LB/BB open then they can add them as well. 

Edited by Kiinkyfoxx
  • Like 1
Link to comment
Share on other sites

7 minutes ago, Kiinkyfoxx said:

Yes thanks to JayJay and their amazing plugin, all the end user needs to do is set it up once per the instructions and then can just load LB/BB like normal and it will take care of itself-they might need to adjust a sleep or two depending on their system, but I have commented it so can be done easily. 

Due to the extra work JayJay put in if end user needs/wants to add extra bits specific for LB or BB or other ahks that they also want to always have running when LB/BB open then they can add them as well. 

Awesome, thank you so much. Ill just add here a little as i saw you mention it doesnt contain much of your own work now. It was your enthusiasm to try and fix a problem that grew traction. I had been pissed off about the mouse issue for months, i brought it up in private with the devs many times, but never heard anything back, or id bring it up again and would get a "dont remember that issue" response. So to have someone just come in and say "you know what people, i can fix this with a simple AHK script" that changed everything. :) 

Then when that worked for me, thanks to your AHK script, i was like thats brilliant, it works exactly how i would want it to, just a shame i have to manually launch it, and cant use a @ ;) 

So for then to have others like @jayjay and @JoeViking245 come in, (after admittedly i did tag joeviking, after you asked if there was any more knowledgeable AHK users, he is the only one i ever remember the name of for some reason). :)

So, long story short. Thanks  to all involved here, this is what happens when thoughts/ideas/opinions are shared, it turns into a win for everyone.

 

 

  • Like 2
Link to comment
Share on other sites

  • 2 years later...

After updating BigBox I have the lost focus issue. I have to get a mouse, open my cabs back plate, unplug my BT dongle for my xbox controllers, plug in the mouse, & click it on every game exit.

I had the issue years back & a post from a hero named  @jayjay fixed it. He had a single .dll & a single .ahk in a zip file. From what I gather through my attempts is the Auto HotKey moved to the Third Party folder & broke his original fix.

Ive tried mixing & matching al the scripts & downloads in this thread. I tried to edit his old .dll. It has became impossible to follow this thread if youre just coming in to the thread.

Is there any way 1 of you wizards can make me a simple zip folder w/ the proper .dll & .ahk please? I will erase my current plugins & auto hotkey .ahks.

All I need is for the mouse to click after exiting a game like I manualy do. I dont care if I get a cursor or not. I dont care about screen fickers. I dont care if I need to turn off or on startup screens. I Just need the mouse clicked to refocus BigBox.

Im so frustrated Im going to drill a hole & buy a long usb male to female splitter or a bluetooth keyboard just for this. It loses focus after every game & renders a cab I spent 3 years on unusable.

 

Thank you to anybody that solved this & may find it in your heart to help me. I certainly appreciate you guys for helping others & Im thankful for jayjay solving it a few years back.

 

UPDATE - I will also say when i open the script via double click it brings BigBox to the front & its in focus. Therefore I think the script is correct. Its something in the .dll thats not activating or executing the script named RegainFocus.

 

@jayjay @JoeViking245 @Kiinkyfoxx

Edited by Lf indy
Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...