0

I'm trying to make a screenshot capture App. The App will first place a semitransparent full screen dark view over other Apps, this will make other Apps not responding to mouse scrolling event. How can I set a view covers other Apps and keep them respond to scrolling event? Thanks.

  1. Ignore MyApp's dark view?

or

  1. Send event to other Apps in MyApp?
 -(void)scrollWheel:(NSEvent *)theEvent {
    NSLog(@"user scrolled %f horizontally and %f vertically", [theEvent deltaX], [theEvent deltaY]);
}

Edited:

Found a way to get a App's pid and Followed @Willeke's reference, write the following code, but not work.

-(void)scrollWheel:(NSEvent *)theEvent {
    [super scrollWheel:theEvent];

    CGEventRef wheelevent = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, 1, theEvent.deltaY, theEvent.deltaX);

    // AppPid is gotten before mouse wheel scrolls
    CGEventPostToPid(AppPid, wheelevent);

    CFRelease(wheelevent);
}
jdleung
  • 1,088
  • 2
  • 10
  • 26
  • Possible duplicate of [How to simulate mouse click from Mac App to other Application](https://stackoverflow.com/questions/41908620/how-to-simulate-mouse-click-from-mac-app-to-other-application) – Willeke Jul 10 '19 at 08:14
  • @Willeke This solution may not fit my need, since I cannot the process id other Apps. – jdleung Jul 10 '19 at 11:10
  • @Willeke I followed your reference but it seems not work, did I make something wrong? I edited the question and posted the code above – jdleung Jul 26 '19 at 14:35
  • It could be a permission issue. Or try `theEvent.cgEvent` instead of recreating the event. – Willeke Jul 26 '19 at 21:24
  • Hello, @Willeke. It did ask for permission when the App ran the new code for the first time, and I have enabled it in system configuration. Code has changed to `CGEventPostToPid(AppPid, theEvent.CGEvent);` – jdleung Jul 27 '19 at 14:42

0 Answers0