Can I assign a global hotkey to an Adobe AIR app? - air

Is it possible to assign a global hotkey to a specific feature in an Adobe AIR app, i.e. the app feature responds to the hotkey whether the app is active or not (it must be running of course, but only in the system tray).

I don't this it's possible with Adobe AIR itself. The only method I can think of:
Install 3rd party hotkey application (like AutoHotkey or HotKeyBind)
Configure hotkey application to make CTRL+ALT+Q to launch
"c:\programs\thvo42\coolapp.exe --hotkey q"
In your AIR application, register for the NativeApplication.invoke event, and watch for arguments like '--hotkey q' to know that the Q hotkey was pressed, and then act accordingly.
Of course, this is kind of a hassle, maybe with some hacking you can roll it all into a single install file.

From the Reference Manual:
To listen globally for key events, listen on the Stage for the capture and target or bubble phase.

SWFKit creates a wrapper around your flash/flex movie, and allows access to system DLLs and other goodies, but unfortunately it would export as an .exe, so windows only and no AIR.
ASFAIK, there is no support for it by using AIR alone.

Related

How can i keep focus on my own application or regain it when lost in delphi? [duplicate]

I need to create a simple Delphi application, kiosk style.
It is a very simple thing, a single form where the user writes some personal info to register to an event. 4 TEdit and a TButton.
What I want to achieve is to avoid the user does any action different then typing in TEdit or clicking on the TButton. For example I don't want he does ALT TAB (switchin applications), pressing windows key on keyboard, doing ctrl-alt-canc, etc...
I can add a passowrd protected Button that enables/disables this "Kiosk mode", in this way as I need to exit the kiosk mode I simply press that button and exit.
How to achieve this "kiosk mode" in Delphi without intercepting all the keystrokes manually? Or did anyone already develop this so it can be shared?
I think you'd better create a new desktop, and run your app in there. When your app is done, you can bring back user's desktop. That is how Windows login screen works. Of course Windows login screen uses a special secure desktop. Your app in a separate desktop would be isolated. You will have a desktop background with no start menu, taskbar, or desktop icons because explorer.exe is not running there automatically. Of course a can start a new process, using Task Manager, but desktops in Windows are securable objects; therefore, you can make restrictions if you want. Of course if your app has sufficient permissions.
To create a new desktop, you can use CreateDesktop Windows API, and to switch to the newly created desktop, you can use OpenDesktop function.
You can try Change the Windows Shell.
When you start windows, you don't execute the default shell (explorer.exe), you can execute your application.
Al internet you can find alternative Shell (more attractive) to default windows like:
BlueBox or
SharpE
This option is used for purposes similars at the application that you are developing. Kiosks or TPV.
For change the default applicacion you must modify a registry key:
In Win3.x and Win9x, SYSTEM.INI file:
[boot]
shell=MiAplicacion.exe
In Win2k and WinXP, use Registry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
Shell=MiAplicacion.exe
If you test this option, think the mode to turn the configuration to the original value (button or option). You must reboot to test changes.
ADDED: In addition, if you search on the web some similar at this "Delphi Change default windows shell", you can find more code, samples and information about this.
Regards
P.D: Excuse me for mistakes with english.
Well but if someone can open the taskmgr he could just create a new task and run explorer.exe from there so its not really secure though...
Ok Taskmgr can be stopped with policies...
Well and for disabling the cad sequence you can use saslibex which Remko Weijnen had created you can find it here: SASLibEx
kindest regrads,
s!

How to check file info, which is double-clicked in finder, in preferred application? This is for os x

I want to implement some application, which is called as preferred app when users double click file of some type (ex. ".test") in finder.
To implement this, I have a question.
I want to know the file infos in the preferred application which is implemented by me.
To test this, I make an application.
I only implement a main function which has to print "argc" and "argv".
I register this app as preferred app for ".test" file extension (ex. something.test).
When I double-click "something.test" file in finder, it executed my app and my app printed that argc is "2" and argv are "/Users/appchemist/myApp.app/Contents/MacOS/myApp" and "-psn_0_225954"
So, I have no idea.
An app usually does not receive the file to open as an argument to its main() function.
When you open a file, your app is launched if it's not already running.
Whether it was or wasn't already running, it is then sent an "open documents" ('odoc') Apple Event. The standard handlers for this Apple Event within Cocoa will call your application delegate's -application:openFiles: or -application:openFile: method, depending on which it implements.
The reason that Apple Events are used rather than arguments to main() is precisely because apps need to be able to open documents even when they are already running. Arguments to main() are only useful at launch, which is not good enough, so they aren't particularly useful at all for this purpose.
See Cocoa Scripting Guide: How Cocoa Applications Handle Apple Events – Apple Events Sent by the Mac OS for more details.

How to emulate mouse clicking/mouse moving/key typing in the global context?

Emulate means to invoke these events programatically.
Global context means that these event invocations should affect the whole desktop (sort of global environment) rather than the application which produces them. Moreover, the application itself should have no windows - it has to simply execute in background and produce these events due to some logic. In other words, if, for example, this application puts mouse in "global" arbitrary position and invokes a double click event and there is an icon of some other application under the cursor then this "other" application should start.
Which library can I use to achieve it?
Note: I don't specify OS since I hope that the library is supposed to do it in a cross-platform way. If that's not possible then I will be fine with the Windows only solution.
I found out that Java's java.awt.Robot has all requested features.

how do I observe keyboard input event while the applicaion is not actived

how do I observe keyboard input event while the applicaion is not actived.
You'll need to create a CGEventTap using Quartz Event Services. The user must have access for assistive devices turned on, which makes sense, because that's the only legitimate reason for you to do that.
If you want to set up a hotkey, there's an API in Carbon Event Manager for that, and a Cocoa wrapper named SGHotKeysLib. Note that the Carbon Event Manager hotkey API is still supported in current, 64-bit Mac OS X.

Cocoa global shortcuts?

I want to create a global shortcut for my app. I've used the 'cool new way' of doing this with the addGlobalMonitorForEventsMatchingMask method. The problem is, my events don't get "consumed": my shortcut includes the spacebar, so whenever I use the shortcut, Quicklook pops up when I'm in the Finder.
How can I prevent this from happening? I know it's possible, because many apps, for example the Bowtie iTunes controller app, do it.
addGlobalMonitorForEventsMatchingMask: is not a suitable replacement for the existing Carbon Hotkey API for all sorts of reasons; it's horribly inefficient, for one. And from the docs:
... you can only observe the event; you cannot modify or otherwise prevent the event from being delivered to its original target application.
and
Key-related events may only be monitored if accessibility is enabled or if your application is trusted for accessibility access
The Hotkey API is still the only way to implement global shortcut in OS X. But unlike many Carbon APIs, the Hotkey API is available to 64-bit apps.
Use the hotkey API, which is meant for this purpose.