|
|
|
@ -2,11 +2,13 @@ package xyz.wbsite.jmacro;
|
|
|
|
|
|
|
|
|
|
import com.melloware.jintellitype.JIntellitype;
|
|
|
|
|
import javafx.application.Application;
|
|
|
|
|
import javafx.application.Platform;
|
|
|
|
|
import javafx.fxml.FXMLLoader;
|
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
|
import javafx.scene.image.Image;
|
|
|
|
|
import javafx.stage.Stage;
|
|
|
|
|
import xyz.wbsite.jmacro.ui.FXMLUtil;
|
|
|
|
|
import xyz.wbsite.jmacro.util.DialogUtil;
|
|
|
|
|
import xyz.wbsite.jmacro.util.ResourceUtil;
|
|
|
|
|
import xyz.wbsite.jtask.TaskImpl;
|
|
|
|
|
|
|
|
|
@ -49,9 +51,14 @@ public class JMainApplication extends Application {
|
|
|
|
|
stage.show();
|
|
|
|
|
JMainApplication.primaryStage = stage;
|
|
|
|
|
|
|
|
|
|
// 创建独立线程处理JIntellitype初始化
|
|
|
|
|
Thread hotkeyRegistrationThread = new Thread(() -> {
|
|
|
|
|
try {
|
|
|
|
|
JIntellitype.getInstance().registerHotKey(F1_SHORTCUT, JIntellitype.MOD_CONTROL, KeyEvent.VK_F1);
|
|
|
|
|
JIntellitype.getInstance().registerHotKey(F2_SHORTCUT, JIntellitype.MOD_CONTROL, KeyEvent.VK_F2);
|
|
|
|
|
|
|
|
|
|
JIntellitype.getInstance().addHotKeyListener(identifier -> {
|
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
|
switch (identifier) {
|
|
|
|
|
case F1_SHORTCUT:
|
|
|
|
|
mainController.onStart();
|
|
|
|
@ -61,6 +68,19 @@ public class JMainApplication extends Application {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} catch (UnsatisfiedLinkError e) {
|
|
|
|
|
Platform.runLater(() -> DialogUtil.error("缺少必要的系统组件(VC++运行时)"));
|
|
|
|
|
} catch (NoClassDefFoundError e) {
|
|
|
|
|
Platform.runLater(() -> DialogUtil.error("热键功能依赖库未找到"));
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, "Hotkey-Registration-Thread");
|
|
|
|
|
// 启动线程(设为守护线程,避免阻止JVM退出)
|
|
|
|
|
hotkeyRegistrationThread.setDaemon(true);
|
|
|
|
|
hotkeyRegistrationThread.start();
|
|
|
|
|
|
|
|
|
|
// 服务初始化
|
|
|
|
|
JMainService.init(new TaskImpl(), new File("legend"));
|
|
|
|
|