首页 > 解决方案 > 如何通过 autohotkey 使用自动化 netbeans ide 格式化我的 java 代码?

问题描述

我想通过将密钥发送到隐藏的 NetBeans IDE 来格式化选定的 Java 代码。我编写了以下脚本

^+b::
sleep 30
Send ^c
sleep 30
run,C:\Program Files\NetBeans 8.2\bin\netbeans64.exe "C:\sample.java",Hide
sleep 1500
ControlSend,,{^v}, "Netbeans"
sleep 50
ControlSend,,{!+f}, "Netbeans" 
sleep 50
ControlSend,,{^a}, "Netbeans" 
sleep 50
ControlSend,,{^c}, "Netbeans" 
sleep 50
WinMinimize,"Netbeans"
sleep 100
Send, ^v
return

但是尝试使用 ControlSend 发送密钥时会弹出隐藏的 NetBeans,并且我无法使用 WinMinimize,"Netbeans" 最小化 Netbeans 窗口。我该如何解决这个问题?

标签: automationautohotkeycode-formatting

解决方案


您不需要使用引号,您的代码将无法正常工作。如果你愿意,你不必使用逗号。

此代码工作正常:

WinMinimize Netbeans
; WinMinimize, Netbeans ; this will work too

使用逗号:

WinMinimize % "Netbeans"

但由于某些程序使用动态窗口名称,您最好按进程名称最小化程序:

WinMinimize, ahk_exe netbeans.exe

此外,您可以最小化活动窗口:

WinMinimize A

更多:https ://autohotkey.com/docs/misc/WinTitle.htm


推荐阅读