Do Autohotkey scripts require running as administrator?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Do Autohotkey scripts require running as administrator?

13 Dec 2017, 18:37

I have a script that I wrote several years ago for ham radio applications. It has expanded and evolved over time and is still being updated. Since Windows 10, or maybe Windows 8, any GUI generated, such as the setup window, causes the program to terminate without warning, unless it is being run as administrator. Same behavior if running from ahk script of compiled exe. Is this normal? Or am I missing something?
Thanks,
Ed - W4ELP
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 18:51

No, they don't require being run as administrator unless you're trying to interact with a program that is running as admin or need to do system actions that require admin (such as copying to protected folders). Is your ham radio application running as admin? If so, then, your script needs to, as well.
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 19:21

No, the ham radio app does not run as admin. My script will run all day with no problem (mainly hotkeys), until it generates a GUI. It seems to be the presence of the GUI that causes the crash. I also made a very simple test program that just makes a small GUI and it crashes every time (after about 10-15 seconds) unless I run it as admin - then it's ok. I'm thinking this may be some setting in Windows 10 rather than a problem in Autohotkey.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 19:53

- So creating GUIs via the Gui command, causes a crash?
- What about commands like: MsgBox, InputBox, Progress, SplashImage, SplashTextOn, ToolTip, FileSelectFile, FileSelectFolder?
- Do GUIs in AHK v2 work?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 20:07

Msgboxes, tooltips and such run just fine - no problem. But if the program generates a GUI and does the GUI Show, the GUI may display for several seconds, then disappears as the program terminates. My typical GUI contains text, checkboxes and edit controls. Nothing fancy. I have tried all the options such as + and - DPIScale (thinking it may have been a display problem), but no difference.
My Autohotkey is v1.1.26.01. I haven't tried v2, but will do so.
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 20:27

Have you tried disabling your anti-virus and any other anti-malware apps to make sure that it's not the problem?
You also don't have the UAC settings in Windows set to the most secure, do you?

Here's about the simplest GUI that can be created:

Code: Select all

Gui, Add, Text, Test
Gui, Show
Put only those two lines into a new script and try it. If it doesn't crash, perhaps something in your own code is the problem.
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 20:42

Tried disabling all the anti-virus and such - no effect. Also had UAC settings to least secure.
The sample script is almost identical to the test script I was running today. I then spruced it up a bit as shown below. It will crash every time if NOT running as administrator.

Msgbox, This is a test to see if your computer will tolerate a Autohotkey-generated GUI window.`n`nWhen the next window appears, leave it alone and see if it disappears after a few seconds.`n`nIf it disappears, try right-clicking the program and "Run As Administrator" and see if that works.
Gui, Font, S40, Verdana
Gui, add, text, ,GUI crash test
Gui, show
sleep, 60000
Gui, Destroy
Gui, Font, S40, Verdana
Gui, Add, Text, ,Congratulations!`nYour computer passed the test.`n`nThe program will terminate in 10 seconds..
Gui, Show
Sleep, 8000
Gui, Destroy
Msgbox,,,Goodbye!,2
ExitApp

BTW - did some quick checking into Autohotkey v2 and it looks like a lot of recoding would be required. My main program is 5,000 lines and I'm not anxious to jump into that if I don't have to.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 20:51

- The AHK v2 idea, was just a thing I would try, I have no particular reason to believe it would work. I would try a very small script just to see if it worked.
- Have you tried GUI scripts of a few lines?
- The MsgBox command might be a bad example if just uses a simple Winapi function (MessageBox), I would try the other AHK commands.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 20:52

That code worked fine for me. My computer passed the test. It's not the code, but your system, apparently. Try closing as many programs and utilities from your system tray and Task Manager.
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 21:06

Interesting! Thanks, Osprey. That's encouraging.
I'd be very happy (and not surprised) to find that it's a setting in my system. Gradually closing everything possible via Task Manager is a good idea. I'll try that.
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 22:16

PROBLEM FOUND! (Maybe)
My main program is an add-on for the Ham Radio Deluxe suite, therefore that software is always running with mine. Their Logbook program is the culprit. Shutting it down allows my GUI's to run happily.
I went back in my Ham Radio Deluxe archives and found that all versions older than a certain date are ok - no conflict. Something changed in their program about 2 years ago that created the conflict, and it continues in the current versions.
Many thanks to jeeswg and Osprey for your input and suggestions. Without them I probably would have never looked at the obvious.
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Do Autohotkey scripts require running as administrator?

13 Dec 2017, 22:37

I'm glad to hear it. I wonder if you could keep the program from crashing your GUI by suspending it while the GUI is displayed.

https://docs.microsoft.com/en-us/sysint ... /pssuspend

In other words, just before showing the GUI, use the Run command to run PsSuspend.exe with the necessary parameters, then un-suspend it when the GUI is hidden.
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

14 Dec 2017, 05:41

Great idea, Osprey, but the Logbook needs to continue functioning while my program's GUIs are visible. It's curious that the crash does not occur if the Autohotkey script is running as administrator, and that it's only when a GUI is shown. The Logbook and rest of the HRD suite are NOT running as admin.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Do Autohotkey scripts require running as administrator?

14 Dec 2017, 06:11

- What exactly happens, the window is closed (and not destroyed)? The script continues to run? Does the script 'crash' in any way?
- Why would it only close AutoHotkey windows, and not other windows? Are other windows being closed?
- Is there something in the window title? So it thinks it's closing its own window?
- Is your script looking for something, which if found/not found closes the script/hides the window? I.e. is your script somehow closing itself?
- You could search the Internet for: 'AutoHotkey OnMessage WM_CLOSE', to see if the program is sending WM_CLOSE messages to your script.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Ed-W4ELP
Posts: 9
Joined: 13 Dec 2017, 18:24

Re: Do Autohotkey scripts require running as administrator?

14 Dec 2017, 20:39

jeeswg- The Autohotkey script just terminates without warning, and the GUI with it.
It's a total mystery why only Autootkey scripts seem to be affected (either running as ahk, or compiled - same effect). No other programs are affected as far as I can tell.
My script is not closing itself. I've made some very simple 2 or 3-line scripts for testing with all kinds of titles, borders, and other GUI attributes, but nothing makes any difference.
I'll try the search you suggested and see if anything pops up.
I've done more testing today and it's still just one specific commercial program that causes the autohotkey crash, and only versions of that program since May 31, 2015. Earlier versions are ok. Unfortunately it's part of the suite that my program works with, so it's always running when mine is running.
But with all that said - keep in mind that if I run the AHK as administrator, all is good - no crash. I was just hoping to find a solution and not have to run as admin, but I can live with that as long as it works.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 140 guests