0
votes

I've written a Autohotkey script to auto-complete print statement in java

System.out.println("");

by clicking s and then Tab and jump to next line when cursor is between quotation marks by clicking Shift + Enter as follows

:*:s`t::System.out.println("");{left}{left}{left}

+Enter::
ClipSaved := ClipboardAll  
Loop
{
    clipboard =           
    Send, +{Right} 
    Send, ^c              
    ClipWait , 0.2             
    StringRight := InStr(Clipboard,OutputVar, 1)
    If OutputVar = {;}
    Send ^v
    Send {Right}
    Send {Right}
    Send {Right}
    Send {Enter}
    break            
}
clipboard := ClipSaved    
Return

The problem here is it works good when I type s and then Tab and when clicking Shift + Enter jumps to new line. But if I type anything between quotations and then hit Shift + Enter it jumps to new line but then onwards the auto-complete is not working i.e., I'm not getting print statement when typing s and then Tab. The image of error is attached for illustration. You can copy/paste the code and tell me where the error is, as I'm unable to figure it out.

error_image

1

1 Answers

2
votes

If you want to trigger a hotstring after you typed something, you need to use the question mark option. Try this:

:*?:s`t::System.out.println("");{left}{left}{left}