Hi I am trying to figure a way to when my browser is not in focus that I can make a different layout visible. For the purpose of not being able to capture the image with a screen capture....
Idea is for an art gallerey that when focus is lost the screen goes black....
Upon pressing any key the screen will go black....
theory is two layers on visible as gallerey and controls to scroll through.
Other being the black layer which will be on top but invisible until needed.
So basicly I need to know if there is a way to check for the browser being in focus or not.
Thanks I am working on this but do not see this feature?
Found this under 'Browser' in the manual:
"Page is visible
True if the page the HTML5 game is running on is currently visible. The page counts as hidden if the window is minimised, the page is in a different tab to the one being viewed, or on a mobile device when the app goes in to the background. When the page is hidden the game automatically pauses."
I haven't used it, but it sounds like it would fit your needs. Add an event 'Browser - Page is Visible'; make your black overlay invisible for that condition and visible on an 'Else' condition.
Thanks for the reply I did see and try as you also have written prior to my posting the question.
It seems this will only check for is the tab the game is on active. When tab is not active the game is not visible so no need for cover up. I want this to be when the actual browser is not in focus. Such as a screen capture software takes focus. and also will use on any key pressed to prevent shortcuts to launch a capture device.
an example to test would be have game running and then open any window but only cover part of the browser. There should be a way to know the game is out of focus at that point. perhaps it is not in CS2 ability yet.
Whenever those conditions that you mention are present, the game pauses. So having your game window partially covered should pause the game, correct?
Maybe the 'Browser > On Suspended' event would work? Black out the screen if it's suspended and show the screen when it's resumed? (Browser > On Resumed)
Develop games in your browser. Powerful, performant & highly capable.
Here is the sample I been working on it shows the last suggestion still not what I am thinking should happen.
Again Thanks — always nice to get replies :)
Hmmm... it seems you need a very specific function for this to work. Probably beyond my expertise! Hopefully, someone more knowledgeable swoops in with a solution.
Thanks Again space Ape.
I tried a few other ways to achieve my deired result and of course hit walls there too :)
These days clicking the print screen key will capture the screen without any 3rd party software or anything else needing to be opened. Programs running wont even lose focus so you may be attempting to do something that isn't going to end up helping much in the long run. (Hopefully I'm wrong, just something to keep in mind.)
Burvey I think you may be right I thought that using the command like on any key pressed with my above request would cover this. However I moved on to the any key pressed and while I can disable the windows built in screen capture I was unsuccessful in detecting a hotkey prior too it already grabbing the screenshot. That's a bummer. Thanks for Reply I am going to look further I now know it's not built in and will need some form of coding on my part so if I am going to code it mayve I can code a key press checking sytem that will go in front of other hotkeys.... Just rambling here LOL
You really got me thinking about ways to beat the screen capture. I did some searching around and there is one novel idea, but I'm not sure if it would work in your case, or at all for that matter. But the idea is to take your images and pixelate them down into 3 or 4 different images then switch between them quickly enough that the human eye can't tell the difference. In theory when the computer gets a screenshot it will only get one part of the image filled with transparent holes.
Good luck, I hope you can figure something out. Please let us know if you do.