Hi dears
To execute automatically my ahk script, I've put a shortcut in the windows startup folder. In that way, every time I open session in Windows, script is executed.
Unfortunately, I realized that I need to reaload my script in order to make it work. Any suggestion to avoid this manual step?
Best way to initiate a script
Re: Best way to initiate a script
I think I understand what you're trying to do, but I don't understand your problem. Does your script shutdown when you have used it? Should it shutdown?
There are a few ways to make a script easily available, f.ex:
FileCreateShortcut, %A_ScriptDir%\%A_ScriptName%, %A_Desktop%\Zizorz.lnk, %A_ScriptDir%,, Launch Zizorz, %A_ScriptDir%\data\img\Zizorz.ico, Z
In the above code, I call that function if the user wants to create a shortcut to Zizorz (with Z as a shortcut key, meaning Ctrl+Alt+Z will launch it). In your example, you can just do it manually.
There are a few ways to make a script easily available, f.ex:
- Have it autostart with Windows, like you mentioned - using the %A_Startup% folder
- Have one persistent script that includes hotkeys to launch your other scripts (and programs)
- Create a desktop shortcut to your script, and add a hotkey to it (only some hotkeys are supported)
FileCreateShortcut, %A_ScriptDir%\%A_ScriptName%, %A_Desktop%\Zizorz.lnk, %A_ScriptDir%,, Launch Zizorz, %A_ScriptDir%\data\img\Zizorz.ico, Z
In the above code, I call that function if the user wants to create a shortcut to Zizorz (with Z as a shortcut key, meaning Ctrl+Alt+Z will launch it). In your example, you can just do it manually.
Re: Best way to initiate a script
why "reload" your script to execute it ?
reload are ok only if you make some changes and must apply it ... for me
you use HotKey to start script ?
for example:
this script are active/work 24/24h and only when you press CTRL+ALT+w script are executed
but probably i not understand you
reload are ok only if you make some changes and must apply it ... for me
you use HotKey to start script ?
for example:
Code: Select all
;####################################################################################
;######## find active window position ##################################################
;####################################################################################
!^w:: ; <-- this are HotKey
WinGetPos , X, Y, Width, Height, 1
MsgBox %x% - %y% - %Width% - %Height%
Return
but probably i not understand you
Re: Best way to initiate a script
or, i think other use
Code: Select all
#Persistent
SetTimer, Alert1, 500 ;check time every half second.
return
Alert1:
;your code executed every half second
IF ...
{
...
}
Return
Re: Best way to initiate a script
I think I didn't provide enough detail.
My script is recoding some mouse buttons. Therefore, I want it active and executed since I start windows session.
To do that, I've included a shortcut to the scrito in the startup windows folder. The script is executed and is always present in the task bar, but my problem (I don't know why because I make no changes) is I must reload it to make it work.
I don't know why...
My script is recoding some mouse buttons. Therefore, I want it active and executed since I start windows session.
To do that, I've included a shortcut to the scrito in the startup windows folder. The script is executed and is always present in the task bar, but my problem (I don't know why because I make no changes) is I must reload it to make it work.
I don't know why...
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Best way to initiate a script
Sounds like a privilege issue. In the shortcut you have, make sure it's set to run as administrator. Windows 10 doesn't allow rebinds/hotkeys without admin.