Hi,
here a script that automatically modifys the actual wordfile for UltraEdit. If there is always a AHK-syntax, it will update it und if there is no syntax for AHK present then it adds it to the wordfile. It also creates a backup. This script uses the syntax-file from EditPlus to create UltraEdits syntaxfile. It also assigns UE to the default AHK-Editor.
To use this script, you should create it in a subfolder inside AHK/Extras/Editors"
I've only tested this script with UE 10.20
If it works for you all, it could be included in the release.
Code:
RegRead, UeditPath, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\UEDIT32.exe,Path
ifNotExist, %UeditPath%\uedit32.exe
{
FileSelectFolder, UeditPath,, 0,Select UltraEdit program-folder
}
ifNotExist, %UeditPath%\uedit32.exe
{
MsgBox, 16,, UltraEdit cannot be found.
ExitApp
}
UEini = %APPDATA%\IDMComp\UltraEdit\uedit32.ini
IfNotExist, %UEini%
{
FileSelectFile, UEini, 1, %ProgramFiles%\UltraEdit, Select UltraEdit INI-File, *.ini
}
IniRead, UEwordfile, %UEini%, Settings, Language File
if UEwordfile = ERROR
{
MsgBox, 16,, Wrong INI-File, missing the Key: Language File
ExitApp
}
; Get path of AHK-path
ahkpath = %A_WorkingDir%
StringGetPos, pos, ahkpath, \, R3
StringLeft, ahkpath,ahkpath, %pos%
AHKwordfilepart = "AutoHotkey" Nocase Line Comment = `; Escape Char = `` String Chars = `% File Extensions = ini ahk`n
AHKwordfilepart = %AHKwordfilepart%/Delimiters = ~!@`%^&*()-+=``|\/{}[]:;"'<> , .? `n
AHKwordfilepart = %AHKwordfilepart%/Indent Strings = "{" ":"`n
AHKwordfilepart = %AHKwordfilepart%/Unindent Strings = "}" "Return"`n
AHKwordfilepart = %AHKwordfilepart%/Function String = "`%[^t ]++^(:++[a-zA-Z0-9_äöüß<>^~!$#+.*^^^[^]]++:+^)"`n
KWcolor = 0
Loop, Read, %ahkpath%\Extras\Editors\EditPlus\AutoHotkey.stx
{
StringLeft, KWdef , A_LoopReadLine , 8
StringMid, KWname, A_LoopReadLine, 10, 100
if KWdef = #KEYWORD
{
Sort, AHKwordsToSort
gosub, WordsInOneLine
AHKwordfilepart = %AHKwordfilepart%%AHKwordsToSort%
AHKwordsToSort =
KWcolor += 1
AHKwordfilepart = %AHKwordfilepart%`n/C%KWcolor%"%KWname%"
Continue
}
if KWcolor = 0
Continue
StringLeft, KWfirst, A_LOOPREADLINE, 1
if KWfirst = `;
Continue
Line = %A_LoopReadLine%
if Line = #
Continue
if KWfirst = ^
StringReplace, Line, Line, ^,
AHKwordsToSort =%AHKwordsToSort%`n%Line%
}
Sort, AHKwordsToSort
gosub, WordsInOneLine
AHKwordfilepart = %AHKwordfilepart%%AHKwordsToSort%
Loop, Read, %UEwordfile%, UEwordfile.txt
{
StringLeft, WFdef, A_LoopReadLine, 2
StringGetPos, WFpos, A_LoopReadLine, "
WFcolLen = %WFpos%
WFcolLen -= 2
StringMid, WFcolor, A_LoopReadLine, 3, %WFcolLen%
StringSplit, WFname, A_LoopReadLine, "
if WFdef = /L
{
WFactName = %WFname2%
WFactColor = %WFcolor%
if WFactName = AutoHotkey
{
FileAppend, /L%WFactColor%%AHKwordfilepart%
WFahktrue = 1
}
}
if WFactName <> AutoHotkey
{
FileAppend, %A_LoopReadLine%`n
}
}
if WFahktrue <> 1
{
WFactColor += 1
FileAppend, /L%WFactColor%%AHKwordfilepart%, UEwordfile.txt
}
If WFactColor > 19
{
MsgBox, 48,, The wordfile has 20 or more syntax-schemes. UltraEdit does only support 20 schemes.`nPlease delete one scheme from the file!
FileDelete, UEwordfile.txt
ExitApp
}
FileCopy, %UEwordfile%, %UEwordfile%.ahk.bak, 1
FileMove, UEwordfile.txt, %UEwordfile%, 1
RegWrite, REG_SZ,HKEY_CLASSES_ROOT,AutoHotkeyScript\Shell\Edit\Command,, %UeditPath%\uedit32.exe "`%1"
if WFahktrue = 1
MsgBox, 64,, The AutoHotkey-Syntax for UltraEdit has been updated in your actual wordfile!`n`n%UEwordfile%`n`nA backup has been created in the same folder.
else
MsgBox, 64,, The AutoHotkey-Syntax for UltraEdit has been added to your actual wordfile!`n%UEwordfile%`n`n`nA backup has been created in the same folder.
Return
WordsInOneLine:
WordBeg_last =
Concat =
Loop, Parse, AHKwordsToSort, `n
{
StringLeft, WordBeg, A_LoopField, 1
If WordBeg = %WordBeg_last%
{
AutoTrim, off
Concat=%Concat%%A_LoopField%%A_Space%
AutoTrim, on
}
else
{
AutoTrim, off
Concat=%Concat%`n%A_LoopField%%A_Space%
AutoTrim, on
}
WordBeg_last = %WordBeg%
}
AHKwordsToSort = %Concat%
Return
Tekl