Jump to content
LaunchBox Community Forums

XAML Question


Recommended Posts

Hi All,

I have a XAML question. I'm not sure if this is the best spot to post it or not, so I apologize if it's not.

I wanted to know if there's a way that I can have a black screen (AutoHotKey script using a gui) that will always be on top of Bigbox once the script is launched with a Windows game, but not on top of anything else.

I want to do this for running Windows games. There's always different amounts of time between launching a game and when the game is displayed or running. Typically, the BigBox startup screen ends and you're back looking at Bigbox until the game loads.

I know how to create a black screen using the gui command in AutoHotKey. I'm also familiar with +AlwaysOnTop. +AlwaysOnTop will cover BigBox, but it typically covers the game too. I've looked into child/parent relations with AHK but I can't quite seem to wrap my head around how to do it with an app (BigBox) and a gui.

If this isn't possible I would also like to know.

Thanks!

Link to comment
Share on other sites

Here's a bit of code to give a crude idea of what I'm looking for --

Gui, BigBox: New, +HwndmainGuiId +Resize, BigBox
Gui, BigBox: Show, x0 y0 w1920 h1080

Gui, BlackScreen: New, +ParentBigBox +HwndBlackScreenId1, BlackScreen
Gui, BlackScreen: Show, x0 y0 w1920 h1080
Gui, BlackScreen: Color,Black,000000

The issue is I want to use the actual BigBox (BigBox.exe) not a Gui Window called Bigbox

Link to comment
Share on other sites

Ok, after several days I figured it out. Now my only question is -- does anyone know how to make the child window fade in and out?

WinGet, active_id, ID, A

Gui, BlackScreen: New, +Parent%active_id% +HwndBlackScreenId1, BlackScreen
TempVar := A_ScreenHeight +100
Gui, BlackScreen: Show, h%TempVar% w%A_ScreenWidth%
Gui, BlackScreen: Color,Black,000000

WinSet, Top, , ahk_id %BlackScreenID1%
OnMessage(0x0022, "BlackScreenActivate") ; WM_BlackScreenACTIVATE

BlackScreenActivate() {
   If (A_Gui <> "BigBox") && (A_Gui <> "BlackScreen1") {
      Gui, BlackScreen1:+LastFound
      WinSet, Top
   }
}

Link to comment
Share on other sites

Hi @bbweiners This is really an AHK related question, rather than XAML.

If I understand right, the goal is to not have it flash back to Big Box due to the Startup Screen ending too soon? If that is the case, you should simply increase the delay for the Startup Screen. That makes it stay up for X secs (X being the value you set). If the game launches into exclusive fullscreen it takes over as fullscreen prior to X secs. Same tip it tells you on the Startup Screen window in LaunchBox. Goes up to 30 secs which should be enough time for any game to fully launch

Before we dive into AHK talk, try cranking up the Startup Screen delay because this AHK stuff seems like an unnecessary approach

 

You make more posts before I finished mine lol - well the question about fading in and out is a loaded question.  You should look into the "Gdip" library and experiment around it. I unfortunately lost my examples I made of making images fade in or fade out so don't have anything to share. If you have RocketLauncher you can look at some of their scripts too because it's exactly how they accomplish their Fade In/Fade out screens, which is the RocketLauncher equivalent of Startup and Shutdown Screens. You can also use that library to make "perfect transparent images". Combining both of those functions is how RL employs their bezels. I figured out how to do both fade in/out and perfect transparent image, but couldn't figure out how to combine both functions simultaneously. That was also quite some time ago and my skills have improved so maybe I should revisit it sometime.

 

You could just make the game/emulator window also AlwaysOnTop. You can have more than one window declared "AlwaysOnTop". Whichever is executed more recent will be at the top of the window stack. It would be a more straight forward method for the same goal

  • Like 1
Link to comment
Share on other sites

Hey @skizzosjt,

The idea of adjusting Start Screen times is a good idea. However, my issue with that is every game seems to take a different amount of time to start. Even the same game can vary in start time. (Hard drive was just asleep, the game is still in memory, etc..)

The issue with +AlwaysOnTop for the game itself is that you would have to make a different startup script for every Windows game, since each game has it's own uniquely named executable. It's a very solid solution though if you do that. I've considered it.

The RocketLauncher idea is a good one. I didn't think about that.

I did get my script to work, now I just want the black screen that covers BigBox when loading and exiting games to be able to fade in and out.

Thanks for the suggestions. I appreciate your help.

  • Like 1
Link to comment
Share on other sites

38 minutes ago, bbweiners said:

I just want the black screen that covers BigBox when loading and exiting games to be able to fade in and out

Maybe setup a timer (or a For loop with a sleep timer?) and then WinSet the Transparent Level of your black screen.  Adjusting from 255 to 0 (fade in) or 0 to 255 (fade out)

 

If you have or can get the GUID of your black screen window...

DllCall("AnimateWindow","UInt",GUI_ID,"Int",1700,"UInt","0xa0000") ; Fade in


DllCall("AnimateWindow","UInt",GUI_ID,"Int",1700,"UInt","0x90000") ; Fade out

1700 is the fade duration (larger number longer).

GUI_ID is, well... you guessed it.  The GUID of the window you want to fade.

 

Edit: per Microsoft docs, "AnimateWindow function (winuser.h)"  Re: the "fade duration" (as I called it) is: 

Quote

The time it takes to play the animation, in milliseconds. Typically, an animation takes 200 milliseconds to play.

So looks to be a value of 0 to 200.

Edited by JoeViking245
Clarify 'fade duration'
  • Like 2
Link to comment
Share on other sites

I got the DllCall to work, but it doesn't really "fade". It looks basically the same as closing a window via it's X button. It hides the window, but I found no way to adjust how quickly it does it. It disappears immediately. No matter what value I put in the fade duration parameter it looks the same. 0, 200, 17000, 200000, blank (no value), type in some random nonsense kfdsaklioiojklk0389, looks the same lol. I might be misunderstanding what the purpose of the DllCall is though?

 

Now I feel like a boob about WinSet, Transparent though! I apparently totally glossed over that long ago and thought AHK could only change transparency of a single color value. That's why I end up resorting to Gdip. I had no idea there were native commands to change transparency value of an entire window consisting of many colors! This is a game changer for me! This works as I would have hoped it does. So happy JoeViking245 brought this up!

 

I had something like this going last night. using a loop to change the transparent value each iteration. Adjusting the change of the value each iteration, or the speed of the loop will give you a different fade appearance, slower/faster/smoother/rigid steps kinda stuff.

TransValue := 255
Loop
{
	WinSet, Transparent, %TransValue%, <WinTitle Here>
	TransValue := TransValue - 5
	If (TransValue <= 0)
		Break
	Sleep, 100
}

 

A timer version of the above would be like this

#Persistent
TransValue := 255
SetTimer, ChangeTransValue, 100
ChangeTransValue:
WinSet, Transparent, %TransValue%, <WinTitle Here>
TransValue := TransValue - 5
If (TransValue <= 0)
	ExitApp

 

Edited by skizzosjt
adding timer version
  • Like 2
Link to comment
Share on other sites

47 minutes ago, skizzosjt said:

a loop to change the transparent value each iteration.

Nice!

I'd be inclined to do it all with the TransValue adjustment and remove the Sleep timer altogether.  (one less thing in the mix)

To reduce the code a little more and still get the same result

TransValue := 255
;Fade Out
While (TransValue >= 0)
{
   WinSet, Transparent, %TransValue%, ahk_exe notepad.exe
   TransValue := TransValue - .25
}

;Fade In
While (TransValue <= 255)
{
   WinSet, Transparent, %TransValue%, ahk_exe notepad.exe
   TransValue := TransValue + .75
}

 

  • Like 2
Link to comment
Share on other sites

18 hours ago, bbweiners said:

The idea of adjusting Start Screen times is a good idea. However, my issue with that is every game seems to take a different amount of time to start. Even the same game can vary in start time. (Hard drive was just asleep, the game is still in memory, etc..)

I wanted to test this before commenting, but whenever I have a game that exceeds the Startup Screen Delay the Startup Screen turns into a blank black screen and keeps waiting until the game window appears. That's why I thought using AHK was unnecessary. The Startup Screen behavior is different for you? For example, turn it down to a short duration like 1 sec and if game takes 10 secs to show, the last 9 secs are going to be blank black screen. If you turn it up all the way to 30 secs, and game take 35 secs to show, last 5 secs will be blank black screen, at least that's how I've noticed this feature behave for me.

 

11 minutes ago, bbweiners said:

I can't figure out how to switch from transparent to black.

The transparency value in AHK is 0 - 255. 0 being 100% transparent, and 255 being 100% opaque. So you would want to switch that stuff around to do a fade in. Starting with 0 and adding to the value rather than subtract

Joe has nice condensed example of fade in and fade out now!

If my examples got changed from fade out to fade in, they get those couple things switched like this.

TransValue := 0
Loop
{
	WinSet, Transparent, %TransValue%, <WinTitle Here>
	TransValue := TransValue + 5
	If (TransValue >= 255)
		Break
	Sleep, 100
}

 

#Persistent
TransValue := 0
SetTimer, ChangeTransValue, 100
ChangeTransValue:
WinSet, Transparent, %TransValue%, <WinTitle Here>
TransValue := TransValue + 5
If (TransValue >= 255)
	ExitApp
Edited by skizzosjt
correcting code
  • Like 1
Link to comment
Share on other sites

@skizzosjt,

That's correct about how Startup Screens work for me. The Startup Screen will be up for a couple of seconds, and if the game hasn't loaded, it will just go back to BigBox. It will sit at BigBox for however long it takes to load the game. That's why I wanted to do this Black Screen thing. I thought it was really clumsy and weird to have a Startup Screen fade in, sit there for a couple of seconds, fade out back to BigBox, then eventually show the game.

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