Skip to content

Instantly share code, notes, and snippets.

@KnIfER
Created March 4, 2023 05:23
Show Gist options
  • Save KnIfER/2554aebdbe1fd8f36194baa29c445fcb to your computer and use it in GitHub Desktop.
Save KnIfER/2554aebdbe1fd8f36194baa29c445fcb to your computer and use it in GitHub Desktop.
FIX IDEA -- "Focus on Start-up" option doesn't work in Intellij IDEA Ultimate
#IfWinActive ahk_exe idea64.exe
$RButton::
MouseGetPos, xpos, ypos
WinGetPos, x, y, w, h, A
if(xpos < 10 && ypos<y+h)
{
Send +{F10}
}
return
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; asume that IDEA window is maximized
;消息("启动")
sleep 100
WinGetPos,x,y,w,h, A
MouseGetPos, xpos, ypos
WinGet, WND, ID, A
sleep 100
MouseClick, Middle, -x, ypos
; active IDEA window again
send !{Right}
MouseMove, x+xpos, y+ypos
WinActivate ahk_id %WND%
; sleep 1000
; 消息(Message,Width := "w150",Timeout := "-500", Title := "")
; {
; Progress, %Width% b1 zh0 fs18, %Message%,,%Title%,
; settimer, killAlert,%Timeout%
; }
; killAlert:
; progress,off
; return
package hunxiao;
import org.junit.Test;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
public class JavaTestUtility {
@Test
public void First_Button() {
_log("first button clicked.");
}
/* Run Java To Run Exe To Utilize Java Tests with or without IDEA running. */
public static void main(String[] args) throws Exception {
List<String> commands = new ArrayList<>();
// run the native gui application.
commands.add("D:\\Code\\FigureOut\\Textrument\\plugins\\DirectUILib\\bin\\ListViewDemo.exe");
Process proc = new ProcessBuilder(commands).start();
BufferedReader errorResult = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
BufferedReader errorResult1 = new BufferedReader(new InputStreamReader(proc.getInputStream()));
Thread t = new Thread(() -> {
while (proc.isAlive())
{
try {
String line;
while ((line=errorResult.readLine()) != null) _log(line);
while ((line=errorResult1.readLine()) != null) _log(line);
} catch (Exception e) { _log("PlayService", "read ErrorStream exception:", e); }
try { Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); }
}
});
// active the second log tab.
List<String> ahk = new ArrayList<>();
ahk.add("C:\\Program Files\\AutoHotkey\\AutoHotkey.exe");
ahk.add("/r");
ahk.add("D:\\Code\\FigureOut\\chrome\\extesions\\AutoHotKey\\idea_next_tab.ahk");
new ProcessBuilder(ahk).start();
t.start();
t.join();
proc.waitFor();
}
public JavaTestUtility() throws Exception {
//readVersion();
// preserve defualt output. see https://stackoverflow.com/questions/3340342/writing-to-the-real-stdout-after-system-setout
original = new PrintStream(System.out);
File file = new File("D:\\dev.log");
PrintStream stream = new PrintStream(new FileOutputStream(file, true)){
public void write(int b) { super.write(b); original.write(b); }
public void write(byte[] b) throws IOException { super.write(b); original.write(b); }
public void write(byte[] buf, int off, int len) { super.write(buf, off, len); original.write(buf, off, len); }
};
System.setOut(stream);
_log("000");
}
public static void _log(Object...value) {
for (int i = 0; i < value.length; i++) {
System.out.print(""+value[i]);
System.out.print(" ");
}
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment