Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

15 minutes ago, whazzzzzup17 said:

the cores show up as missing

RetroArch uses the cores. Not AutoHotkey.  So effectively what's happening is you're sending the command:

Autohotkey.exe -L vba_next_libretro rom_name

So AHK is trying to load/launch the script "-L".  Which of course doesn't exist.

There's something here about a 'Pandora's Box', 'can of worms', 'what have I gotten myself into'....  lol

So ya, in retrospect, RA needs to know what core to load. For proof of concept [that this'll work], for your Associated Platform "Nintendo Game Boy Advance" (I'm assuming your Pokémon game is in GBA), completely remove the core

image.thumb.png.ecb93b6d90f99c07b9fa7ddc871698b8.png

Now in the Extra Command-Line Parmeters field (the one just to the right), put

"E:\_arcade\LaunchBoxPortable\ThirdParty\AutoHotkey\MyAHKs\CustomEmulator.ahk" vba_next_libretro

Note: this Extra Command-Line Parmeter, I'm pretty sure, overrides the Default Command-Line Parameters in the Details Tab. But leave it there.

Oh, and as suggested above, you probably will need to Un-Check those 2 boxes.  When done, save.

 

Now edit "CustomEmulator.ahk"

Run, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\retroarch.exe -L %1% "%2%
RunWait, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\retroarch.exe -L %1% %2%

Try running Pokémon LeafGreen and cross your fingers.

 

 

 

  • Like 1
Link to comment
Share on other sites

5 hours ago, JoeViking245 said:

Try running Pokémon LeafGreen and cross your fingers.

 

Thank you for all your help, but I think I almost got it after trying everything. So originally, after running, the error doesn't appear anymore but nothing happens. After tinkering with it, I thought about changing the location on the AutoHotkey file to a bogus location. 

After doing so, I get the following error.. It looks like the parameters are being transferred correctly. Maybe it isn't working because it can't unzip the archive? I don't know what else it could be. If I revise the ahk file to the right retroach.exe location, nothing happens. 

Clipboard Image.jpg

Clipboard Image (1).jpg

Clipboard Image (2).jpg

Link to comment
Share on other sites

Hi @whazzzzzup17

I could be wrong here - I frequently am, but I think that the ahk needs the full path to the core rather than just the name

I think it would need to be 

 

Run, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\retroarch.exe -L E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\cores\%1%.dll "%2%
RunWait, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\retroarch.exe -L E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\cores\%1%.dll %2%

 

I'm not near my computer at the moment so cannot test it.

Also its a guess that might need the .dll part added to it

Over to @JoeViking245 to actually tidy it up and get it working nicely.

 

I know it a batch file its (assuming on C drive)

C:\path\to\retroarchexe -L C:\path\to\core.dll C:\path\to\game

So assume (Always dangerous) that same is true for AHK

Cheers

 

 

 

  • Like 2
Link to comment
Share on other sites

Thank you both!!! I have been manually doing this for years to play Pokemon with my kids and this is going to be a life saver. Just need to work on aligning one to the left and right of the screen and removing the title bar. I can probably figure that out though. Thank you so much.

Please read below on how I got it to work from your responses and for other future users. 

8 hours ago, JoeViking245 said:

retroarch1.exe vs retroarch.exe?

I did that on purpose, because the original fix wasn't doing anything. After creating a bogus file location, I was able to see the error above.

59 minutes ago, Kiinkyfoxx said:

Hi @whazzzzzup17

I could be wrong here - I frequently am, but I think that the ahk needs the full path to the core rather than just the name

I think it would need to be 

 

You are absolutely correct. It didn't work at first, but I think it was some typos. 

- I added a " on the second line before %2%. You had it on the first line but not the second. Also, I don't think this matters, but your second line references the same core from RetroArch1

Run, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\retroarch.exe -L E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\cores\%1%.dll "%2%
RunWait, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\retroarch.exe -L E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\cores\%1%.dll "%2%

And here are the images of the configuration for those interested. 

image 1.jpg

image 2.jpg

  • Game On 1
Link to comment
Share on other sites

5 minutes ago, whazzzzzup17 said:

I got it to work

Sweet!!  

 

6 minutes ago, whazzzzzup17 said:

I added a " on the second line before %2%

You should have a quote at the very end of both lines as well (similar to my 1st post, but never transferred over 😊).  If fact, should probably quote all paths to 'future proof it'.  (Only really needed if the path and/or filename has a space in it.  But is also cheap insurance.)

RA1 := E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1
RA2 := E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2

Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%"
RunWait, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%"

 

25 minutes ago, whazzzzzup17 said:

Just need to work on aligning one to the left and right of the screen and removing the title bar. I can probably figure that out though.

If you need help with that, let me know.   Hint: (from a copy & paste)

WinSet, Style, -0xC00000, a    ; remove the titlebar and border(s)
WinMove, a,, 0, 0, 1280, 1024  ; move the window to 0,0 and reize it to 1280x1024. Adjust accordingly

 

  • Like 1
Link to comment
Share on other sites

9 minutes ago, JoeViking245 said:

You should have a quote at the very end of both lines as well (similar to my 1st post, but never transferred over 😊).  If fact, should probably quote all paths to 'future proof it'.  (Only really needed if the path and/or filename has a space in it.  But is also cheap insurance.)

45 minutes ago, whazzzzzup17 said:

You are absolutely correct. It didn't work at first, but I think it was some typos. 

- I added a " on the second line before %2%. You had it on the first line but not the second. Also, I don't think this matters, but your second line references the same core from RetroArch1

That's what happens when you try to do it quickly at work and not check you answers before submitting

Glad its all working now though - and I doubt it matters which core, but probably easier to have it picking from whichever version of retroarch it is opening.

Would it be worth giving each Run its own PID variable and then use that variable in the Winset and WinMove part to act on each version of RetroArch? but that would mean either not using RunWait or having a timer (or two) that waits for each version of retroarch, restyles it and then moves it, then turns off. Or would this be a stupid way of doing it? Most of the AHK stuff I have learnt in the last year has been from adapting stuff on here done by people like JoeViking245

Cheers

 

  • Like 2
Link to comment
Share on other sites

13 hours ago, JoeViking245 said:

If you need help with that, let me know.   Hint: (from a copy & paste)

If you don't mind, can you help me finalize this? I have the gist of it, but I'm not experience with AutoHotKey. Basically, I set up the script to ask the user for how many single players. I made the script for up to (4) players, which is all I need but with how big my TV is, it would be nice to have up to (8). I also need to exit the script upon completing.

I have all the code, it runs, but I can't get it to align properly.

 

HideShowTaskbar(hide) ;Hide taskbar

; RetroArch locations
RA1 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1"
RA2 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2"
RA3 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch3"
RA4 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch4"

;Ask the user how many single player games
InputBox, UserInput, Enter RetroArch Instances (up to 4), Please enter the amount of single player games (<=4):, , 300, 150

;Determine the window sizes
height := (A_ScreenHeight/%UserInput%)
width := (A_ScreenWidth/%UserInput%)
UserCount = 0

Loop %UserInput%
{

	GetName:=UserInput%A_Index%
	WinGetTitle, title, % "ahk_id " GetName

	If (UserCount == 0)
	{
		Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%"
		WinActivate, % "ahk_id " GetName
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " GetName, , 0, 0 , %width%, %height%
		UserCount++
	}
	If (UserCount == 1)
	{
		RunWait, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%"
		WinActivate, % "ahk_id " GetName
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " GetName, , %width%, 0 , %width%, %height%
		UserCount++
	}
	If (UserCount == 2)
	{
		RunWait, "%RA3%\retroarch.exe" -L "%RA3%\cores\%1%.dll" "%2%"
		WinActivate, % "ahk_id " GetName
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " GetName, , 0, %height% , %width%, %height%
		UserCount++
	}
	If (UserCount == 3)
	{
		RunWait, "%RA4%\retroarch.exe" -L "%RA4%\cores\%1%.dll" "%2%"
		WinActivate, % "ahk_id " GetName
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " GetName, , %width%, %height% , %width%, %height%
		UserCount++
	}
	If (UserCount == 4)
	{
		exit  ; exit script
		UserCount++

	}

}

UserCount = 0


$F12:: HideShowTaskbar(hide := !hide) ;Toggle taskbar.

HideShowTaskbar(action) 
{
	;https://www.autohotkey.com/boards/viewtopic.php?t=60866&p=257259
	static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
	VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
	NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
	NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
	DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
}


; Borderless Windows (Hide)
LWIN & LButton::
SetTitleMatchMode, 2
WinGetPos, X, Y, Width, Height, A
WinSet, Style, -0xC00000, A
;WinMove,A,,0,0,1920,1080
return
;

; Borderless Windows (Show)
;+Caption
LWIN & RButton::
WinSet, Style, +0xC00000, A
;WinMove,A,,%X%,%Y%,%Width%,%Height%
Sleep, 1000
Sleep, 1000
return
;

 

Link to comment
Share on other sites

42 minutes ago, whazzzzzup17 said:

I have all the code, it runs, but I can't get it to align properly.

Without copying your script (which is quite impressive looking!!!) and running it myself (cause I ain't making 4 copied of RA. And it's my bedtime right now.  lol), is the alignment issue by chance: say you select 2 players, there's a little gap on the very left, in between the 2 windows, and on the very right?

That's what I had seen when playing with it earlier today (but using notepad windows [easier to test that way]).  Using WindowSpy.ahk (included with [a full install of] AutoHotkey), I found on my 1920 x1080 monitor, the difference (the 'little gap') was 7.  So setting window #1's x value to -7 (instead of 0 [zero]) pushed it up against the left edge.  Then each windows' width was 974.  Ya, the math don't add up to 1920. But I'm sure M$ has some logical reasoning for it. ;) 

 

How I found the -7... Opened 2 copies of Notepad.  Clicked one and hit {Win}{Left Arrow}.  The selected the other copy to be the right.  Then with WindowSpy

image.png.f252eca5b76ceb633239bf3ab78c8cea.pngimage.png.8fdeec14db464983f2fe1ed2f20ce28b.png

[left window]      [Right Window] 

The height (1047) is without the taskbar being hidden, so ignore it. ;)  And don't ask me about the "953". (maybe the math will make sense to me in the morning.)

And if that wasn't the alignment issue you're experiencing...  Could you explain more, please?

  • Like 1
Link to comment
Share on other sites

9 hours ago, JoeViking245 said:

Without copying your script (which is quite impressive looking!!!) and running it myself (cause I ain't making 4 copied of RA. And it's my bedtime right now.  lol), is the alignment issue by chance: say you select 2 players, there's a little gap on the very left, in between the 2 windows, and on the very right?

First, I want to say thank you for all of your help. You have helped made playing single player games with my kids very easy.

I think I was a little unclear about the alignment. I'm running into (2) problems for this script, both pertaining to the alignment.

  1. The alignment script isn't running at all. I think I am having an issue determining the correct window, and thus the commands aren't running for each RetroArch instance. Maybe since they all have the same window name, the script gets confused?
  2. The second thing is more of an issue on how to assign different window sizes determined by the users input. Meaning — If I input 1 RetroArch instance, it should play full screen, if I type 2, it should split half and half, if I type 3 or 4, it should adjust to the corners, and if I select 5-6, it should split 3 columns, and finally if I select 8 it should split in 8 boxes.
    1. I am more stuck on the best way to implement it. You see, I'm pretty sure I can just create tons of if statements, if %userinput% == 1, ==2, but it will make the code extremely long. This way I would remove the counter++ and just use (8) if statements. Either way, I think I can solve this issue that way, but I'm not an expert with AutoHotkey to determine a more effective solution.
Link to comment
Share on other sites

1 hour ago, whazzzzzup17 said:

I want to say thank you for all of your help.

You're welcome. :) 

If you're shooting for up to 8 players, I think you're crazy. lol  Here's 4 (I hope)

WinHide, ahk_class Shell_TrayWnd ;Hide taskbar

; RetroArch locations
RA1 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1"
RA2 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2"
RA3 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch3"
RA4 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch4"

;Ask the user how many single player games
InputBox, UserInput, Enter RetroArch Instances (up to 4), Please enter the amount of single player games (<=4):, , 300, 150

If (UserInput == 1)
{
   Run, "%RA1%\retroarch.exe" -f -L "%RA1%\cores\%1%.dll" "%2%", , , p1
}
else If (UserInput == 2)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Sleep,  1000   ;give the windows a sec to load
   Loop,  UserInput
   {
      WinSet, Style, -0xC00000, ahk_pid p%A_Index%
      WinSet, Style, -0x40000, ahk_pid p%A_Index%
      
   }
   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight
}
else If (UserInput == 3)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Run, "%RA3%\retroarch.exe" -L "%RA3%\cores\%1%.dll" "%2%", , , p3
   Sleep,  1000   ;give the windows a sec to load
   Loop,  UserInput
   {
      WinSet, Style, -0xC00000, ahk_pid p%A_Index%
      WinSet, Style, -0x40000, ahk_pid p%A_Index%
      
   }
   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p3%, , 0, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
}
else If (UserInput == 4)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Run, "%RA3%\retroarch.exe" -L "%RA3%\cores\%1%.dll" "%2%", , , p3
   Run, "%RA4%\retroarch.exe" -L "%RA4%\cores\%1%.dll" "%2%", , , p4
   Sleep,  1000   ;give the windows a sec to load
   Loop,  UserInput
   {
      WinSet, Style, -0xC00000, ahk_pid p%A_Index%
      WinSet, Style, -0x40000, ahk_pid p%A_Index%
      
   }
   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p3%, , 0, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p4%, , A_ScreenWidth/2, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
}
else
{
   MsgBox Invalid Selection
   WinShow, ahk_class Shell_TrayWnd ;Restore TaskBar
   ExitApp
}

Sleep,  1000   ; because you never know
last := p%UserInput%
Process, WaitClose, %last%
WinShow, ahk_class Shell_TrayWnd ;Restore TaskBar
ExitApp


$F12:: HideShowTaskbar(hide := !hide) ;Toggle taskbar.

HideShowTaskbar(action) ;revised. Same AHK thread, different answer
{
   ;https://www.autohotkey.com/boards/viewtopic.php?p=414584&sid=dac3435aa858994dfe2ffd9cb41fdb7d#p414584
   if action
      WinHide, ahk_class Shell_TrayWnd
   else
      WinShow, ahk_class Shell_TrayWnd
}

I like the shorter HideShowTaskbar method. :)  But if doesn't work on your PC, change it back to the "other" one (and change line #1 and the line right before ExitApp [2 locations]).   If you don't need to manually toggle the TB at all, you can remove everything from "$F12::" on down.

Any hotkeys you assign (i.e. F12 as shown) will function until the last Player #'s window is closed/exited.  So if 3 players is selected, you can exit p1 and p2, and F12 will still work.  But if you exit [only] p3 (leaving p1 and p2 still open) F12 will not work anymore.

If only "1" player is selected, I'm pretty sure the "-f" makes it fullscreen.

There's probably some other stuff I'm forgetting to mention, but I think you get the gist. 

Link to comment
Share on other sites

On 12/16/2021 at 8:35 AM, JoeViking245 said:

You're welcome. :) 

If you're shooting for up to 8 players, I think you're crazy. lol  Here's 4 (I hope)

I like the shorter HideShowTaskbar method. :)  But if doesn't work on your PC, change it back to the "other" one (and change line #1 and the line right before ExitApp [2 locations]).   If you don't need to manually toggle the TB at all, you can remove everything from "$F12::" on down.

Any hotkeys you assign (i.e. F12 as shown) will function until the last Player #'s window is closed/exited.  So if 3 players is selected, you can exit p1 and p2, and F12 will still work.  But if you exit [only] p3 (leaving p1 and p2 still open) F12 will not work anymore.

If only "1" player is selected, I'm pretty sure the "-f" makes it fullscreen.

There's probably some other stuff I'm forgetting to mention, but I think you get the gist. 

Sorry for the delay, I have been a bit preoccupied. I tested it and it works. It seems to have a small gap that I can't seem to get rid of between the emulators, but at least it works. Also, the top borders on each window aren't removed, but I have a script for that — see below. I will try and finalize it in the next day or so, and post it for anyone else looking in the future. Thank you again!

	+b::  ; toggles border on active window.
		if (border := !border)
			misc.BorderOn()
		else
			misc.BorderOff()
	return


class misc {
		BorderOn() {
			WinSet, Style, +0xC00000, A
			;WinMove,A,,%X%,%Y%,%Width%,%Height%
		}
		BorderOff() {
			; If the toggle is off (0 or false), do theo stuff in here
			SetTitleMatchMode, 2
			WinGetPos, X, Y, Width, Height, A
			WinSet, Style, -0xC00000, A
		}
	}

1460076506_bordersremoved.thumb.jpg.26634a96eafa6730899d93570a5a471f.jpg1590861305_bordersadded.thumb.jpg.4c5f4f07643939bf95a2c18d771253cf.jpg

Link to comment
Share on other sites

1 hour ago, whazzzzzup17 said:

the top borders on each window aren't removed

Revised (fixed programmer error, actually) and improved

WinHide, ahk_class Shell_TrayWnd ;Hide taskbar

; RetroArch locations
RA1 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1"
RA2 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2"
RA3 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch3"
RA4 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch4"

;Ask the user how many single player games
InputBox, UserInput, Enter RetroArch Instances (up to 4), Please enter the amount of single player games (<=4):, , 300, 150

If (UserInput == 1)
{
   Run, "%RA1%\retroarch.exe" -f -L "%RA1%\cores\%1%.dll" "%2%", , , p1
}
else If (UserInput == 2)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Sleep,  1000   ;give the windows a sec to load
   Loop,  UserInput
   {
      pidInt := p%A_Index%
      WinSet, Style, -0xC40000, ahk_pid %pidInt%
      RemoveMenuBar(ahk_pid %pidInt%)
   }
   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight
}
else If (UserInput == 3)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Run, "%RA3%\retroarch.exe" -L "%RA3%\cores\%1%.dll" "%2%", , , p3
   Sleep,  1000   ;give the windows a sec to load
   Loop,  UserInput
   {
      pidInt := p%A_Index%
      WinSet, Style, -0xC40000, ahk_pid %pidInt%
      RemoveMenuBar(ahk_pid %pidInt%)
   }
   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p3%, , 0, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
}
else If (UserInput == 4)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Run, "%RA3%\retroarch.exe" -L "%RA3%\cores\%1%.dll" "%2%", , , p3
   Run, "%RA4%\retroarch.exe" -L "%RA4%\cores\%1%.dll" "%2%", , , p4
   Sleep,  1000   ;give the windows a sec to load
   Loop,  UserInput
   {
      pidInt := p%A_Index%
      WinSet, Style, -0xC40000, ahk_pid %pidInt%
      RemoveMenuBar(ahk_pid %pidInt%)
   }
   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p3%, , 0, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p4%, , A_ScreenWidth/2, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
}
else
{
   MsgBox Invalid Selection
   WinShow, ahk_class Shell_TrayWnd ;Restore TaskBar
   ExitApp
}

Sleep,  1000   ; because you never know
last := p%UserInput%
Process, WaitClose, %last%
WinShow, ahk_class Shell_TrayWnd ;Restore TaskBar
ExitApp

RemoveMenuBar( hWin )
{
	;static associative array for keeping track of all windows that have had their menus hidden
  static MenuArray := {}
 
  ;find active window handle in array / add to array if not found
  hWin := WinExist("A")
  hMenu := null
  hMenu := MenuArray.Remove(hWin)
  if (hMenu = null)
  {
    ;store a reference to the window's menu in the array
    hMenu := (DllCall("GetMenu", "uint", hWin))
    MenuArray[hWin] := hMenu
    
    ;hide the menu by uncoupling it from the parent window
    DllCall("SetMenu", "uint", hWin, "uint", 0)
  }
  else
  {
    ;show menu by recoupling it to the parent window
    DllCall("SetMenu", "uint", hWin, "uint", hMenu)
  }
}

 

  • I forgot some % signs in the previous post that (would have) removed the title bars. (fixed here)
  • WinSet, Style, -0xC00000    and    WinSet, Style, -0x40000
    • are combined into the single:      WinSet, Style, -0xC40000
    • 0xC00000 is for the title bar    0x40000 is the the border   (0xC40000 is for both of them)
  • Added a function to remove the menubar.
  • With these last 2 bulleted items, you shouldn't need to manually 'toggle' anything.

The gaps you see are covered in one of my prior posts.  To completely get rid of them, you may need to set those manually for each WinMove, inside each UserInput looped.  There is a chance that with the hiding title/menu/border properly working (I hope they are, this time ;)), the gaps may be eliminated.  Not tested, but fingers crossed.

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

7 hours ago, JoeViking245 said:
  • I forgot some % signs in the previous post that (would have) removed the title bars. (fixed here)
  • WinSet, Style, -0xC00000    and    WinSet, Style, -0x40000
    • are combined into the single:      WinSet, Style, -0xC40000
    • 0xC00000 is for the title bar    0x40000 is the the border   (0xC40000 is for both of them)

Isn't working for me. Even if I change it to 0xC00000. The loop must not be working

Link to comment
Share on other sites

17 minutes ago, whazzzzzup17 said:

Isn't working for me.

There might be a loading time issue.  Start with a UserInput = 2 (load only 2 instances of RA), and increase the "Sleep" right before the Loop to something like "Sleep, 10000" (ten thousand, aka 10 seconds)

....
else If (UserInput == 2)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Sleep,  10000   ;give the windows TEN SECONDS to load
   Loop,  UserInput
   {
....

If it's still not working, get crazy and put it to 20 seconds.  If that does eventually work, do the same for UserInput = 3 and then 4.  Later on you can find the 'sweet spot' for each of the sleeps.  

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

3 minutes ago, JoeViking245 said:

If it's still not working, get crazy and put it to 20 seconds.  If that does eventually work, do the same for UserInput = 3 and then 4.  Later on you can find the 'sweet spot' for each of the sleeps.  

Yeah, I tried that. Still playing around with it though. That sleep just delays the move. The top title/menu bar doesn't run. 

Link to comment
Share on other sites

4 minutes ago, whazzzzzup17 said:

Yeah, I tried that

It might be an RA thing then (I never tested it in RA).  There is a setting in RA where you can remove the title bar (at least).  SettingsVideoWindow ModeShow Window Decorations

image.thumb.png.82c6846dd057b9d616b7e260b9e1ce49.png

(Above) your 1st image (left 2) didn't have the title bar, but the 2nd one (right 2) did.  

  • Like 1
Link to comment
Share on other sites

8 minutes ago, JoeViking245 said:

(Above) your 1st image (left 2) didn't have the title bar, but the 2nd one (right 2) did.  

Wow, you're so awesome!! I didn't know RetroArch had that setting. After changing that setting, there are absolutely no gaps either. It lines up perfectly!

Going back to the other method, not that it is needed anymore, here is my fix to remove the gaps and title bars that I did manually.

;Adjust spacing on left and right windows for (2) players.
;WinMove, ahk_pid %p1%, , -5, 0 ,A_ScreenWidth/2+18, A_ScreenHeight 
;WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2+5, A_ScreenHeight

;Borderless Windows (Hide)
LWIN & LButton::
	SetTitleMatchMode, 2
	WinGetPos, X, Y, Width, Height, A
	WinSet, Style, -0xC00000, A
	;WinMove,A,,0,0,1920,1080
return

Thanks again. I think that's everything. 

Clipboard Image.jpg

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

@whazzzzzup17  So glad it's working as it should!!!!!!!   

Well, I broke down and actually tested it with RA on my cab. Finally. lol  Though I did 'cheat' and used [up to 4 instances of] the same retroarch.exe for each launch.  😊  Going through this (now, properly) I saw some things with the code that could be improved and cleaned up.

  • The Sleep 'timer' was kind of a cheesy and was bugging me, so I changed it to WinWait.  Now there's no guessing as to how long to set it.
  • I looked closer at the RemoveMenuBar method and saw it was only working on the "Active window".  Doh!  It was also long and ugly, so I revamped the 24-lines of code into 2 lines AND it [now] works on the window we tell it to.  I know this is a moot point because of the recent 'discovery' of turning off the menu bar directly in RA.  But it now actually works, regardless of the setting in RA.
  • The Loops inside each "If (UserInput=)" are all the exact same, so I moved them to single method and now just call that method.

Fun project!  Thanks.  (Edit Dec-31:  Fixed window positioning.  Added code to hide all background stuff)

Spoiler

 

; Hide taskbar
WinHide, ahk_class Shell_TrayWnd 

; Global variables to hide stuff in the background
global HWND
global origBackground
global originalWallpaper

; RetroArch locations
RA1 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1"
RA2 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2"
RA3 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch3"
RA4 := "E:\_arcade\LaunchBoxPortable\Emulators\RetroArch4"


;Ask the user how many single player games
InputBox, UserInput, Enter RetroArch Instances (up to 4), Please enter the amount of single player games (<=4):, , 300, 150

If (UserInput == 1)
{
   Run, "%RA1%\retroarch.exe" -f -L "%RA1%\cores\%1%.dll" "%2%", , , p1
}
else If (UserInput == 2)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   
   RemoveExcess()

   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight

   HideStuff()
   WinActivate, ahk_pid %p1%
   WinActivate, ahk_pid %p2%
}
else If (UserInput == 3)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Run, "%RA3%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p3

   RemoveExcess()

   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p3%, , 0, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2

   HideStuff()
   WinActivate, ahk_pid %p1%
   WinActivate, ahk_pid %p2%
   WinActivate, ahk_pid %p3%
}
else If (UserInput == 4)
{
   Run, "%RA1%\retroarch.exe" -L "%RA1%\cores\%1%.dll" "%2%", , , p1
   Run, "%RA2%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p2
   Run, "%RA3%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p3
   Run, "%RA4%\retroarch.exe" -L "%RA2%\cores\%1%.dll" "%2%", , , p4
   
   RemoveExcess()

   WinMove, ahk_pid %p1%, , 0, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p2%, , A_ScreenWidth/2, 0 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p3%, , 0, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2
   WinMove, ahk_pid %p4%, , A_ScreenWidth/2, A_ScreenHeight/2 ,A_ScreenWidth/2, A_ScreenHeight/2

   HideStuff()
   WinActivate, ahk_pid %p1%
   WinActivate, ahk_pid %p2%
   WinActivate, ahk_pid %p3%
   WinActivate, ahk_pid %p4%
}
else
{
   MsgBox Invalid Selection
   ExitApp
}

; Wait for all instances of Retroarch to close
Loop, %UserInput% {
   Process, WaitClose, retroarch.exe
   sleep 500
}

; Restore Desktop Icons
WinShow, ahk_id %HWND%

; Restore original desktop wallpaper
DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, originalWallpaper, UInt, 2)

; Restore the original backrgound color
DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", origBackground)

; Restore TaskBar
WinShow, ahk_class Shell_TrayWnd

; Restore LB/BB
WinRestore, ahk_exe LaunchBox.exe
WinRestore, ahk_exe BigBox.exe

ExitApp

RemoveExcess()
{
   Loop, %UserInput%
   {
      pidInt := ahk_pid p%A_Index%
      WinWait ahk_pid %pidInt%                     ;wait for the window to [actually] exist
      WinSet, Style, -0xC40000, ahk_pid %pidInt%   ;remove title AND border

      ;remove menu bar
      WinGet, hwnd, ID, ahk_pid %pidInt%
      DllCall("SetMenu", "uint", hwnd, "uint", 0)
   }
}

HideStuff() 
{
   ; Minimize all windows
   WinMinimizeAll

   ; Hide desktop Icons
   ControlGet, HWND, Hwnd,, SysListView321, ahk_class Progman
   If HWND =
      ControlGet, HWND, Hwnd,, SysListView321, ahk_class WorkerW
   WinHide, ahk_id %HWND%

   ; Store original desktop wallpaper (probably has issues with multiple monitors)
   RegRead, originalWallpaper, HKCU\Control Panel\Desktop, WallPaper
   ; Set desktop wallpaper to null (not saved after rebooting PC)
   DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, , UInt, 2)

   ; Store to original background color
   RegRead, backgroundRGB, HKCU\Control Panel\Colors, Background
   StringSplit split, backgroundRGB, " "
   origBackground := % RGB( split1, split2, split3)
   ; Set the background Color to black
   DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", 0)
}

RGB(r, g, b) {
   SetFormat, Integer, Hex
   Return, (r << 16) | (g << 8) | b
}

 

 

 

Edited by JoeViking245
Link to comment
Share on other sites

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