Simplest way to blank the Macintosh display until a key is pressed? - macos

What is the simplest way to blank a Macintosh screen (completely black) and unblank it only on keystroke (not mouse movement)? I'm happy to pursue any of these implementations:
Create a completely custom program that blanks the screen (or turns off the display) and awaits a keystroke. (A short gcc/g++ program would be great....)
Create (or locate) a standard "System Preferences" screensaver that ignores mouse events
Some configuration trick that makes the existing screensaver system ignore mouse events
A third-party app, free or commercial
No fancy screensaver graphics wanted - just a blank screen.
I'm an experienced developer (Linux, Windows) but have never written for the Mac. Thank you very much.

Based on your comments on CajunLuke's answer, why not just turn off screen brightness completely when not in use? As far as I know, all Mac keyboards have screen brightness buttons, so you could use them to quickly turn on/off screen brightness when you want to.

Control-Shift-Eject should do what you want. If you have a screensaver password set up, it'll ask for that, too.

Related

How does on-screen (virtual) keyboard works in Win10

I haven't find anything relevant in Google or any Microsoft site about it so I decided to ask a question here.
Everybody knows that in Win-based OS there is a virtual keyboard. I also know that *nix based OS, have it too. So, the question is about:
HOW DOES IT WORK INSIDE?
I mean, let's have an example that I opened on screen keyboard in Windows 10. What's the actual difference between:
input via hardware keyboard: when I'm using it, like I press X button
..and using a virtual keyboard, when I press the same button
Imagine, I have an admin access to terminal/computer, is there any option to track/distinguish that in the second time I pressed button not on hardware keyboard, but on-screen (by mouse clicking) version of it?
And there are also many different software, like AutoIt (yes, it's a language, but it's relevant to this example) that emulating pressing the X button. How does they work in Win-based OS? Do they "in-common" with default on-screen keyboard and using the same driver/WinAPI or there is a difference between them?
And the second case, between:
default on-screen keyboard
compilated AutoIt script
..any other software that emulating press X button
I guess the only way to find out "how exactly button was pressed" is to check current processes list via taskmgr and find out have anything been launched or not. Or I'm totally wrong here, and missing something?
THE SCOPE
I have written a node.js script which emulates button pressing behaviour in windows app.
TL:DR business logic short => open notepad.exe and type `Hello world`
And could someone give me any advice/recommend any powershell/bat script (or any other solution) with demonstration of Get­Async­Key­State check behavior? With which I could easily check my own node.js script (not by functional of it, but by triggering press the X button event)
I found an answer for node.js case here: Detecting Key Presses Across Applications in Powershell
SendInput is the preferred method to generate user input in software. The Windows on-screen keyboard probably uses it for everything except Ctrl+Alt+Delete which I believe has some kind of special handling. The on-screen keyboard is only able to generate Ctrl+Alt+Delete in certain configurations.
Software-generated input is merged with normal hardware input in the RIT (Raw Input Thread) in the kernel.
A low-level keyboard hook can detect software-generated input.

Win7 and multiple monitors: switch focus when moving mouse to different monitor?

I recently upgraded to a dual monitor setup at work, and while the extra real estate is very nice, there's one annoyance: my intuitive reaction is that there are two "active" windows now, namely the topmost window in each monitor -- and I frequently get surprised when keyboard events go to the actual active window, rather than the one I've moused over and am looking at.
There's a setting in the control panel that gives this effect (ease of access -> make the mouse easier to use -> activate a window by hovering over it with the mouse) but it also acts on windows within the same monitor, which I don't want.
I frequently use my ThinkPad's scrolling function on unfocused windows which I don't want to receive focus, which come to think of it probably adds to my confusion, since I can scroll my email in the other window but my keyboard shortcuts don't go there.
Is there any way to achieve this effect or am I just wishing?
Thanks,
Ryan
Yeah, get a Mac :-p
In all seriousness OS X does provide this functionality. It might be worth searching for an add on that does the same sort of thing. I know of Wizmouse -- http://antibody-software.com/web/software/software/wizmouse-makes-your-mouse-wheel-work-on-the-window-under-the-mouse/
There might be more though.
AT LAST!!! Windows 10 has this support :-)
SM
You can change the settings to use classic windows appearance etc. and try to focus on the border color of the window. The board changes on the active window.
I use two monitors and there really isn't much you can do besides change your behavior.
Select things from the taskbar, drag active windows to the same screen and always refer to inactive windows by moving them to the inactive windows monitor and remember to go back to the window you want to be active.

Controlling the windows 7 on screen keyboard position from code

My manager thinks he's seen other people "lock" the windows on screen keyboard to the bottom of their applications, effectively docking it with their window, and wants me to reproduce this. They're using vb6 and occasionally vb.net.
I've done a good amount of googling on the subject and I'm resorting to looking into the windows SDK at the minute, but if someone out there can save me a few days of pain by either confirming that it's not possible or pointing me in the right direction if it is I'd appreciate it.
I find that the keyboard locks if I open it from the taskbar icon. It will stay on the bottom of the screen then, even if I'm not on a text field.
No idea how to achieve that programmatically though

Keyboard in a fullscreen cocoa app

Following up on this ( Display System Keyboard Mac application? ) question, the keyboard is coming up fine, but if my application is in fullscreen mode, the keyboard launches, but remains in the background. How do I get around this? Any help is much appreciated!
Thanks,
Teja
Full screen is, by definition, above other windows and elements. I don't know how well this would work, but you could try asking the view for its -window, then using -setLevel: to lower the window level. Unfortunately, assuming it works at all, this would probably allow other elements (like the dock or other floating panels above your full screen view as well.

Get title of front window in carbon

I am writing a program to sit in the background on osx 10.6, listen to keystrokes and record them, grouping them by window title. (No, I am not writing malicious software. I do not need this program to be sneaky in any way, I just want to have a safety net for when I have typed a huge email and then accidentally refresh the page (APPLE-R) instead of opening a new tab (APPLE-T)) I have already found apple's EventMonitorTest example for the keystroke capturing code, now I just need to find the "key window" title.
Does anyone know where I can find examples for this kind of functionality? Thank you!
A couple of possibilities:
You could use the Accessibility API (though of course keep in mind that 64-bit Carbon does not support this)
You could use the CGWindow functions introduced in Leopard
I suspect the first option will be easier to do this with, since the CGWindow API is somewhat low-level and treats all windows (application windows, menu bars, dock icons, etc.) more or less equally.

Resources