I want to build an app that does something when the user pushes a (keyboard) button, no matter what app is currently running in the front. (Like "CheatSheet")
How can I do this?
Do you mean keylogging input from other apps? If so, this is not possible due to obvious security concerns.
Related
I am trying trying to bring an application that is in the background to the foreground by binding to a key-press from the user even when the application does not have focus.
The affect I want is exactly like Quicksilver / Alfred / Spotlight.
Is it possible to do this without having the user mess with any Settings inside Accessibility?
Or is this functionality prevented for security reasons? It seems some people have managed to get around this
Thanks!
PS: I am working off the example from apple with rounded window / transparency:
https://developer.apple.com/library/mac/samplecode/RoundTransparentWindow/Introduction/Intro.html
Registering a Global Event Listener is what you're looking for.
You can then read global key presses and call [NSApp activateIgnoringOtherApps:YES]; on the desired key press.
If you also want the user to be able to customise that shortcut, use MASShortcut.
I'm working on an app that changes the lock screen background, and I would like to know when the user turns on his phone and looks at the lock screen.
The reason for my question is that if I know that the background has been watched, I will be able to replace the background.
There is no way to do what you're describing. When your application isn't running, you have no information whichever about user's activity.
You cannot do that. If your lockscreen is activated you cannot Access to App data, for security reason.
So, as KooKiz said there is no way to do that.
I am developing an app that allows the user to make certain changes to tiles on the Windows 8 start screen. When a change has been made within the app, the user will be shown a "View my changes" button. Clicking the button should bring the user back to the start screen.
I have looked into different ways of closing/suspending the app programmatically (and thus taking the user to the start screen), but I have not found a way to achieve this using WinJS. Throwing an exception closes the app, but this seems like a very dirty workaround. Any suggestions?
I'm assuming you are creating secondary tiles and want to show the users what they look like? #mydogisbox is right in that this kind of functionality has probably been deliberatly excluded.
I'd recommend to just do an in-app 'view changes' of whatever changes to secondary tiles the user might have made. In general, I'd argue that this would be a better user experience because you will keep the user engaged within your application and not be essentially kicking them out of the experience.
Can a WinRT app continue to run while Screen Off?
I know that a WinRT application can create a Background Task that periodically executes even when the application is not running. Handy, but not what I am asking. What I am asking is, when the user clicks the power button and invokes Connected Standby, is there anything an app can do to remain active. Can it ask for some special capability?
Example - in Windows Phone there is a handy Running and Walking app that keeps track of "where you are" while it is running - then tallies your distances, etc. Even when the screen is off! Turn the screen on and the "where was I" map is up-to-date. Is this type of application possible in WinRT?
I've been looking into the same thing recently, and unfortunately it seems that what you want to do isn't possible with WinRT.
Why don't you use Background task to simulate what you are trying to achieve. When the user starts the app again, you could have the info populated to the latest data by looking at the store where the background process updated. Just a thought.
How would I go about locking a screen like Keychain does, meaning preventing all access to Dock, menubar, desktop, etc. Basically just a black screen that I can add a password field to, for the user to return to the desktop? I am well aware of the Carbon method, but I want the NSApplication method because this is an all Cocoa application.
Thanks~
If you can get away with not writing this code yourself, all for the better. It is usually a terrible idea to write your own code to lock the screen, considering the number of vulnerabilities that have been found in screen locking code over the years. If you have a Carbon call that can do it, go ahead and use that... don't worry about the "purity" of your Cocoa code.
However, if you decide to write this yourself, here's what you do:
First, capture all the screens using CoreGraphics. See: http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayCapture.html
Next, create a new NSWindow and put it in front of the window that's used for capturing the screens. You'll have to call a CG function to get the "order" of the black window covering each screen, and order the new window in front of that. Normally, the black window has an order so far forward that everything is behind it. Put a password field in the window. Do NOT use an ordinary text field or write your own code for password input. The password input field has a ton of special code in it so you can't copy text out of it, and other programs can't listen to keystrokes while you're typing into a password field. So use the one that Apple provides.
Last, put the computer in "kiosk mode". This mode allows you to disable alt-tab, user switching, the menubar and dock, and even the ability to force quit. See: http://developer.apple.com/mac/library/technotes/KioskMode/Introduction/Introduction.html
It's not a lot of code, it just uses a few different APIs so you'll spend most of your time bouncing between API docs. I suggest writing the screen lock code as its own application (just add a new application target to your Xcode project) and then put the screen locker inside your application bundle. This used to be (as of 10.4) how Apple Remote Desktop implemented the "Lock Screen" functionality, but I can't find the app anymore.
I believe the Cocoa replacement to the SetSystemUIMode API was not introduced until 10.6.
If you can live with Snow-Leopard-only code, the answer is - setPresentationOptions: on NSApplication.