Slowly converting myself to AHK Studio, and I've got a script that creates hotstrings on the fly. When I add a new one, it reloads everything, but I can't see the new hotstring added to the bottom of the ahk file unless I close and reopen AHK Studio. Is it possible to "refresh" a script and its Includes? This works whilst using SciTE, so just checking if it also works in Studio.
(Note: I have stripped most of the code out of the string creator code, just giving the outline of how it works.
Main script:
Code: Select all
#Include Lib\AutoType.ahk ;String expansion
Code: Select all
#o::
{
AddHotstring:
;stuff to prep for creating the hotstring
; 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:
;build the AutoType code block to be added to this script
FormatTime, CurrentDateTime,, yyyy-MM-dd
If (A_ThisHotkey = "#h")
{
InputBox, strExpandedHotstring, New Hotstring, Type in the corrected string for the mispelled word '%Hotstring%'.,,,,,,,,
strTextToAppend:=strTextToAppend . ":*:" . Hotstring . "::" . strExpandedHotstring
}
Else If (A_ThisHotkey = "#o")
{
InputBox, strExpandedHotstring, New Hotstring, Type in the expanded string for the hotstring '%Hotstring%'.,,,,,,,,
;-------------------------------------------------------------
;15/05/2020 - LG Edit
;once you know what the hotstring is, add in the capital letter as well.
;https://autohotkey.com/board/topic/24431-convert-text-uppercase-lowercase-capitalized-or-inverted/#entry158152
;UpperCheck:= SubStr(UpperCheck Chr(Asc(UpperCheck) - 32),1,1) ;convert lower to upper
;Use RegExMatch to work out if the letter is upper or lower case:
;https://autohotkey.com/board/topic/65491-using-ahk-code-to-test-uppercase-vs-lowercase/#entry413634
;-------------------------------------------------------------
;15/05/2020 - LG Edit
strTextToAppend:="`n`;`~ " . "------------------------------------------------------------`n"
strTextToAppend := strTextToAppend . ";~ " . CurrentDateTime . " " . Hotstring . " -> " . strExpandedHotstring . " `n"
strTextToAppend:= strTextToAppend . ":O:" . Hotstring . "::`n"
;the rest of the string is built below...
;-------------------------------------------------------------
}
if ErrorLevel <> 0 ; The user pressed Cancel.
{
WinActivate, ahk_id strAHk_id ;reactive previously active window
return
}
;Write the new hotstring to the end of this file
FileAppend, `n%strTextToAppend%, %A_LineFile%
WinActivate, ahk_id %strAHk_id% ;reactive previously active window
Clipboard := strExpandedHotstring ;copy hotstring code text to clipboard
Reload ;reload this script to activate new hotstring
Sleep 200 ;If successful, the reload will close this instance during the Sleep
;so the line below will never be reached.
MsgBox, 4,, The hotstring just added appears to be improperly formatted. Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.
IfMsgBox, Yes, Edit
}
return