4

I am a newbie to launch agent and daemons.I have created a pre-login agent and it will launch my application when login window open.I can simulate the keyboard and mouse events with CGEventPost in the user session. Please refer the code

//For Keyboard

CGEventRef keyEvent = CGEventCreateKeyboardEvent( NULL, keyCode, down ) ;
CGEventPost( kCGHIDEventTap, keyEvent ) ;
CFRelease( keyEvent ) ;

//For Mouse

CGEventRef event = CGEventCreateMouseEvent(eventSource, eventType, mouseLocation, mouseButton );
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);

//Pre-login launch agent

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>my app label</string>
        <key>LimitLoadToSessionType</key>
        <string>LoginWindow</string>
        <key>RunAtLoad</key>
        <true/>
        <key>WorkingDirectory</key>
        <string>My app directory</string>
        <key>ProgramArguments</key>
        <array>
                <string>app absolute path</string>
                <string>service</string>
                <string>myservice</string>
        </array>
        <key>KeepAlive</key>
        <true/>
</dict>
</plist>

CGEventPost is not working in Pre-Login window. How to solve it? Is there any alternative way?

boopathy
  • 427
  • 2
  • 9
  • 20
  • I would hope that it's intentional on Apple's part. It is a huge security risk to allow programmatic input on a login screen. – Avi Sep 12 '16 at 07:09
  • Thank you for the information. Now I'm currently developing the remote support application. Citrix, LogMeIn are providing the remote controls in Pre-login window too. Do you know how they do it? – boopathy Sep 12 '16 at 09:33
  • Did you ever figure this out? I'm running into the exact same issue – Gama Apr 13 '22 at 15:31

0 Answers0