Hey guys, I've finished my little calculator and now what I want to do is this:
I want to be able to run it in the background until I press, say, Control + C and then have it open...is this possible in OS X? I recall it being pretty simple in Windows...where should I begin to look?
I feel like it will involve running as a service or something...
One solution is to have your calculator provide a Service. A Service can be assigned a global key combination. When the combination is pressed, your calculator application can open, and ideally, perform a task on the user's current selection.
To assign a service a specific key combination see:
System Preferences > Keyboard > Keyboard Shortcuts
An alternative approach is to create a background application. This application can register for a global hot key combination. When the combination is pressed, the background application can launch your calculator.
Maybe a setting up a global hotkey.
I found and use the example here. Which works really well.
There where mixed thoughts on if apple would fully deprecate the Legacy API used,And I think
there is a new API. But for the life of me can not find it again.!
Ah! found it it was in the NSEvent Class Reference : * addGlobalMonitorForEventsMatchingMask*
Related
Normally user is doing it by clicking right-mouse into console title bar then selecting "edit" and finally "mark". -> http://www.megaleecher.net/Copy_Paste_Text_Dos_Window
So is there a way of doing it from a console application either by sending a message/api call/keyboard sequence to its own window ?
If this is your own application and you want the richer behaviour and flexibility of a windows app rather than a console app, then use a windows app. Otherwise, you can try to automate the steps by simulating the input via SendInput. I would advise against doing this because it requires two steps (once for right-click, once to select 'Mark'). This means if someone clicks something else between these two events, your sequence will be broken. Furthermore you are really relying on the automation of an implementation detail which is prone to change at any point.
Looking through the Console Functions, it doesn't appear as though anything exists for setting the selection. The closest is going the other way with GetConsoleSelectionInfo.
If you want to process the information that is within a console application, a better alternative is to pipe it to your own process and deal with it there.
Found: PostMessage(GetConsoleWindow(), WM_COMMAND, 65522, 0);
Hey guys, this question might be a little weird worded but I was looking to see if there was a way to add on to an executable. IE: I use the pandora one desktop application which works perfectly except it doesnt have global hotkeys. The hotkeys only work when the program is the active window. I was thinking of making something that would trick the client into thinking it was the active window when it wasn't so I could use the hotkeys globally.
This question could be generalized to any program (.executable) out there for windows. Is there a way to add on to a "finished" program?
Thanks!
What you could do is write an application that registers global hotkeys, then SendMessages the other application.
Here is a C# example:
Send key strokes to another application C#
or
http://www.codeproject.com/KB/cs/SendKeys.aspx
Is there a way to get a list of globally available shortcuts on a Windows system, including 3rd party software?
Random examples:
WndHop - WinKey + Enter to move a window between monitors
Dexpot - Ctrl + Spacebar to open task switcher
Launchy - Alt + Spacebar
My goal is to track down shortcut conflicts. Most of the above software can be customised to change the shortcuts aside from WndHop, the later which is not working for me, probably due to a conflict. Currently winkey+enter toggles a windows normal size and maximised, I'm not sure what introduced this shortcut.
I can't see that it would be possible to find all 3rd party short cuts. If an application has created a global keyboard hook to listen for a certain keyboard event there's no way that Windows can tell which keys will make it do various things.
Gathering a universal Shortcut list seems like rather a long winded way to achieve the result you want.
Instead I would suggest a process of elimination.
Start to eliminate apps running on your machine one by one by killing them off using either Task Manager or Process Explorer.
After killing off each of your programs, attempt the key combo in question again and if the action still occurs, then you have not yet found the program in question.
Eventually the effect in question will cease, and you'll know that the last app you killed off was causing this behaviour.
I have created an NSStatusBar cocoa application which sits in the system status bar.
I want to assign a hotkey so that when pressed it toggles my applications and show the menu.
Is this possible?, In my searching and experimenting I have found a few different ways of assigning global hot keys that can be pressed when your application is in the background but I can't find any way to problematically make the menu show.
Is this possible?, If anyone thinks a way of assigning a global hotkey is best please post it.
Thanks.
One of the hotkey tutorials I found was on http://dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-easily/ for anyone interested.
If you're targeting 10.6+, there's some new API for NSEvent that can do global hotkeys. For more information, check out this awesome blog post: http://cocoakids.net/global-hotkeys-in-cocoa-on-snow-leopard
EDIT (a long time later)
Tooting my own horn a bit: I could never get things like PTHotKey and other libraries to work the way I was expecting, so I eventually gave up and wrote my own HotKey wrapper. It has a very simple API (you give it a key code, modifiers, a target, and an action), that even supports fun things like 10.6's blocks. You can download the source here: http://github.com/davedelong/DDHotKey
There is an actual hotkey API, which still exists in Snow Leopard and is available in 64-bit. It's designed specifically for this purpose, unlike the NSEvent methods, which are essentially just a block-based wrapper around CGEventTaps.
The difference is that the NSEvent methods (or CGEventTaps directly) make you look at every event that comes in, whereas the hotkey API only calls your function when the user presses your hotkey.
I'm looking for a way to programmatically detect hotkeys in the system. My app supports configurable hotkeys to do different things, and I'd like to be able to tell if another app has snagged one already or it's a built-in Windows hotkey (like Win-L to lock the workstation).
And if it is another app that owns the hotkey, I'd like to be able to show that to the user. At least the name of the exe.
I'm aware of three ways to do hotkeys:
System hook using standard API's
Using the hotkey feature in the properties dialog for a shortcut
Polling async key state and responding
I doubt I can detect the third type, but what about the other two? And are there any other situations I need to know about?
I can think of three ways to do it with Standard API:
RegisterHotkey
SetWindowsHookEx(WH_KEYBOARD)
SetWindowsHookEx(WH_LL_KEYBOARD)
With the first approach, you will get in the return value whether another application already registered the very same hotkey (or whether a shortcut uses this hotkey, or Explorer.exe registered the hotkey because it is Win+E or win+R). You don't get the application name this way, though.
Using Windows Hooks or async key states for "hotkeys": I don't think it is possible to detect hotkeys there, since you might use hotkeys in a context (like replace "t" by "irst" if the last four keystrokes were "Fris") that way. You could inject the hotkey using keybd_event (with your window focused) and test if the event "gets through"; on the other hands, some cases of "hotkeys" that are implemented via hooks do not consume the keystroke so it will still get through.
The approach I would use: First make sure that for entering a shortcut, you have to type that exact shortcut into your shortcut box (if that fails, the user will see which application uses it). Then use RegisterHotkey, so you will notice (in future sessions) if another "well-behaving" application tried to steal this shortcut from you.