Skip navigation.
 
mlRe: Setting Cursor from Background (Re: Hotkey/Cursor/Windowing questions)
FROM : daniel
DATE : Tue Oct 12 18:13:32 2004

Oh - and a caveat:  many applications (I think mostly Carbon PowerPlant 
applications) obsessively set the cursor, which has the effect of 
constantly undoing your cursor setting when you're doing it from the 
background.  I haven't figured out yet how to overcome this.

Daniel

On Oct 12, 2004, at 9:02 AM, daniel wrote:

> I ran into this a year or two ago.  I ended up solving this by looking 
> carefully at what programs like the "screen capture" do.  I ended up 
> with this (TOTALLY UNSUPPORTED) wokraround, which uses TOTALLY 
> UNSUPPORTED, undocumented calls.  If getting the behavior is more 
> important than following the rules, this might be useful.
>
> The fact that there is a property named "SetsCursorInBackground" is at 
> least indicative that there is no easy workaround to the problem.
>
> #if EXPLOITBACKGROUNDCURSORHACK    
>            long sysVers = GetSystemVersion();
>
>            // This trick doesn't work on 10.1
>            if (sysVers >= 0x1020)
>            {
>         void CGSSetConnectionProperty(int, int, int, int);
>         int CGSCreateCString(char *);
>         int CGSCreateBoolean(BOOL);
>         int    _CGSDefaultConnection();
>         void CGSReleaseObj(int);
>         int propertyString, boolVal;
>         
>         // Hack to make background cursor setting work
>         propertyString = CGSCreateCString("SetsCursorInBackground");
>         boolVal = CGSCreateBoolean(TRUE);
>         CGSSetConnectionProperty(_CGSDefaultConnection(), 
> _CGSDefaultConnection(), propertyString, boolVal);
>         CGSReleaseObj(propertyString);
>         CGSReleaseObj(boolVal);
>            }
> #endif
>
> On Oct 12, 2004, at 12:51 AM, Sloan Kahsen wrote:
>

>> Hello everyone,
>>
>> Thanks to some code I've been cobbling together from here and various 
>> online sources, I've been able to get somewhat close to what I'm 
>> trying to do... My goal is to have a hotkey be hit, then the cursor 
>> change, an invisible (transparent) window appear above all others, 
>> and then I'm going to do an action on that window. Here is my hotkey 
>> code:
>>
>> - (IBAction)hitHotKey: (id)sender
>> {
>>     [NSApp activateIgnoringOtherApps: YES];            
>>
>>     if (fingerCursor == nil)
>>     {
>>         fingerCursor = [[NSCursor alloc] initWithImage: [NSImage 
>> imageNamed: @"myPic"]
>>         hotSpot: NSMakePoint (0, 0)];
>>         [fingerCursor set];
>>     }
>>     else
>>         [fingerCursor set];
>> }
>>
>> Problem 1) If I *don't* have the activateIgnoringOtherApps, I can't 
>> get the custom cursor to appear, however when I do have it, it brings 
>> my app frontmost, but I don't get the cursor (though I see it for a 
>> second). The cursor remains an arrow until I activate the key 
>> sequence again.
>>
>> Problem 2) Actually I want to *not* have my app come frontmost when I 
>> activate this hotkey. I suppose if my cursor could simply change and 
>> then if I could put a transparent window above all others, I would be 
>> set (similar to the functionality of Quicksilver for example - hit a 
>> hotkey, window comes up but you are still in your frontmost app even 
>> though QS is taking your keystrokes). My hang up is the cursor change 
>> while the app is in the background. The Finder can do it if you 
>> perform the key sequence command-shift-4-space for example (camera) 
>> even while in the background (or is it a function of the dock?) Any 
>> tips or insight on this would be greatly appreciated!
>>
>> Thanks.
>>
>> Sloan
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list      (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>-
>> sweater.com
>>
>> This email sent to <email_removed>

>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>-
> sweater.com
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlHotkey/Cursor/Windowing questions Sloan Kahsen Oct 12, 09:51
mlSetting Cursor from Background (Re: Hotkey/Cursor/Windowing questions) daniel Oct 12, 18:02
mlRe: Setting Cursor from Background (Re: Hotkey/Cursor/Windowing questions) daniel Oct 12, 18:13