I use this script to keep track of how many { and } I have used so that I do not forget to close an open statement. It should only work with notepad. I hope that someone finds it useful.
To use it pressing the [ key will add a { and auto indent the proper amount of spaces (1 for every open { and so on) and ] will close that statement and auto indent accordingly.
Code:
on=on
Hotkey, IfWinActive, Notepad
Hotkey, [, open,on
Hotkey, ], open,on
Hotkey,ins,onoff,on
hotkey, enter, end, on
SetTitleMatchMode, 2
control = Edit1
window = Notepad
return
onoff:
if on = on
on = off
else
on = on
Hotkey, [, open,%on%
Hotkey, ], open,%on%
splashtexton,,,Autoindent %on%
sleep, 1000
splashtextoff
return
f1::
reload
return
brace:
send, [
return
count:
ifwinactive, %window%
{
count = 0
ControlGet, Out,Currentline,,%control%,%window%
loop, %out%
{
controlget, line,Line, %a_index%,%control%,%window%
if line contains `{
count += 1
if line contains `}
{
count -= 1
}
}
}
return
open:
if A_ThisHotkey = ]
brace = }
else
brace = {
ControlGet, Out,Currentline,,%control%,%window%
controlget, line,Line, %out%,%control%,%window%
send, {end}
if line is space
{
if brace = }
{
if count = 0
return
send {bs}
}
send,{%brace%}
goto end
}
gosub, count
send, {enter}{space %count%}{{}
goto end
return
end:
gosub, count
send, {enter}{space %count%}
return
Thanks.
Maestrith.