Seeking advice on how to deploy AHK script to a group

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JayM
Posts: 2
Joined: 26 Apr 2018, 11:14

Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 12:19

Hi - I'm a IT Project Coordinator and am new to working with AHK. I am working with a the Operations Manager of our Legal Dept. We have many attorneys who have to type in a lot of information and the Operations Manager wants to use AHK to create a script that will allow the attorneys to type in certain acronyms, and have the full terms spell out (for example, when the attorney types 'B R" the words "BOND RECOMMENDATION" appear).

The goal is for the Operations Manager to create and maintain this script, which will deploy on all the attorneys' PC's, and that the OPs Manager can make changes to the script and have those changes automatically be applied to the attorneys.

So, here is what I tried to do.
1. The OPs Manager creates the script (call it LegalHotKeys.ahk)
2. The OPs Manager converts it to a stand-alone executable using the "Convert .ahk to .exe"
3. I post the LegalHotKeys.exe to a folder on a network drive that is accessible to everyone in Legal.
4. I create a shortcut to the LegalHotKeys.exe in the same network folder.
5. We put the a copy of the shortcut to LegalHotKeys.exe into the startup folder on each of the attorney's PC's, so that the AHK executable runs when they restart their PC's.
6. When the OPs Manager wants to update or edit the script, she does that on her desktop. After making changes, she converts LegalHotKeys.ahk to an executable, and then replaces the LegalHotKeys executable in the folder on the network drive with the new one (named the same.

This is what I am trying to do in theory. However, when we tried to replace the executable on the network drive with the updated (same named) executable, we were unable to do this.
Maybe I am going about this the wrong way - I admit I am delving into new territory. Any advice on how to get my approach to work, or insights on a better way to accomplish this would be much appreciated.
Let me know if I can provide clarification or additional information. Thanks!

JayM
City of Boise
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 16:01

JayM wrote:This is what I am trying to do in theory. However, when we tried to replace the executable on the network drive with the updated (same named) executable, we were unable to do this.
I assume your problem is that you cannot replace a file on your network drive that is currently in use by other users on the network.

I don't know of a simple solution to this problem but thought I would distill the problem for those that might have suggestions.

One solution that I can think of would be to have the script make a local copy of itself then execute that local copy and then close itself (the network copy). The script would only do this copying if it detects that it is not running a local copy.

If someone does not have a clever way to overwrite a file in use, maybe I will explore this local copy option.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
RiRi Lopez

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 16:12

consider have the exe load the hotstrings from a central txt file

https://autohotkey.com/board/topic/4293 ... -txt-file/ this thread points you to another with the script


The only thing that will be updated is the txt file and that will be in the auto execute section of your script, you then run a timer every hour that checks if the text file changed in size and if it did just reload the script

when the programs load the text file it loads it into memory so you will not have a hard time replacing it even if people are using the program

hope this helps
RiRi Lopez

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 16:26

to open your mind further here is what I want you to do

create a text file called scuts.txt

in it put

::cob::City of Boise
::lol::laugh out loud

and save it in the same folder as your script

then create a script and type in

#Include, scuts.txt
return

and run it

now when you type cob or lol it works

You can update this txt file when you like.

You can set a timer in the script that checked every 30 minutes if the file scuts.txt has changed in filesize and if it did, reload the script

The only thing the manager will do is update a simple txt file, no need to have them play with ahk and compiling exe's again
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 16:47

Here is an example that works on my network.

Code: Select all

; Run Local Copy
if (SubStr(A_ScriptFullPath, 1, 2) = "\\")
{
	FileCopy, % A_ScriptFullPath, % A_Temp "\" A_ScriptName, 1
	Run, % A_Temp "\" A_ScriptName
	ExitApp
}

F12::
	MsgBox % A_ScriptFullPath
return

Esc::ExitApp
Very little testing but seems to work.

If the script runs and detects its path starting with "\\" it assumes this is a network copy and copies itself locally to the computer's temporary folder, executes that local version, then ends itself. The local version started by the network copy checks and it is local so it just continues executing normally.

You can overwrite the network version all you want because it is not actually running on any other computers except for a fraction of a second at startup. Any changes made to the network copy will not go into effect until reboot when the Startup folder runs the network version. Although you could have the script on a timer check ever so often time stamps and such and recopy and reload if the network copy changes.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 17:14

Here's what I do in a similar situation as OP.
I don't compile the script. I put the un-compiled .ahk file and the plain AutoHotkeyU32.exe on a network location. Then I create a shortcut to the .exe and pass it the script path.

Code: Select all

AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]
- https://autohotkey.com/docs/Scripts.htm#cmd
The shortcut target looks like this:

Code: Select all

"D:\FolderX\AutoHotkeyU32.exe" "D:\FolderX\MyScript.ahk"
JayM
Posts: 2
Joined: 26 Apr 2018, 11:14

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 17:19

Wow - thanks for the feedback. Yeah, I'm sure the issue I have is the inability to replace the file since it is in use.
These seem like great workarounds, when I get some bandwidth I'll give it a try... I'll follow up and post on how it works.
Thanks again,

JayM
RiRi Lopez

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 17:25

ignore my comments please, made a mistake about reload and #include
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 18:38

awel20 wrote:Here's what I do in a similar situation as OP.
I don't compile the script. I put the un-compiled .ahk file and the plain AutoHotkeyU32.exe on a network location. Then I create a shortcut to the .exe and pass it the script path.

Code: Select all

AutoHotkey.exe [Switches] [Script Filename] [Script Parameters]
- https://autohotkey.com/docs/Scripts.htm#cmd
The shortcut target looks like this:

Code: Select all

"D:\FolderX\AutoHotkeyU32.exe" "D:\FolderX\MyScript.ahk"
This seems like a good approach if the script does not have to be compiled.

You can even take it further by renaming the AutoHotkeyU32.exe to LegalHotKeys.exe then putting LegalHotKeys.exe and LegalHotKeys.ahk on the network. When you run LegalHotKeys.exe it will default to loading LegalHotKeys.ahk script without even having to include any parameters in the shortcut. You can of course use AutoHotkeyU64.exe or whatever flavor of AHK you like to rename to LegalHotKeys.exe.

With this approach it will be LegalHotKeys.exe that is in use, allowing LegalHotKeys.ahk to be changed at will without problems. It also saves the hassle of recompiling and copying to the network when edited.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Seeking advice on how to deploy AHK script to a group

26 Apr 2018, 18:59

I prefer to leave the original name on the .exe. That way you can have multiple scripts/shortcuts using only the one .exe.
I agree, renaming the .exe to the same name as the script is a nice feature. I use that approach for one of my larger scripts.
lancelot
Posts: 10
Joined: 12 May 2021, 11:05

Re: Seeking advice on how to deploy AHK script to a group

16 Jan 2022, 08:08

RiRi Lopez wrote:
26 Apr 2018, 16:26
to open your mind further here is what I want you to do

create a text file called scuts.txt

in it put

::cob::City of Boise
::lol::laugh out loud

and save it in the same folder as your script

then create a script and type in

#Include, scuts.txt
return

and run it

now when you type cob or lol it works

You can update this txt file when you like.

You can set a timer in the script that checked every 30 minutes if the file scuts.txt has changed in filesize and if it did, reload the script

The only thing the manager will do is update a simple txt file, no need to have them play with ahk and compiling exe's again
Any idea if this would work with compiled ahk executables? Guessing not

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mcd, Nerafius and 130 guests