Best way to initiate a script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sanscrito
Posts: 7
Joined: 21 Jul 2019, 10:05

Best way to initiate a script

24 Jul 2019, 04:38

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?
User avatar
sumon
Posts: 38
Joined: 01 Oct 2013, 14:05
Location: Stockholm, Sweden

Re: Best way to initiate a script

24 Jul 2019, 04:53

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:
  • 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)
Example of code for the third example:
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.
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Best way to initiate a script

24 Jul 2019, 05:14

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:

Code: Select all

;####################################################################################
;######## find active window position ##################################################
;####################################################################################
!^w:: ; <-- this are HotKey
WinGetPos , X, Y, Width, Height, 1
MsgBox %x%  - %y% - %Width% - %Height%
Return
this script are active/work 24/24h and only when you press CTRL+ALT+w script are executed

but probably i not understand you :angel:
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Best way to initiate a script

24 Jul 2019, 05:19

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
sanscrito
Posts: 7
Joined: 21 Jul 2019, 10:05

Re: Best way to initiate a script

24 Jul 2019, 13:11

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...
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Best way to initiate a script

24 Jul 2019, 16:45

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.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, jollyjoe and 147 guests