 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
skrommel Guest
|
Posted: Tue Apr 20, 2004 12:38 am Post subject: Automatic reload of changed script |
|
|
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 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10450
|
Posted: Tue Apr 20, 2004 12:50 am Post subject: |
|
|
| That's very innovative, thanks for sharing. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1715
|
Posted: Tue Apr 20, 2004 2:03 am Post subject: |
|
|
great time saver idea! _________________
 |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1715
|
Posted: Tue Apr 20, 2004 6:08 am Post subject: |
|
|
if there's one file attribute that i never really understood ever since DOS days, then its 'archive' .... mind shedding some light skrommel? _________________
 |
|
| Back to top |
|
 |
skrommel Guest
|
Posted: Tue Apr 20, 2004 9:14 am Post subject: The A attribute |
|
|
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. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1715
|
Posted: Tue Apr 20, 2004 10:52 am Post subject: |
|
|
uh-huh...thanx! _________________
 |
|
| Back to top |
|
 |
jamestr
Joined: 05 Apr 2004 Posts: 96 Location: Connecticut USA
|
Posted: Tue Apr 20, 2004 11:38 pm Post subject: sweet! |
|
|
| even sweeter! |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 808 Location: Germany
|
Posted: Fri Oct 29, 2004 2:33 pm Post subject: |
|
|
Hi,
I'm a tooltip-fan, so I changed the script, to show a tooltip at the cursor.
| Code: |
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 |
|
| Back to top |
|
 |
K-Lel
Joined: 26 Jun 2004 Posts: 6
|
Posted: Fri Oct 29, 2004 6:05 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10450
|
Posted: Sat Oct 30, 2004 2:06 pm Post subject: |
|
|
| Can you clarify? |
|
| Back to top |
|
 |
K-Lel
Joined: 26 Jun 2004 Posts: 6
|
Posted: Sat Oct 30, 2004 4:21 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10450
|
Posted: Sat Oct 30, 2004 4:38 pm Post subject: |
|
|
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: | Code: | #z::
Run Recompile.exe "%A_ScriptFullPath%"
ExitApp |
For Recompile.ahk: | Code: | 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 MyPassword |
The 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. |
|
| Back to top |
|
 |
guivho
Joined: 04 Jun 2005 Posts: 26 Location: Lokeren, Belgium
|
Posted: Mon Jun 06, 2005 8:47 pm Post subject: Re: Automatic reload of changed script |
|
|
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:
| Code: |
SetTimer,UPDATEDSCRIPT,1000
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,500
SplashTextOff
Reload
}
Return
;ENDOFSCRIPT
|
|
|
| Back to top |
|
 |
Decarlo110
Joined: 15 Dec 2004 Posts: 303 Location: United States
|
Posted: Tue Jun 07, 2005 2:48 am Post subject: |
|
|
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. _________________ 1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>> |
|
| Back to top |
|
 |
pwy Guest
|
Posted: Tue Aug 16, 2005 10:15 pm Post subject: Auto Reloading |
|
|
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.
| Code: | $^s::
IfWinActive, %A_ScriptName%
{
Send, ^s
SplashTextOn,,,Updated script,
Sleep,200
SplashTextOff
Reload
}
else
Send, ^s
return |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|