diff --git a/convert/1Commands.ahk b/convert/1Commands.ahk index d3eb0570..486a42c9 100644 --- a/convert/1Commands.ahk +++ b/convert/1Commands.ahk @@ -498,20 +498,24 @@ global gmAhkCmdsToConvert := OrderedMap( return false } - _SendMessage(p){ - if (p[3] ~= "^&.*"){ - p[3] := SubStr(p[3],2) - Out := format('if (type(' p[3] ')="Buffer"){ `;V1toV2 If statement may be removed depending on type parameter`n`r' gIndentation ' ErrorLevel := SendMessage({1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9})', p*) - Out := RegExReplace(Out, "[\s\,]*\)$", ")") - Out .= format('`n`r' gIndentation '} else{`n`r' gIndentation ' ErrorLevel := SendMessage({1}, {2}, StrPtr({3}), {4}, {5}, {6}, {7}, {8}, {9})', p*) - Out := RegExReplace(Out, "[\s\,]*\)$", ")") - Out .= '`n`r' gIndentation "}" - return Out - } - if (p[3] ~= "^`".*") { - p[3] := 'StrPtr(' p[3] ')' - } + _SendMessage(p) { - Out := format("ErrorLevel := SendMessage({1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9})", p*) - Return RegExReplace(Out, "[\s\,]*\)$", ")") + + if (p[3] ~= "^&.*"){ + p[3] := SubStr(p[3],2) + Out := format('if (type(' . p[3] . ')="Buffer"){ `;V1toV2 If statement may be removed depending on type parameter`n`r' . gIndentation + . ' ErrorLevel := SendMessage({1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9})', p*) + Out := RegExReplace(Out, "[\s\,]*\)$", ")") + Out .= format('`n`r' . gIndentation . '} else{`n`r' . gIndentation + . ' ErrorLevel := SendMessage({1}, {2}, StrPtr({3}), {4}, {5}, {6}, {7}, {8}, {9})', p*) + Out := RegExReplace(Out, "[\s\,]*\)$", ")") + Out .= '`n`r' . gIndentation . "}" + return Out + } + if (p[3] ~= "^`".*") { + p[3] := 'StrPtr(' . p[3] . ')' + } + + Out := format("ErrorLevel := SendMessage({1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9})", p*) + Return RegExReplace(Out, "[\s\,]*\)$", ")") } diff --git a/convert/MaskCode.ahk b/convert/MaskCode.ahk index 504a8427..acf20691 100644 --- a/convert/MaskCode.ahk +++ b/convert/MaskCode.ahk @@ -1,4 +1,4 @@ -; 2026-06-26 ADDED by andymbody to support code block masking +; 2026-06-26 ADDED by andymbody to support code block masking ; currently supports nested classes and functions (as wells as block/line comments and quoted strings for v1 or v2) ; will add more support for other code blocks, AHK funcs, etc as needed ; all regex needles were designed to support masking tags. Feel free to contact me on AHK forum if I can assist with edits @@ -543,16 +543,20 @@ class MLSTR extends PreMask { ; Multi-line string block ; non-expression version [ = ], not [ := ] +; does not support block comments between declaration and opening parenthesis +; can using masking to support them, or update needle to support raw block comments - opt := '(*UCP)(?ims)' ; pattern options - LC := '(?:(?<=\s|);[^\v]*)' ; line comment (allows lead ws to be consumed already) + ; 2024-07-06, UPDATED for better performance + opt := '(*UCP)(?ims)' ; pattern options + LC := '(?:(?<=\s);[^\v]*)' ; line comment (allows lead ws to be consumed already) tagChar := (IsSet(gTagChar)) ? gTagChar : chr(0x2605) - TG := '(?:#TAG' tagChar '\w+' tagChar '#)' ; mask tags - CT := '(?(?:\s*(?:' LC '|' TG '))*)\h*' ; optional line comment OR tag - var := '(?[_a-z]\w*)\h*=\h*' ; var - variable name - body := '\R+\h*(?\((?(?>.+?)+?)\R+\h*\))' ; body - block body with parentheses and guts + TG := '(?:#TAG' tagChar '\w+' tagChar '#)' ; mask tags + CT := '(?(?:\s*+(?:' LC '|' TG '))*)' ; optional line comment OR tag + var := '(?[_a-z]\w*)\h*=\h*' ; var - variable name + body := '\h*\R+(?\h*\((?(?:\R*(?>[^\v]*))*?)\R+\h*+\))' ; body - block body with parentheses and guts pattern := opt . var . CT . body - ; (*UCP)(?ims)(?[_a-z]\w*)\h*=\h*(?(?:\s*(?:(?:(?<=\s|);[^\v]*)|(?:#TAG?\w+?#)))*)\h*\R+\h*(?\((?(?>.+?)+?)\R+\h*\)) + ; changed to line-at-a-time vs character-at-a-time -> 4-5 times faster, only fooled if original code syntax is incorrect + ; (*UCP)(?ims)(?[_a-z]\w*)\h*=\h*(?(?:\s*+(?:(?:(?<=\s);[^\v]*)|(?:#TAG★\w+★#)))*+)\h*\R+(?\h*\((?(?:\R*(?>[^\v]*))*?)\R+\h*+\)) ; A_Clipboard := pattern ; ExitApp return pattern