我使用LaunchAgents在登录窗口中运行一个java应用程序,它远程捕获鼠标和键盘事件并执行它。键盘事件可以正常工作,但不能处理鼠标事件。
<?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>com.ash.login</string>
<key>LimitLoadToSessionType</key>
<string>LoginWindow</string>
<key>RunAtLoad</key>
<true/>
<key>Program</key>
<string>/usr/bin/java</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-jar</string>
<string>-Dapple.awt.uielement=true</string> (Works sometimes without this option)
<string>/Library/Ash_Agent/data/remote.jar</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
captureImage.robot.mousePress(InputEvent.BUTTON1_MASK); (在代码中使用)
我无法在loginwindow获得鼠标控制权。在aqua或登录时工作正常。 * 控制台错误: *
Untrusted apps are not allowed to connect to or launch Window Server before login.
Window Server is not available
答案 0 :(得分:0)
我相信这是因为Robot在内部使用CGEventPost而不是弃用的CGPostMouseEvent,但CGEventPost不会使用prelogin。