Help with reload

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Help with reload

22 May 2017, 10:30

hii,

i want reload a script by a code exactly like i reload it in the picture below
i know i can use reload, but its keeps reloading the script non stop and i want it to reload it only one time

Image


smaple code below do it like i want,
reload it only one time but it requires to press alt+ctrl+r to make it

Code: Select all

;Reload the current AutoHotKey script
^!r::
SplashTextOn, , , Reloading....
Reload
Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
SplashTextOff
MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
IfMsgBox, Yes, Edit
return
any way to reload it only 1 time without any hotkeys ?

thanks in advance
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Help with reload

22 May 2017, 12:25

So it sounds like when it reloads a lot, you've put Reload in the auto-execute section.

I don't know what you mean by reloading once. You ca give your script instructions to reload every 15 minutes by doing something like this:

Code: Select all

SetTimer, reload_delay, -900000
return

reload_delay:
reload
But it's every 15 minutes, even if we specify a negative in the timer, because when the script loads again, it'll set the timer again.

We'd really need to know the context of what you want to do to figure out why you'd want to reload it once - and how you think the script should know when it needs to do that reloading.
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Help with reload

22 May 2017, 12:30

Unless it can be found in the auto-execute sectionof your script the reload command have to be triggered somehow: apart from hotkey registering you can listen selectively for one or more event to occur (using settimer for example) and that motivates the script to reload actually.

Code: Select all

#Persistent
WinWait, ahk_class Notepad
SetTimer, reloadOnNotepadClose, 500
return

reloadOnNotepadClose:
if not (WinExist("ahk_class Notepad")) {
MsgBox
reload
}
return
If you want this event to to be listen just once you have to consider that reload command will make your script start off fresh of any variable so that it will be necessary to save somewhere outside the script (taking advantage of ini commands for instance) a persistent boolean depending on whether or not the command has yet been executed.

Hope this helps
my scripts
donovv
Posts: 108
Joined: 15 Apr 2017, 21:06

Re: Help with reload

22 May 2017, 12:44

Code: Select all

menu, tray, add, reload, menuhandler

menuhandler:
reload
return
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: Help with reload

23 May 2017, 01:49

Thank you all.
its more clear now.
maybe i will post my script if needed later on..

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kingina and 225 guests