Make screen black on focus lost?

Get help using Construct 2

Post » Wed Nov 20, 2013 11:05 pm

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?
B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Wed Nov 20, 2013 11:33 pm

@Pennington Games

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.

Take care!
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Wed Nov 20, 2013 11:56 pm

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.

B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Thu Nov 21, 2013 12:03 am

@Pennington Games

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)
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Thu Nov 21, 2013 12:31 am

Here is the sample I been working on it shows the last suggestion still not what I am thinking should happen.

Again Thanks @SpaceApe always nice to get replies :)


https://dl.dropboxusercontent.com/u/223672920/hide%20objects.capx
B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Thu Nov 21, 2013 1:41 am

@Pennington Games

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.

Good luck!
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Thu Nov 21, 2013 10:50 pm

Thanks Again @Space Ape.

I tried a few other ways to achieve my deired result and of course hit walls there too :)

I am curious about execute Javascript as perhaps my solution. I was researching browser focus and ca,e across this Demo that is what I want to do. In that demo the page goes black if browser loses focus. Even a right click on the status bar will invoke it. this could be perfect if I can understand how if at all possible to use.

http://www.thefutureoftheweb.com/demo/2007-05-16-detect-browser-window-focus/
B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Thu Nov 21, 2013 10:59 pm

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.)
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Fri Nov 22, 2013 12:32 am

@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
B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Fri Nov 22, 2013 12:56 am

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.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Next

Return to How do I....?

Who is online

Users browsing this forum: beohs, Elliott, Yahoo [Bot] and 11 guests