OSXvnc
OSXvnc copied to clipboard
Try to login Mac By TightVNC client fail(update)
HI ! I download the newest source code and use it to control My Mac.It look likes all well.However,when I Try to used it to Login Mac(no any users login before),it did not work,then the screen can not update again. the Screen keeped the state before I type anything;
I want to know If I do something Wrong?
Thanks
Update: I find some artice wrote that CGEventPost not work preLogin,so I replace it with CGPostKeyboardEvent.Then all goes well.
I do not know why!
Please be more specific.
@pan2636119599 : could you please send me your code improvement, either as a pull request on GitHub or here as a comment?
Thanks, Stefan
@stweil I have created a pre-login agent which uses CGEventPost for simulating keyboard. FYI I am developing a remote control app similar to yours.
Keyboard
CGEventRef keyEvent = CGEventCreateKeyboardEvent( NULL, keyCode, down ) ;
CGEventPost( kCGHIDEventTap, keyEvent ) ;
CFRelease( keyEvent ) ;
Mouse
CGEventRef event = CGEventCreateMouseEvent(eventSource, eventType, mouseLocation, mouseButton );
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
Pre-login launch agent
Pre Login
<?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, I get the following in the Console logs after login
Untrusted apps are not allowed to connect to Window Server before login. I have searched o chromium's remote control (which has keyboard and mouse simulation working) source code. They use CGEventPost for keyboard, but it works in login window.
https://cs.chromium.org/chromium/src/remoting/host/input_injector_mac.cc?rcl=0&l=42
They seem to use a sh file in privileged helper tools directory and use to to load the service, I tried putting our service in prieveleged helpers tool, but still the event handling fails.
The Deprecated API CGPostMouseEvent, CGPostKeyBoardEvent work without problem , but would really like to know how non deprecated keyboard API works in chromium
https://stackoverflow.com/questions/41429524/how-to-simulate-keyboard-and-mouse-events-using-cgeventpost-in-login-window-mac
This may help solve this bug in your remote host too.
@stweil I solved this after long and arduous search, shall I give a pull request, it comes down to adding stuff to ldflags?
Yes, please.
Hey sorry @stweil , forgot about this thread. If I have the time I will give pull request, but you can fix it yourself.
Refer this answer
https://stackoverflow.com/questions/41429524/how-to-simulate-keyboard-and-mouse-events-using-cgeventpost-in-login-window-mac/41607430#41607430
Appears that keyboard input doesn't work on a "default login screen" (before anybody has yet logged in) though mouse works fine there and everywhere else, and keyboard works everywhere else. I attempted some of the link options mentioned and didn't have much luck, though I didn't look too closely...
For me, while running system server on macos 10.13.2, keyboard does not work too on login screen. So system server is actually unusable in my case.
I have been able to get it work on Mojave following the stackoverflow article posted by sai-prasanna
@romanprocopie do you have a git diff or anything? I could never get it to work...
@rdp have a look in the PR, worked out the box tbh
Thank you to all who participated in the discussion here.
I merged pull request #39, so hopefully this issue is fixed. Please test and report your results.