Use autohotkey to speedup st programming.
As the poor support for structure text programming in plc world(code snippet), here are some short key for it I used with autohotkey.
It’s good for your healthy, enjoy it.
- ,s ==> SET(TRUE, );
- ,r ==> RST(TRUE, );
- ,t ==> := TRUE;
- ,f ==> := FALSE;
;==================================== | |
; for ladder | |
;==================================== | |
; key 'a ' => 'ld ' | |
:*:a ::ld | |
:*:b ::ldi | |
:*:o ::out | |
;==================================== | |
; for structure text | |
;==================================== | |
; key ',f' --> ' := FALSE;' | |
:*:,f:: := FALSE; | |
; key ',t' --> ' := TRUE;' | |
:*:,t:: := TRUE; | |
; key ',;' --> ' := ;' | |
:*:,;:: := 0;{Left 2} | |
:*:,s::SET(TRUE, );{Left 2} | |
:*:,r::RST(TRUE, );{Left 2} | |
:*:,ei::END_IF; | |
; replace c sytle mark '//' to '(* *)' | |
:://::(* *){Left 3} | |
; three '-' --> 'seperate line' | |
; 輸入三個"-"後,會變成一列分割線 | |
::---::(*-------------------------------------------------------------------------------------------------*) | |
; '/todo' --> '(* TODO: *)' | |
; 輸入/todo後,變成 (* TODO: *) | |
::/todo::(* TODO: *){Left 3} | |
; generate 'if' block | |
::/if::If THEN{Enter}{Tab};{Enter}END_IF;{UP 2} | |
; generate 'case' block | |
::/cas::CASE ( ) OF{Enter}:{Enter}{Tab 2};{Enter}END_CASE;{UP 3} | |
; comment a block | |
; use hotkey "ctrl +'/'" to add (* *) surround the target string | |
^/:: | |
Send ^c(*{Enter}^v{Enter}*) | |
return | |
; change "M0 := false;" --> "RST(TRUE, M0);" | |
; use hotkey ctrl + '.' to change boolean assign style | |
^.:: | |
Send {Home} | |
Send +{End} | |
Clipboard = ; | |
Send ^c | |
ClipWait, 2 | |
srcString = %Clipboard% | |
wordsAry := StrSplit(srcString, [A_Space, ";"]) | |
tmpString := wordsAry[1] | |
str1 := wordsAry[3] | |
StringUpper, upStr, str1 | |
if (upStr = "TRUE") | |
{ | |
Clipboard = SET(TRUE, %tmpString%); | |
} | |
if (upStr = "FALSE") | |
{ | |
Clipboard = RST(TRUE, %tmpString%); | |
} | |
Send +{Left 1} | |
Send ^v | |
ClipWait, 2 | |
Send {Home} | |
Send {Tab} | |
return | |
; generate Today's datetime string | |
::,d:: | |
d = %A_YYYY%/%A_MM%/%A_DD% | |
Send %d% | |
return | |
;Win + Ctrl + R reload script | |
#^r:: | |
reload | |
return |