my-lord
my-lord

Reputation: 2913

How can I format my java code with automating netbeans ide by autohotkey?

I want to format selected java code with sending keys to hidden NetBeans IDE.I wrote following script

^+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

But hidden NetBeans pops up when trying to send keys with ControlSend and I can't minimize Netbeans window with WinMinimize,"Netbeans".How can I fix this issues?

Upvotes: 1

Views: 132

Answers (2)

user70960
user70960

Reputation: 326

You don’t need to use quotes, your code won’t be working. And if you want, you don’t have to use commas.

This code works fine:

WinMinimize Netbeans
; WinMinimize, Netbeans ; this will work too

Using with commas:

WinMinimize % "Netbeans"

But since some programs use dynamic window name, you’d better minimize programs by their process name:

WinMinimize, ahk_exe netbeans.exe

Also, you can just minimize the active window:

WinMinimize A

More: https://autohotkey.com/docs/misc/WinTitle.htm

Upvotes: 2

johnlee
johnlee

Reputation: 392

I don't use NetBeans so I can't experiment, but:

  1. Double-click the tray icon of your script and run Window Spy.
     
  2. Make sure you're detecting the right window, and you might have to experiment with "SetTitleMatchMode RegEx" and refine your WinTitle string, but this might not be really necessary, as your ControlSend does seem to detect it correctly. However, I'd still make sure.
     
  3. You might also have to use an alternative method for minimizing a window:
    From WinMinimize:
    PostMessage, 0x112, 0xF020,,, WinTitle, WinText ; 0x112 = WM_SYSCOMMAND, 0xF020 = SC_MINIMIZE
     
  4. What you really want to use might not be WinMinimize, but WinHide.

Upvotes: 1

Related Questions