Okay, I guess no one wants to get paid (see my other post), so I'll just ask my questions:
I just tried compiling my nifty script. All seemed to go well.
BUT -- The script contains a hotstrings manager that adds, edits, deletes the hotstrings. When I use it, instead of performing the action in the compiled script it performs the action in the original .ahk file.
Any idea what I did wrong?
Thank you!
![Photo](https://secure.gravatar.com/avatar/af6b5251b77a490cf4140614f3d8e9a2?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
Question about compiling
Started by
LindaR
, Apr 05 2007 09:07 PM
25 replies to this topic
do you mean when you try to add a hotstring and it doesn't add it to your compiled version, but it adds it to your .ahk version?
I'm confused, so you probably don't want to pay me to do it.
An example might be helpful for me.
I'm confused, so you probably don't want to pay me to do it.
An example might be helpful for me.
#2
-
Posted 05 April 2007 - 09:13 PM
![Question about compiling: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
I'd like to help, but there's a lot of stuff that could be wrong. I'd have to see something, or get a better explanation of how you create the hotstrings (GUI?) and where and how you write them, if you do at all.
That's all I got.
That's all I got.
#4
-
Posted 05 April 2007 - 09:40 PM
![Question about compiling: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Here is the code. I'm using a WONDERFUL gui that the kind people here -- esp HelpingHand -- helped with. (more than helped)
I have thousands and thousands of hotstrings in here, so I just put in a few for an example.
#NoEnv #SingleInstance, Force SetBatchLines, -1 SendMode, Input SetKeyDelay ,1 SetControlDelay, -1 _HS_File := A_ScriptDir . "\kate2.ahk" _TITLE := "Kate's Rad Words" _FILE := "" _STRINGS := "`n" _CHANGED := False _SEARCH := "" _MATCH := 0 Gui, font, s10 Arial Gui, Color, CCCCFF Gui, Margin, 10, 10 Gui, Add, GroupBox, x10 y10 w620 h215, Edit HotString: Gui, Add, GroupBox, xp+10 yp+18 w290 h50 Section, Brief: Gui, Add, Edit, xs+10 ys+18 w150 h20 vED_1 gEdit_1 Gui, Add, GroupBox, xs+310 ys w290 h50 Section, Options: (*=prefix, ?=suffix, R=as is) Gui, Add, Edit, xs+10 ys+18 w80 h20 vED_2 Gui, Add, GroupBox, xm+10 ys+60 w600 h90 Section, Text: (enter portion of text and press Find to search) Gui, Add, Edit, xs+10 ys+18 w580 h60 vED_3 WantTab WantReturn Gui, Add, Button, xs+10 y+20 w67 h25 vBT_Add, &Add Gui, Add, Button, x+20 yp w67 h25 Disabled vBT_Repl, &Replace Gui, Add, Button, x+20 yp w67 h25 vBT_Clear, &Clear Gui, Add, Button, x+20 yp w67 h25 vBT_Find, &Find Gui, Add, Groupbox, xm ys+150 h185 w620 Section, HotStrings: Gui, Add, ListView, xp+10 yp+18 w600 h120 vLV_1 Sort ReadOnly Grid NoSortHdr -Multi HwndLV_ID ; changed, added "-Multi" , Brief|Options|Text Gui, Add, Button, xs+10 y+10 w67 h25 , &Edit ;buttons modified Gui, Add, Button, x+20 yp w67 h25 , &Delete Gui, Add, Button, xm ys+200 w67 h30 , &Save Gui, Add, Button, xs+280 yp w67 h30, &Close Gui, Add, Button, xs+560 yp w67 h30, &Quit GoSub, Read_File Return ; ------------------------------------------------------------------------------ ; Gui's Hotkey ; ------------------------------------------------------------------------------ #b:: ;;browse hotstrings Gui, Show, , %_TITLE% Return ; ------------------------------------------------------------------------------ ; Subroutines ; ------------------------------------------------------------------------------ Read_File: LV_Delete() FileRead, _FILE, %_HS_File% StringReplace, _FILE, _FILE, `r`n, `n, All Loop, Parse, _File, `n, `r { If RegExMatch(A_LoopField,"^:(.*):(.*)::(.*)", HS_) { If (HS_3) { LV_Add("", HS_2, HS_1, HS_3) _STRINGS .= HS_2 . "`n" } } } _FILE := "`n" . _File If (SubStr(_FILE, StrLen(_FILE), 1) <> "`n") { _FILE .= "`n" } StringTrimRight,_STRINGS, _STRINGS, 1 LV_ModifyCol(1, "AutoHdr") Return ; ------------------------------------------------------------------------------ ; Gui Subroutines ; ------------------------------------------------------------------------------ Edit_1: ; Show matching hotstrings in the listview GuiControlGet, ED_1 If (!RegExMatch(ED_1, "\S+")) { Return } If (InStr(_STRINGS, "`n" . ED_1)) { ControlSend, , {Home}%ED_1%, ahk_id %LV_ID% } Return ; ------------------------------------------------------------------------------ ButtonAdd: ; Add new hotstring Gui, Submit, NoHide If (!RegExMatch(ED_1, "\S+") Or !RegExMatch(ED_3, "\S+")) { Return } If (InStr(ED_2, "R") And !InStr(ED_2, "R0")) { ED_3 := To_Raw(ED_3) } Else { StringReplace, ED_3, ED_3, %A_Tab%, {Tab}, All StringReplace, ED_3, ED_3, `n, {Enter}, All# } LV_Add("", ED_1, ED_2, ED_3) _HS := ":" . ED_2 . ":" . ED_1 . "::" . ED_3 _FILE .= _HS . "`n" _CHANGED := True Gosub, ButtonClear Return ; ------------------------------------------------------------------------------ ButtonReplace: ; Replace hotstring Gui, Submit, NoHide If (!RegExMatch(ED_1, "\S+") Or !RegExMatch(ED_3, "\S+")) { Return } If (InStr(ED_2, "R") And !InStr(ED_2, "R0")) { ED_3 := To_Raw(ED_3) } Else { StringReplace, ED_3, ED_3, %A_Tab%, {Tab}, All StringReplace, ED_3, ED_3, `n, {Enter}, All# } LV_Modify(_Row, "", ED_1, ED_2, ED_3) StringReplace, _FILE, _FILE, `n%_HS%`n, `n:%ED_2%:%ED_1%::%ED_3%`n _CHANGED := True Gosub, ButtonClear Return ; ------------------------------------------------------------------------------ ButtonClear: ; Clear edit area GuiControl, Enable, BT_Add GuiControl, Disable, BT_Repl GuiControl, Enable, BT_Find GuiControl, , ED_1 ; reset to blank GuiControl, , ED_2 ; reset to blank GuiControl, , ED_3 ; reset to blank Return ; ------------------------------------------------------------------------------ ButtonFind: ; Searches for Text in the ListView Gui, Submit, NoHide If (!RegExMatch(ED_3, "\S+")) { Return } If (ED_3 <> _SEARCH) { _MATCH := 0 _SEARCH := ED_3 } _MATCH := Find_Next(ED_3, _MATCH) If (_MATCH) { LV_Modify(_MATCH, "Select Focus Vis") } Return ; ------------------------------------------------------------------------------ ButtonEdit: ; Edit selected hotstring _Row := LV_GetNext() If (!_Row) { Return } Loop, % LV_GetCount("Col") { LV_GetText(ED_%A_Index%, _Row, A_Index) } _HS := ":" . ED_2 . ":" . ED_1 . "::" . ED_3 If (InStr(ED_2, "R") And !InStr(ED_2, "R0")) { ED_3 := From_Raw(ED_3) } Else { StringReplace, ED_3, ED_3, {Tab}, %A_Tab%, All StringReplace, ED_3, ED_3, {Enter}, `n, All } GuiControl, Disable, BT_Add GuiControl, Enable, BT_Repl GuiControl, Disable, BT_Find GuiControl, , ED_1, % ED_1 GuiControl, , ED_2, % ED_2 GuiControl, , ED_3, % ED_3 Return ; ------------------------------------------------------------------------------ ButtonDelete: ; Delete selected hotstring _Row := LV_GetNext() If (!_Row) { Return } Loop, % LV_GetCount("Col") { LV_GetText(ED_%A_Index%, _Row, A_Index) } _HS := ":" . ED_2 . ":" . ED_1 . "::" . ED_3 LV_Delete(_Row) StringReplace, _FILE, _FILE, `n%_HS%`n, `n GuiControl, Enable, BT_Add GuiControl, Disable, BT_Repl GuiControl, Enable, BT_Find _CHANGED := True Return ; ------------------------------------------------------------------------------ ButtonSave: ; Save hotstring file Gui, +OwnDialogs If (FileExist(_HS_FILE . "_New")) { FileDelete, %_HS_FILE%_New If (ErrorLevel) { MsgBox, 16, %_TITLE%, Couldn't delete %_HS_FILE%_New Return } } FileAppend, % SubStr(_FILE, 2, StrLen(_FILE) -2), %_HS_FILE%_New If (ErrorLevel) { MsgBox, 16, %_TITLE%, Couldn't write to %_HS_FILE%_New Return } FileMove, %_HS_FILE%_New, %_HS_FILE%, 1 If (ErrorLevel) { MsgBox, 16, %_TITLE%, Couldn't overwrite %_HS_FILE% } _CHANGED := False Reload Return ; ------------------------------------------------------------------------------ ButtonQuit: ButtonClose: GuiClose: GuiEscape: Gui, +OwnDialogs If (_CHANGED) { MsgBox, 36, %_TITLE%, (LTrim You've changed your hotstrings! Do you want to save the changes? ) IfMsgBox, Yes { Gosub, ButtonSave } } If (A_GuiControl = "&Quit") { Gui, Destroy ExitApp } Gui, Hide Return ; ------------------------------------------------------------------------------ ; Functions ; ------------------------------------------------------------------------------ Find_Next(String, LastRow) { ; Search next match for string in lestview's column 3 Global Local Options := "" Local Text := "" Local End := LV_GetCount() Local Row := LastRow + 1 If (Row > End) { MsgBox, 64, %_TITLE%, No (more) matches for`n%String% Return 0 } Loop { LV_GetText(Options, Row, 2) LV_GetText(Text, Row, 3) If (InStr(Options, "R") And !InStr(Options, "R0")) { Text := From_Raw(Text) } Else { StringReplace, Text, Text, {Tab}, %A_Tab%, All StringReplace, Text, Text, {Enter}, `n, All } If (InStr(Text, String)) { Return Row } Row++ If (Row > End) { MsgBox, 64, %_TITLE%, No (more) matches for`n%String% Return 0 } } } ; ------------------------------------------------------------------------------ To_Raw(String) { ; From Andreas Borutta's HotString Helper ; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring: ; The same is done for any other characters that might otherwise ; be a problem in raw mode: ; Do this replacement first to avoid interfering with the others below. StringReplace, String, String, ``, ````, All ; Using `r works better than `n in MS Word, etc. StringReplace, String, String, `r`n, ``r, All StringReplace, String, String, `n, ``r, All StringReplace, String, String, %A_Tab%, ``t, All StringReplace, String, String, `;, ```;, All Return String } ; ------------------------------------------------------------------------------ From_Raw(String) { ; Reverse translation from To_Raw() (see above) StringReplace, String, String, ``r, `r`n, All StringReplace, String, String, ``t, %A_Tab%, All StringReplace, String, String, ```;, `;, All StringReplace, String, String, ````, ``, All Return String } ;================================== #z:: KeyList: SetBatchLines,-1 AutoTrim,off Loop,Read,%A_ScriptName% { Line=%A_LoopReadLine% IfNotInString,Line,`;`;,Continue Key= IfInString,Line,`:`: { StringSplit,Key,Line,`: StringReplace,Key,Key1,#,Win- StringReplace,Key,Key,!,Alt- StringReplace,Key,Key,^,Ctrl- StringReplace,Key,Key,+,Shift- StringReplace,Key,Key,`;, Key=%key% ! } StringLeft,key,key,15 StringSplit,Comment,Line,`; StringTrimLeft,Comment,Comment%Comment0%,0 KeyList=%KeyList%%Key%`t%Comment%`n } MsgBox,0,Hotkeys list,%KeyList% KeyList= Return ; ===== ; places to go #i::Run www.imdb.com ;;IMDB #w::Run www.en.wikipedia.org/wiki/Main_Page ;;wikipedia ;========= ::5mdl::five-minute delay ::5mgs::5 mm images ::5mhc::5 mm helical collimation ::5mhgs::5 mm helical images ::5micts::5 mm increments ::5miks::5 mm increments ::5mivs::5 mm intervals ::5mk::5 mm thick ::5mkts::5 mm thick cuts ::5msc::5 mm slice collimation ::5msl::5 mm slice thickness ::5mslc::5 mm slice collimation ::5mthts::5 mm thick cuts ::5mx::5 mm reconstruction ::5mxgs::5 mm axial images ::5n::fifth nerve ::5nr::five non-rib-bearing ::5nrr::Five non-rib-bearing ::5pm::5:00 p.m. ::5q5::5 mm q5 ::5ss::5 South Searle ::5vd::{backspace}, five views, done at ::5vlp::five vertebrae of the lumbar-type ::5vot::Five views of the ::5vsm::Five views were submitted ::5vx::five-view examination of the ::630am::6:30 a.m. ::6am::6:00 a.m. ::6cn::sixth cranial nerve ::6d::6 days ::6f::6 French ::6fctl::6-French Cook shuttle ::6fe::6 French Envoy ::6fec::6 French Envoy catheter ::6n::sixth nerve ::6pm::6:00 p.m. ::6rib::sixth rib ::6x35::6 French x 35 cm sheath ::7-8x::7-8 complex ::710d::7 to 10 days ::71jx::C7-T1 junction ::789pc::70 to 89% stenosis ::78a9::7, 8, and 9 ::78cn::seventh and eighth cranial nerve ::78cns::seventh and eighth cranial nerves ::78n::seventh and eighth nerve ::78ns::seventh and eighth nerves ::78nx::seventh and eighth nerve complexes ::79miparls::700-900 micron particles ::7a8th::seventh and eighth ::7am::7:00 a.m. ::7cn::seventh cranial nerve ::hrl::humeral
I have thousands and thousands of hotstrings in here, so I just put in a few for an example.
#5
-
Posted 05 April 2007 - 10:03 PM
![Question about compiling: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Something pithy on order.
Since you are generating an AHK file, the user will have to have AHK on their computer. You may need to change your format a bit (store your hotstrings in a seperate file)
You can include the Autohotkey executable with your program, but this will not solve all your problems.
also, it looks like you have the edited script reload itself, but you can't recompile the EXE while it is running. you can have a seperate file with the strings in it, and the Gui is always running in a seperate process, but you will have to restucture your code a liittle bit (but not much).
I am willing to help you, as I said in your other thread, but I won't have time until maybe the weekend to work on it. I can't quote a price, though, just pay us what you think it's worth - maybe some royalty from you selling it? (i'm at least half-kidding)
You can include the Autohotkey executable with your program, but this will not solve all your problems.
also, it looks like you have the edited script reload itself, but you can't recompile the EXE while it is running. you can have a seperate file with the strings in it, and the Gui is always running in a seperate process, but you will have to restucture your code a liittle bit (but not much).
I am willing to help you, as I said in your other thread, but I won't have time until maybe the weekend to work on it. I can't quote a price, though, just pay us what you think it's worth - maybe some royalty from you selling it? (i'm at least half-kidding)
#6
-
Posted 05 April 2007 - 10:11 PM
![Question about compiling: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Hi engunneer!
I sent you a pm with my email address -- let's talk!
Linda
I sent you a pm with my email address -- let's talk!
Linda
#7
-
Posted 05 April 2007 - 10:16 PM
![Question about compiling: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Something pithy on order.
Hi engunneer --
I answered your pm -- did it go through this time?
LindaR
I answered your pm -- did it go through this time?
LindaR
#8
-
Posted 05 April 2007 - 10:43 PM
![Question about compiling: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Something pithy on order.
LindaR:
Change the following to allow including the hs in a seperate file:
Move the Hotstrings to Strings.hs in the directory of the script.
Remove them from the script file.
Now run your script...It should work normally..
It will create the Strings.hs file in the A_AppData directory.
When you compile the application, the copy of strings.hs that is in the directory of the script will be included. When the exe is ran it checks for the strings.hs file in the A_AppData, if it does not exist it will create the file that was included at compilation time.
If the user edits the hotstrings they will available the next time the application runs...it will add to the hotstrings file.
If you want a custom icon, you choose it when you compile with Convert .ahk to .exe in the start menu folder or AHK2EXE in the ahk directory...You will need an icon to use..search for free icons on google...
Enjoy....
Thanks for posting!
This has been needed around here for a long time, by others...
EDIT::The options might not work..I did not test that.
Change the following to allow including the hs in a seperate file:
Move the Hotstrings to Strings.hs in the directory of the script.
Remove them from the script file.
... _HS_File := "Strings.hs" If !FileExist(_HS_File) FileInstall, Strings.hs, Strings.hs, 0 ...
Read_File: LV_Delete() FileRead, _FILE, %_HS_File% StringReplace, _FILE, _FILE, `r`n, `n, All Loop, Parse, _File, `n, `r { If RegExMatch(A_LoopField,"^:(.*):(.*)::(.*)", HS_) { If (HS_3) { LV_Add("", HS_2, HS_1, HS_3) _STRINGS .= HS_2 . "`n" ; ; ADDED THIS LINE hs(HS_2, HS_3) .....Include the following Function to the bottom of your script file
It is from this thread
Now run your script...It should work normally..
It will create the Strings.hs file in the A_AppData directory.
When you compile the application, the copy of strings.hs that is in the directory of the script will be included. When the exe is ran it checks for the strings.hs file in the A_AppData, if it does not exist it will create the file that was included at compilation time.
If the user edits the hotstrings they will available the next time the application runs...it will add to the hotstrings file.
If you want a custom icon, you choose it when you compile with Convert .ahk to .exe in the start menu folder or AHK2EXE in the ahk directory...You will need an icon to use..search for free icons on google...
Enjoy....
Thanks for posting!
This has been needed around here for a long time, by others...
EDIT::The options might not work..I did not test that.
#9
-
Posted 05 April 2007 - 11:31 PM
![Question about compiling: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
ahklerner, I did this, but I don't (excuse my ignorance) understand this sentence:
Do you mean create a file named Strings.hs and put the strings in there?
And what is "the directory of the script"? and how do I make it?
I really do apologize for my ignorance. And yes, this utility is fab. It works great uncompiled!!
Move the Hotstrings to Strings.hs in the directory of the script.
Do you mean create a file named Strings.hs and put the strings in there?
And what is "the directory of the script"? and how do I make it?
I really do apologize for my ignorance. And yes, this utility is fab. It works great uncompiled!!
#10
-
Posted 05 April 2007 - 11:50 PM
![Question about compiling: post #10](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Something pithy on order.
it is whatever folder on your computer the script resides in. wherever the ahk/exe file is is the script's default working folder.
#11
-
Posted 05 April 2007 - 11:52 PM
![Question about compiling: post #11](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Yes put the hotstrings into a file named strings.hs . save it where the script is saved.
#12
-
Posted 05 April 2007 - 11:55 PM
![Question about compiling: post #12](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Okay, it's still not working. Here is the code with the changes:
This file is in the folder that has AutoHotKey and I also put in a file named Strings.hs with all the hotstrings.
#NoEnv #SingleInstance, Force SetBatchLines, -1 SendMode, Input SetKeyDelay ,1 SetControlDelay, -1 _HS_File := A_AppData . "Strings.hs" If !FileExist(_HS_File) FileInstall, Strings.hs, %A_AppData%Strings.hs, 0 _TITLE := "Kate's Rad Words" _FILE := "" _STRINGS := "`n" _CHANGED := False _SEARCH := "" _MATCH := 0 Gui, font, s10 Arial Gui, Color, CCCCFF Gui, Margin, 10, 10 Gui, Add, GroupBox, x10 y10 w620 h215, Edit HotString: Gui, Add, GroupBox, xp+10 yp+18 w290 h50 Section, Brief: Gui, Add, Edit, xs+10 ys+18 w150 h20 vED_1 gEdit_1 Gui, Add, GroupBox, xs+310 ys w290 h50 Section, Options: (*=prefix, ?=suffix, R=as is) Gui, Add, Edit, xs+10 ys+18 w80 h20 vED_2 Gui, Add, GroupBox, xm+10 ys+60 w600 h90 Section, Text: (enter portion of text and press Find to search) Gui, Add, Edit, xs+10 ys+18 w580 h60 vED_3 WantTab WantReturn Gui, Add, Button, xs+10 y+20 w67 h25 vBT_Add, &Add Gui, Add, Button, x+20 yp w67 h25 Disabled vBT_Repl, &Replace Gui, Add, Button, x+20 yp w67 h25 vBT_Clear, &Clear Gui, Add, Button, x+20 yp w67 h25 vBT_Find, &Find Gui, Add, Groupbox, xm ys+150 h185 w620 Section, HotStrings: Gui, Add, ListView, xp+10 yp+18 w600 h120 vLV_1 Sort ReadOnly Grid NoSortHdr -Multi HwndLV_ID ; changed, added "-Multi" , Brief|Options|Text Gui, Add, Button, xs+10 y+10 w67 h25 , &Edit ;buttons modified Gui, Add, Button, x+20 yp w67 h25 , &Delete Gui, Add, Button, xm ys+200 w67 h30 , &Save Gui, Add, Button, xs+280 yp w67 h30, &Close Gui, Add, Button, xs+560 yp w67 h30, &Quit GoSub, Read_File Return ; ------------------------------------------------------------------------------ ; Gui's Hotkey ; ------------------------------------------------------------------------------ #b:: ;;browse hotstrings Gui, Show, , %_TITLE% Return ; ------------------------------------------------------------------------------ ; Subroutines ; ------------------------------------------------------------------------------ Read_File: LV_Delete() FileRead, _FILE, %_HS_File% StringReplace, _FILE, _FILE, `r`n, `n, All Loop, Parse, _File, `n, `r { If RegExMatch(A_LoopField,"^:(.*):(.*)::(.*)", HS_) { If (HS_3) { LV_Add("", HS_2, HS_1, HS_3) _STRINGS .= HS_2 . "`n" hs(HS_2, HS_3) } } } _FILE := "`n" . _File If (SubStr(_FILE, StrLen(_FILE), 1) <> "`n") { _FILE .= "`n" } StringTrimRight,_STRINGS, _STRINGS, 1 LV_ModifyCol(1, "AutoHdr") Return ; ------------------------------------------------------------------------------ ; Gui Subroutines ; ------------------------------------------------------------------------------ Edit_1: ; Show matching hotstrings in the listview GuiControlGet, ED_1 If (!RegExMatch(ED_1, "\S+")) { Return } If (InStr(_STRINGS, "`n" . ED_1)) { ControlSend, , {Home}%ED_1%, ahk_id %LV_ID% } Return ; ------------------------------------------------------------------------------ ButtonAdd: ; Add new hotstring Gui, Submit, NoHide If (!RegExMatch(ED_1, "\S+") Or !RegExMatch(ED_3, "\S+")) { Return } If (InStr(ED_2, "R") And !InStr(ED_2, "R0")) { ED_3 := To_Raw(ED_3) } Else { StringReplace, ED_3, ED_3, %A_Tab%, {Tab}, All StringReplace, ED_3, ED_3, `n, {Enter}, All# } LV_Add("", ED_1, ED_2, ED_3) _HS := ":" . ED_2 . ":" . ED_1 . "::" . ED_3 _FILE .= _HS . "`n" _CHANGED := True Gosub, ButtonClear Return ; ------------------------------------------------------------------------------ ButtonReplace: ; Replace hotstring Gui, Submit, NoHide If (!RegExMatch(ED_1, "\S+") Or !RegExMatch(ED_3, "\S+")) { Return } If (InStr(ED_2, "R") And !InStr(ED_2, "R0")) { ED_3 := To_Raw(ED_3) } Else { StringReplace, ED_3, ED_3, %A_Tab%, {Tab}, All StringReplace, ED_3, ED_3, `n, {Enter}, All# } LV_Modify(_Row, "", ED_1, ED_2, ED_3) StringReplace, _FILE, _FILE, `n%_HS%`n, `n:%ED_2%:%ED_1%::%ED_3%`n _CHANGED := True Gosub, ButtonClear Return ; ------------------------------------------------------------------------------ ButtonClear: ; Clear edit area GuiControl, Enable, BT_Add GuiControl, Disable, BT_Repl GuiControl, Enable, BT_Find GuiControl, , ED_1 ; reset to blank GuiControl, , ED_2 ; reset to blank GuiControl, , ED_3 ; reset to blank Return ; ------------------------------------------------------------------------------ ButtonFind: ; Searches for Text in the ListView Gui, Submit, NoHide If (!RegExMatch(ED_3, "\S+")) { Return } If (ED_3 <> _SEARCH) { _MATCH := 0 _SEARCH := ED_3 } _MATCH := Find_Next(ED_3, _MATCH) If (_MATCH) { LV_Modify(_MATCH, "Select Focus Vis") } Return ; ------------------------------------------------------------------------------ ButtonEdit: ; Edit selected hotstring _Row := LV_GetNext() If (!_Row) { Return } Loop, % LV_GetCount("Col") { LV_GetText(ED_%A_Index%, _Row, A_Index) } _HS := ":" . ED_2 . ":" . ED_1 . "::" . ED_3 If (InStr(ED_2, "R") And !InStr(ED_2, "R0")) { ED_3 := From_Raw(ED_3) } Else { StringReplace, ED_3, ED_3, {Tab}, %A_Tab%, All StringReplace, ED_3, ED_3, {Enter}, `n, All } GuiControl, Disable, BT_Add GuiControl, Enable, BT_Repl GuiControl, Disable, BT_Find GuiControl, , ED_1, % ED_1 GuiControl, , ED_2, % ED_2 GuiControl, , ED_3, % ED_3 Return ; ------------------------------------------------------------------------------ ButtonDelete: ; Delete selected hotstring _Row := LV_GetNext() If (!_Row) { Return } Loop, % LV_GetCount("Col") { LV_GetText(ED_%A_Index%, _Row, A_Index) } _HS := ":" . ED_2 . ":" . ED_1 . "::" . ED_3 LV_Delete(_Row) StringReplace, _FILE, _FILE, `n%_HS%`n, `n GuiControl, Enable, BT_Add GuiControl, Disable, BT_Repl GuiControl, Enable, BT_Find _CHANGED := True Return ; ------------------------------------------------------------------------------ ButtonSave: ; Save hotstring file Gui, +OwnDialogs If (FileExist(_HS_FILE . "_New")) { FileDelete, %_HS_FILE%_New If (ErrorLevel) { MsgBox, 16, %_TITLE%, Couldn't delete %_HS_FILE%_New Return } } FileAppend, % SubStr(_FILE, 2, StrLen(_FILE) -2), %_HS_FILE%_New If (ErrorLevel) { MsgBox, 16, %_TITLE%, Couldn't write to %_HS_FILE%_New Return } FileMove, %_HS_FILE%_New, %_HS_FILE%, 1 If (ErrorLevel) { MsgBox, 16, %_TITLE%, Couldn't overwrite %_HS_FILE% } _CHANGED := False Reload Return ; ------------------------------------------------------------------------------ ButtonQuit: ButtonClose: GuiClose: GuiEscape: Gui, +OwnDialogs If (_CHANGED) { MsgBox, 36, %_TITLE%, (LTrim You've changed your hotstrings! Do you want to save the changes? ) IfMsgBox, Yes { Gosub, ButtonSave } } If (A_GuiControl = "&Quit") { Gui, Destroy ExitApp } Gui, Hide Return ; ------------------------------------------------------------------------------ ; Functions ; ------------------------------------------------------------------------------ Find_Next(String, LastRow) { ; Search next match for string in lestview's column 3 Global Local Options := "" Local Text := "" Local End := LV_GetCount() Local Row := LastRow + 1 If (Row > End) { MsgBox, 64, %_TITLE%, No (more) matches for`n%String% Return 0 } Loop { LV_GetText(Options, Row, 2) LV_GetText(Text, Row, 3) If (InStr(Options, "R") And !InStr(Options, "R0")) { Text := From_Raw(Text) } Else { StringReplace, Text, Text, {Tab}, %A_Tab%, All StringReplace, Text, Text, {Enter}, `n, All } If (InStr(Text, String)) { Return Row } Row++ If (Row > End) { MsgBox, 64, %_TITLE%, No (more) matches for`n%String% Return 0 } } } ; ------------------------------------------------------------------------------ To_Raw(String) { ; From Andreas Borutta's HotString Helper ; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring: ; The same is done for any other characters that might otherwise ; be a problem in raw mode: ; Do this replacement first to avoid interfering with the others below. StringReplace, String, String, ``, ````, All ; Using `r works better than `n in MS Word, etc. StringReplace, String, String, `r`n, ``r, All StringReplace, String, String, `n, ``r, All StringReplace, String, String, %A_Tab%, ``t, All StringReplace, String, String, `;, ```;, All Return String } ; ------------------------------------------------------------------------------ From_Raw(String) { ; Reverse translation from To_Raw() (see above) StringReplace, String, String, ``r, `r`n, All StringReplace, String, String, ``t, %A_Tab%, All StringReplace, String, String, ```;, `;, All StringReplace, String, String, ````, ``, All Return String } ;================================== #z:: KeyList: SetBatchLines,-1 AutoTrim,off Loop,Read,%A_ScriptName% { Line=%A_LoopReadLine% IfNotInString,Line,`;`;,Continue Key= IfInString,Line,`:`: { StringSplit,Key,Line,`: StringReplace,Key,Key1,#,Win- StringReplace,Key,Key,!,Alt- StringReplace,Key,Key,^,Ctrl- StringReplace,Key,Key,+,Shift- StringReplace,Key,Key,`;, Key=%key% ! } StringLeft,key,key,15 StringSplit,Comment,Line,`; StringTrimLeft,Comment,Comment%Comment0%,0 KeyList=%KeyList%%Key%`t%Comment%`n } MsgBox,0,Hotkeys list,%KeyList% KeyList= Return ; ===== ; places to go #i::Run www.imdb.com ;;IMDB #w::Run www.en.wikipedia.org/wiki/Main_Page ;;wikipedia ;========= hs(c, a = "") { ; Titan v1 static d, b, q global $ v = `n,€,~$,Numpad,BS StringSplit, v, v, `, If !d { Loop, 104 Hotkey, % Chr(42 * !!RegExMatch(t := Chr(32 + (x := A_Index)) , "[a-z]")) . v3 . (x > 94 ? v4 . x - 95 : t), _hs Hotkey, %v3%%v5%, _hs } If a Return, !!b .= c . v2 . a . v1 If c = %v3%%v5% Return, !!q := SubStr(q, 1, -1) If GetKeyState("Shift", "P") or GetKeyState("Capslock", "T") StringUpper, c, c Else StringLower, c, c q .= SubStr(c, StrLen(v3) + !!InStr(c, v4) * StrLen(v4) + 1 + !!InStr(c, "*")) Loop, Parse, b, %v1% { If (c := RegExMatch(q, SubStr(t := A_LoopField, 1 , InStr(t, v2) - 1) . "$", $)) and t { f += RegExMatch(t, ".+" . v2 . "(.+)", l) SendInput, % "{BS " . StrLen($) . "}" Transform, l, Deref, %l1% If IsLabel(l) GoSub, %l% Else SendInput, %l% } } If f q = } _hs: hs(A_ThisHotkey) Return
This file is in the folder that has AutoHotKey and I also put in a file named Strings.hs with all the hotstrings.
#13
-
Posted 06 April 2007 - 12:05 AM
![Question about compiling: post #13](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Something pithy on order.
_HS_File := A_AppData . "\Strings.hs" If !FileExist(_HS_File) FileInstall, Strings.hs, %A_AppData%\Strings.hs, 0
I forgot a slash.
#14
-
Posted 06 April 2007 - 12:25 AM
![Question about compiling: post #14](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
I added the slash on both lines, but it still doesn't work. So I tried using it to add a hotstring. That worked -- but it automatically expands, as if the option has a *, which is not good. I need to use the space bar to expand the hotstrings unless I specify differently.
But the main thing is, it isn't reading the String.hs file.
Linda
But the main thing is, it isn't reading the String.hs file.
Linda
#15
-
Posted 06 April 2007 - 12:32 AM
![Question about compiling: post #15](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Something pithy on order.