Script disabled on some windows, why? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jagusztinl3
Posts: 3
Joined: 17 Sep 2021, 00:55

Script disabled on some windows, why?

Post by jagusztinl3 » 17 Sep 2021, 05:03

I have this script, that simulate mouse buttons on CapsLock and Windows key (perfect for laptops without mouse keys):

Code: Select all

Lwin::
click Down left
keywait Lwin
click Up left
return
CapsLock::
click Down right
keywait Capslock
click Up right
return
[Mod edit: [code][/code] tags added.]

The proble is that on some windows (admin rights popup, services administration) stops working, do nothing. After navigating from the window, working again,

Steps to reproduce:
-Start the script
-Start services.msc
-Try to use capslock or windows key to push mouse buttons on the Services window
-Expected behaviour: script to work on all window types
-Symptom: On services window, mouse key simulation not working

Please help, no idea how to solve it...
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Script disabled on some windows, why?  Topic is solved

Post by mikeyww » 17 Sep 2021, 05:29

You probably need to run your script as admin.
jagusztinl3
Posts: 3
Joined: 17 Sep 2021, 00:55

Re: Script disabled on some windows, why?

Post by jagusztinl3 » 17 Sep 2021, 09:20

Unfortunately running as admin did not help, tried it.
Simply AHK stops functioning on services.msc or for example any popup that asks for admin rights.
User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: Script disabled on some windows, why?

Post by MrDodel » 17 Sep 2021, 10:04

I've just tested this with Services.msc and it works fine when run as admin.

Pressing capslock gives me the right click menu, pressing Lwin brings up the properties for the selected services.
jagusztinl3
Posts: 3
Joined: 17 Sep 2021, 00:55

Re: Script disabled on some windows, why?

Post by jagusztinl3 » 18 Sep 2021, 11:59

You are right, thank you, running AHK with admin rights solve the services.msc window problem, but not all of them. New steps to reproduce:

-Start the AHK script, in the first post, with admin rights
-Start any program (for example CMD) with admin rights (use context menu, run with admin rights..)
-Try to click the yes or no button on the admin rights approval popup window with capslock (AHK simulated mouse button)
-Expected behaviour: script to work on all window types
-Symptom: On admin rights popup window, mouse key simulation not working

Please help, I have no idea how to solve it...
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Script disabled on some windows, why?

Post by mikeyww » 18 Sep 2021, 20:07

Here is some info about UAC. Perhaps it will help (I did not test).
ludamo
Posts: 44
Joined: 25 Mar 2015, 02:21

Re: Script disabled on some windows, why?

Post by ludamo » 19 Sep 2021, 00:51

I think you are trying to click a button (with AHK) on the User Account Control Dialog which comes up when the rest of the screen goes blank. I think this is a Windows security feature that this could only be clicked by a physical mouse click (or use Tab then Enter) by the user otherwise any malware could easily give itself Administrator rights e.g. set a timer to programmatically click on the Yes Button after asking for Admin rights.

If you want to run cmd or anything else easily as Admin then you could use the Run command from an elevated AHK script.
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Script disabled on some windows, why?

Post by mikeyww » 19 Sep 2021, 05:35

Another option, if UAC is not desired, is to lower its level in the Windows settings. That also lowers security, but so would a script that automatically accepts the prompt.
Post Reply

Return to “Ask for Help (v1)”