AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Automatic reload of changed script
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Wed Aug 17, 2005 6:51 am    Post subject: Reply with quote

Hi pwy,

Then this might work for you too
Code:
~^s::
  IfWinActive, %A_ScriptName%
    {
       SplashTextOn,,,Updated script,
       Sleep, 200
       SplashTextOff
       Reload
    }
return

_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pwy
Guest





PostPosted: Thu Aug 18, 2005 8:37 pm    Post subject: Reply with quote

Thanks toralf.

Your code is purer.
Back to top
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Sat Oct 15, 2005 9:14 am    Post subject: Reply with quote

Since that SplashText info didn't look too good (grey on grey) on my PC I tried to change it to a TrayTip.

Edit - Moderator: Removed code, see next post
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Wed Nov 02, 2005 3:42 pm    Post subject: Reply with quote

Here's the latest and improved version, fresh from http://www.autohotkey.com/forum/viewtopic.php?p=36886 Smile

Code:

$^s::
  Send, ^s
  IfWinActive, AutoHotkey
    {
       TrayTip, Timed TrayTip, updated AutoHotkey script
       SetTimer, RemoveTrayTip, 6000
     }
return

RemoveTrayTip:
    SetTimer, RemoveTrayTip, Off
    TrayTip
    Reload
return

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 147

PostPosted: Thu Nov 24, 2005 6:23 am    Post subject: Reply with quote

I updated it again to use it with Win32Pad, a small and fast editor. Works also with other editors that display "AutoHotkey.ini" in the window title if that script is loaded.

Code:

;2005-11-23
;auto-reloads the AHK script
;http://www.autohotkey.com/forum/viewtopic.php?t=135&highlight=auto+reload
$^s::
  Send, ^s
  SetTitleMatchMode, 2
  IfWinActive, AutoHotkey.ini
    {
       TrayTip, AutoHotkey, reloading script...
       SetTimer, RemoveTrayTip, 1500
     }
return

RemoveTrayTip:
    SetTimer, RemoveTrayTip, Off
    TrayTip
    Reload
return
;http://www.autohotkey.com/forum/viewtopic.php?t=135&highlight=auto+reload

_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
Zoandar



Joined: 08 Jun 2006
Posts: 91
Location: Northern Ohio - USA

PostPosted: Wed Jun 14, 2006 9:35 pm    Post subject: An alternative to Splash Text Reply with quote

Since I use dual monitors, and do most of my script editing on the "extended" desktop of the 2nd monitor, using the different variations that utilize Splash Text make the "splash" appear on the blue-sky background of my primary monitor's desktop.

It maks it hard to read, and happens rather quickly. So, I modified a slightly earlier version of your scripts and used a GUI instead of a Splash text. No mistaking this notifier! Smile

Code:

;STARTOFSCRIPT ->>> Auto-Reload script if it is edited and saved

~^s::
  IfWinActive, %A_ScriptName%
    {
       Gui, Show, x1385 y217 h198 w377, Generated using SmartGUI Creator ; create message box at    

   secified coordinates

   Gui, Font, s14 cRed Bold, Verdana ; Set new default font for window
   Gui, Add, Text, x65 y106, Script Was Reloaded. ; Text line if message box

   Sleep 1000  ;wait 1 seconds

   Gui, Destroy  ; Closes GUI message box + releases memory it used.
          Reload
    }
return

;ENDOFSCRIPT ->>> Auto-Reload End
;


Please excuse, but for some reason my indentation used in this code is not being correctly rendered here in the previewer. Question
_________________
Zoandar - new user - still learning.
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6702
Location: France (near Paris)

PostPosted: Thu Jun 15, 2006 9:50 am    Post subject: Re: An alternative to Splash Text Reply with quote

Zoandar wrote:
Please excuse, but for some reason my indentation used in this code is not being correctly rendered here in the previewer. Question
Mixing tabs and spaces is often a bad idea, even more when you cannot control the size of the tabs...
Don't forget that when you copy/paste code from the forum, you will get only spaces, even if the original code used tabs. phpBB puts three spaces per tab, so you can do a search/replace after pasting to homogenize the indenting.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Thu Jun 15, 2006 11:57 am    Post subject: Reply with quote

Before you paste text, go to your editr and use option
"replace tabs with spaces"
_________________
Back to top
View user's profile Send private message MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Thu Jun 15, 2006 12:58 pm    Post subject: Reply with quote

BTW, from this post, I can conclude that Tooltip MUST have following attributes: autoclose. This is what I suggest:


Code:

Tooltip, <text> [, [-]posX, [-]posY, Timeout ]


<text> - text to display
posX,Y - position on screen, specify - for absolute position
Timeout - close tooltip automaticaly after X seconds.

I will post this to the wish list also.
_________________
Back to top
View user's profile Send private message MSN Messenger
dale3h



Joined: 03 Dec 2006
Posts: 1
Location: Waco, TX

PostPosted: Tue Dec 05, 2006 6:57 am    Post subject: Reply with quote

Here's my contribution, basically using it as an include.

File: AutoReload.ahk
Code:
SetTimer, ReloadScriptIfChanged, 1000

ReloadScriptIfChanged:
{
  FileGetAttrib, FileAttribs, %A_ScriptFullPath%
  IfInString, FileAttribs, A
  {
    FileSetAttrib, -A, %A_ScriptFullPath%
    TrayTip, Reloading Script..., %A_ScriptName%, , 1
    Sleep, 1000
    Reload
    TrayTip
  }
  Return
}

And in your AHK file that you want to auto reload, put this on the first line:
Code:
#Include AutoReload.ahk

Just be sure that your script and AutoReload.ahk reside in the same directory.
_________________
Proud to be a Texan
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
BETLOG



Joined: 27 Nov 2006
Posts: 218
Location: Queensland, Australia

PostPosted: Fri Dec 08, 2006 4:31 pm    Post subject: Reply with quote

This is awesome, and so logical; i've wanted to find a way to handle this globally for ages, MANY thanks

[edit] SetTitleMatchMode

Incidentally, this splashIMAGE looks nicer (more visible) to me...

Code:
~^s::
SetTitleMatchMode, 2   ;--- works in ANYTHING displaying scripts name as ANY part of the window title
IfWinActive,%A_ScriptName%
{
  SplashImage , ,b1 cw008000 ctffff00, %A_ScriptName%, Reloaded
  Sleep,750
  SplashImage, Off
  Reload
}
return


I insert it with a hotstring in my persistent script:
Code:
:r:ReloadOnSave::#Include, x:\......\ReloadOnSave.ahk


Last edited by BETLOG on Thu Dec 28, 2006 8:21 am; edited 4 times in total
Back to top
View user's profile Send private message
Azerty
Guest





PostPosted: Wed Dec 13, 2006 2:56 pm    Post subject: Reply with quote

Skrommel, this one is a really wonderful WINNER - Thanx

Azerty
Back to top
clintster



Joined: 27 Dec 2006
Posts: 2

PostPosted: Wed Dec 27, 2006 5:55 pm    Post subject: My script not working if reload script is used Reply with quote

dale3h:

Thanks for your cool script, and use of include.

The reloading works perfectly, including the display of the traytooltip.

I have a script that works perfectly, but it doesn't work if ur reload code is included, or pasted at the top of the script. I think my problem might have something to do with the #ifwinexist hotkey definition I'm using.

I'm new to hotscript so think it might be something small i'm doing wrong in my script. Hopefully you can help - thanks!

Here is my script, which starts with your reload code...

SetTimer, ReloadScriptIfChanged, 1000
ReloadScriptIfChanged:
{
FileGetAttrib, FileAttribs, %A_ScriptFullPath%
IfInString, FileAttribs, A
{
FileSetAttrib, -A, %A_ScriptFullPath%
TrayTip, Reloading Script..., %A_ScriptName%, , 1
Sleep, 1000
Reload
TrayTip
}
Return
}


SetTitleMatchMode, 2

;my script starts here.....

ifwinexist, ACDSee 9 Photo Manager
{
#ifwinactive, ACDSee 9 Photo Manager
^!D:: ;Keyboard Shortcut Ctrl-ALT-D runs this script. Hotkey only active if ACDSee is open
winMaximize ; Maximizes the ACDSee Manager window found by IfWinActive above.
DetectHiddenText, Off
WinGetPos, ,, Width, Height
if (Width = 1288) and (Height = 778)
IfWinExist,,Properties - EXIF ;;Properties - EXIF sub-window is always hidden, but hidden text is not detected based on command above
Click, Left,1240, 335,3 ;Activate Image Description Edit box. Mouse clicked three times as sometimes edit box not activated if clicked less
else
{
send !{Enter} ;Activates Properties Windows
click, Left, 1123, 734 ;Activate EXIF tab
Click, Left, 1240, 335,3 ;Activate Image Description Edit box
}
return ;ends hotkey function
}
Back to top
View user's profile Send private message
BETLOG



Joined: 27 Nov 2006
Posts: 218
Location: Queensland, Australia

PostPosted: Thu Dec 28, 2006 8:10 am    Post subject: Reply with quote

As Torlaf pointed out on the top of this page: we are all over-complicating this script. My version is the same as Torlafs', except it should work in ANY window that displays the script name in ANY part of it's title.
http://www.autohotkey.com/forum/viewtopic.php?p=93714#93714
...and it works as an include (as does his I assume).

May i suggest that if possible you use controlsend instead of the mouseclicks? It's much more reliable, won't require maximizing the window, is resolution independent, and doesn't need to interfere with the users mouse movement.
Back to top
View user's profile Send private message
clintster



Joined: 27 Dec 2006
Posts: 2

PostPosted: Thu Dec 28, 2006 10:01 am    Post subject: Reload works Reply with quote

Hi

Thanks. I found the problem was because I placed SetTitleMatchMode,2 after the include command. It's before and it works perfectly.

I still prefer the traytip so combined your script and his.

I will definitely use the controlsend command - thank you!! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group