Page 1 of 1

Script reload not showing changes?

Posted: 31 May 2020, 20:43
by submeg
Hi all,

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

AutoType string creator:

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


Re: Script reload not showing changes?

Posted: 01 Jun 2020, 03:22
by DaveT1
Not sure if this will help, but right clicking on AHKStudio's Project Explorer pane or Code Explorer pane allows you to 'refresh'. As I say, not sure if this is what's needed.

Re: Script reload not showing changes?

Posted: 24 Jun 2020, 16:22
by submeg
DaveT1 wrote:
01 Jun 2020, 03:22
Not sure if this will help, but right clicking on AHKStudio's Project Explorer pane or Code Explorer pane allows you to 'refresh'. As I say, not sure if this is what's needed.
Thanls DaveT1, I gave that a go and no luck. I tried reindexing the current project and then both, but I still had to close AHK Studio completely to see my addition.

I also tried closing the file in AHK Studio and reopening, but also no good.

Does anyone know a way around this?

Re: Script reload not showing changes?

Posted: 11 Aug 2020, 19:20
by submeg
Bump. @maestrith, any ideas on this one?

Re: Script reload not showing changes?

Posted: 18 Aug 2020, 22:19
by maestrith
Alt+M Check For Edited Files On Focus {Enter}

Re: Script reload not showing changes?

Posted: 07 Jan 2021, 17:53
by submeg
maestrith wrote:
18 Aug 2020, 22:19
Alt+M Check For Edited Files On Focus {Enter}
@maestrith, I have that option enabled, does it mean I need to navigate away from the ahk file and then come back to put "focus" on it?

EDIT: When you navigate away from AHK Studio being the active program and then back, it puts the asterisk there and the changes to show it hasn't been saved! Perfect!