8) Just add this to your scripts to have it automatically reload if it is changed!
All it does is set a timer to check if the attrib of the file is A, that is altered, and if so reloads the script.
A real timesaver!
Skrommel
;STARTOFSCRIPT
SetTimer,UPDATEDSCRIPT,1000
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,500
Reload
}
Return
;ENDOFSCRIPT
Automatic reload of changed script
Started by
skrommel
, Apr 19 2004 11:38 PM
57 replies to this topic
#1
-
Posted 19 April 2004 - 11:38 PM
great time saver idea!
#3
-
Posted 20 April 2004 - 01:03 AM
CleanNews.in : Bite sized latest news headlines from India with zero bloat
if there's one file attribute that i never really understood ever since DOS days, then its 'archive' .... mind shedding some light skrommel?
#4
-
Posted 20 April 2004 - 05:08 AM
CleanNews.in : Bite sized latest news headlines from India with zero bloat
:idea: The A attribute stands for Archive. It's used to tell if a file has changed. Very handy for backups using XCOPY /M to copy only the files changed since the last backup.
#5
-
Posted 20 April 2004 - 08:14 AM
uh-huh...thanx!
#6
-
Posted 20 April 2004 - 09:52 AM
CleanNews.in : Bite sized latest news headlines from India with zero bloat
Hi,
I'm a tooltip-fan, so I changed the script, to show a tooltip at the cursor.
Tekl
I'm a tooltip-fan, so I changed the script, to show a tooltip at the cursor.
UPDATEDSCRIPT: FileGetAttrib,attribs,%A_ScriptFullPath% IfInString,attribs,A { FileSetAttrib,-A,%A_ScriptFullPath% posX = %A_CaretX% posY = %A_CaretY% ToolTip,Updated script,%posX%,%posY% Sleep,500 Reload } Return
Tekl
#8
-
Posted 29 October 2004 - 01:33 PM
Hello:
I donĀ“t know so much about it, but how can I replace a script.exe file that is been in use by a #persistent script????
Thanks for All
I donĀ“t know so much about it, but how can I replace a script.exe file that is been in use by a #persistent script????
Thanks for All
#9
-
Posted 29 October 2004 - 05:05 PM
Ok, I've a compiled script thas is loaded when start the Pc and never down.
If I want to change it, with a new version, the system send an error because the file is in use.
Can it be replaced in any way?
Thanks
If I want to change it, with a new version, the system send an error because the file is in use.
Can it be replaced in any way?
Thanks
#11
-
Posted 30 October 2004 - 03:21 PM
Two possibilities:
1) If possible, don't run it as a compiled script. When run normally, the method in the posts above will work.
2) Launch another EXE or script that runs ahk2exe to re-compile the first script. When it's done, run the original EXE (which is now new because it was recompiled). Something like this:
1) If possible, don't run it as a compiled script. When run normally, the method in the posts above will work.
2) Launch another EXE or script that runs ahk2exe to re-compile the first script. When it's done, run the original EXE (which is now new because it was recompiled). Something like this:
#z:: Run Recompile.exe "%A_ScriptFullPath%" ExitAppFor Recompile.ahk:
if 1 = ; No param given. ExitApp Sleep, 200 ; Give the other script time to exit. SplitPath, 1,, OutDir, OutExtension, OutNameNoExt Run %ProgramFiles%\AutoHotkey\Compiler\ahk2exe.exe /in "%OutDir%\%OutNameNoExt%.ahk" /out "%1" /icon MyIcon.ico /pass MyPasswordThe above will need to be modified if your original script isn't in the same folder as the EXE. It might need other changes for your configuration.
#12
-
Posted 30 October 2004 - 03:38 PM
The scriptlet in this post may benefit from a SplashTextOff statement after the Sleep but before the Reload.
This ensures that the SplashText disappears, even if the Reload fails:
This ensures that the SplashText disappears, even if the Reload fails:
SetTimer,UPDATEDSCRIPT,1000 UPDATEDSCRIPT: FileGetAttrib,attribs,%A_ScriptFullPath% IfInString,attribs,A { FileSetAttrib,-A,%A_ScriptFullPath% SplashTextOn,,,Updated script, Sleep,500 SplashTextOff Reload } Return ;ENDOFSCRIPT
#13
-
Posted 06 June 2005 - 07:47 PM
Adding SplashTextOff to the end of the routine was my first modification the day i first adopted skrommel's script back in March (which i learned from Example 3 at the end of Wolfgang Reszel's review... it is one of the most useful scripts for those who use AutoHotkey a lot... i had previously been using a hotkey for reload, but automatic is even better), but i later moved the SplashTextOn & Off to immediately before the end of the Configuration section, which also added the visual benefit of indicating when it has reached that point. Plus i use two timers, one for when the .ini file is open (checking every sec) and one for when it is not, checking every 20 sec if it has just been opened.
#14
-
Posted 07 June 2005 - 01:48 AM
1) The Open Source Definition http://www.opensourc...ition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <>
2) Intuitive. Logical. Versatile. Adaptable. <
Thank Skrommel for the graet idea. Some how the SetTimer approach did not always work on my computer, so I modified the script as follows, it will reload whenever it is saved.
$^s:: IfWinActive, %A_ScriptName% { Send, ^s SplashTextOn,,,Updated script, Sleep,200 SplashTextOff Reload } else Send, ^s return
#15
-
Posted 16 August 2005 - 09:15 PM