Script reload not showing changes?

Editor for AutoHotkey written completely in AutoHotkey.

Moderator: maestrith

User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Script reload not showing changes?

Post by submeg » 31 May 2020, 20:43

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

____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

DaveT1
Posts: 218
Joined: 07 Oct 2014, 11:23

Re: Script reload not showing changes?

Post by DaveT1 » 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.

User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Re: Script reload not showing changes?

Post by submeg » 24 Jun 2020, 16:22

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?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Re: Script reload not showing changes?

Post by submeg » 11 Aug 2020, 19:20

Bump. @maestrith, any ideas on this one?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

User avatar
maestrith
Posts: 825
Joined: 16 Oct 2013, 13:52

Re: Script reload not showing changes?

Post by maestrith » 18 Aug 2020, 22:19

Alt+M Check For Edited Files On Focus {Enter}
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32

User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Re: Script reload not showing changes?

Post by submeg » 07 Jan 2021, 17:53

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!
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

Post Reply

Return to “AHK Studio”