Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Autohotkey_L cannot send commands to Windows 8 windows?


  • Please log in to reply
18 replies to this topic
deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011

I'm using AutoHotkey_L v1.1.08.01 with Windows 8 Enterprise 64-bit. This is the RTM version of Windows 8, not the Developer or Consumer Preview.

I've noticed that AutoHotkey still works for sending input to applications, but I can't get it to interact with any windows. For example, I have a little script that opens up the UAC window and is supposed to slide the slider down to Never notify:
 

	;~ Open the UAC Window
	SendInput, #r
	WinWaitActive, Run
	SendInput, C`:\Windows\System32\UserAccountControlSettings.exe
	SendInput, {Enter}
	WinWaitActive, User Account Control Settings
	
	;~ Method 1:
	ControlFocus, msctls_trackbar321
	ControlSend, msctls_trackbar321, {Down}{Down}
	ControlSend, Button1, {Enter}
	SendInput, y
	
	;~ Method 2:
	SendInput, {Tab}{Down}{Down}{Down}{Tab}{Enter}y
	
	;~ Method 3:
	MouseClickDrag, Left, 148, 243, 148, 373
	MouseClick, Left, 1964, 1792


This will open the UAC window, so the script is able to interact with the little Run window alright, but Methods 1, 2, and 3 do not do anything. I would expect that with Method 2 the control that has focus would change, or with Method 3 the mouse would at least move, but nope, nothing. I've tried creating an AHK script to interact with the Windows 8 Task Manager window as well, but get the same thing; AHK is not able to interact with the window at all.

Can anybody else verify that this is a problem for them? Or have any ideas/suggestions of other things to try? I'm assuming this is a "bug" with AHK and that a new release will be required to increase compatibility with Windows 8, but any suggestions are appreciated. Thanks.

 

-- EDIT --

So it turns out the problem was that the AHK script needs to run as admin to be able to interact with any windows requiring admin privileges (e.g. the UAC window, Control Panel, etc.).  In my blog I show how to have the scripts run as admin when launched manually, and when running a script automatically at login.



tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
:twisted: this probably has more to do with blocking virtual keystroks in the UAC than them not working in general
I wonder why anyone would want to automate this any how
Never lose.
WIN or LEARN.

deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011

:twisted: this probably has more to do with blocking virtual keystroks in the UAC than them not working in general

Then why does the Task Manager have the same problem?

I wonder why anyone would want to automate this any how

Our office admins have it preset to have the UAC notifications return to the default level after every reboot by using a Group Policy, so I want to automate the task of changing the notification level down to never. I realize that I could also disable UAC completely through the registry, but my understanding is if I do this then I cannot use the Windows Store.

deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011
After a bit more testing, AHK is able to interact with the Windows Explorer window, but not with the Computer Management window, or even pop the Win+X menu (yet Win+R and Win+E work fine). So I'm not sure if Windows 8 has purposely made some power-user windows/functions not automatable, or if this is just a "bug" with AHK.

Here's another example script that is supposed to interact very simply with the Computer Management window:

	SendInput, #r
	WinWaitActive, Run
	SendInput, `%windir`%\system32\compmgmt.msc
	SendInput, {Enter}
	WinWaitActive, Computer Management
	
	MouseMove, 100, 100
	SendInput, {Down}{Down}{Down}

With this script, not even MouseMove does anything.

Again, any other suggestions are appreciated. Thanks.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
I am so happy to hear that these things are being blocked in win8 and truly hope that limitations such as this are not worked around any time soon. this is a useful but of security
Never lose.
WIN or LEARN.

deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011
Arg, this is getting very frustrating now. So it looks like Windows blocks automation on any windows that require admin privileges. For example, you can launch a command prompt window and paste text into it, unless you launch it with administrative privileges; then you can't interact with it at all :(

I agree that from a security standpoint it is great, but from a developer standpoint who just wants to automate all the tedious daily tasks this really sucks.

For example, I need to launch my visual studio instances with admin privileges because my solutions talk to IIS. AutoHotkey's RunAs command only works with executables, not with .sln files. My workaround was going to be to launch the .sln file from the command prompt using it's RunAs command. However, I can only RunAs an administrator if the command prompt is running as an administrator, which then prevents from from interacting with the command prompt window :( Arg, so frustrated.

I'm still open to any suggestions. Thanks.

Wingfat
  • Members
  • 937 posts
  • Last active: Oct 14 2015 04:20 PM
  • Joined: 23 Aug 2004
Have you set your IIS program to run as Admin Always?
1. Take your mouse to bottom left hand corner to pop out Start Panel. Now click Search
2. This will open Search Apps windows and will list most commonly used apps. Search for the app if its not listed there.
3. Right click the app icon which you want to run as administrator. After right click, a check mark will appear on the icon.
4. And at the bottom you will get Advanced option this App. Click on the Advanced icon and select Run as administrator.

Edit:
Also.

The solution is to right click on the devenv.exe (for VS Studio 2008, under C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE), select properties and go to the compatibility tab and set “Run this program as administrator”.
then.. when trying to run a .sln file the version selector is invoked (when having multiple versions of VS Studio installed),the vslauncher.exe (under C:\Program Files (x86)\Common Files\microsoft shared\MSEnv). This must also run with administrator rights,! By doing the same procedure as above to run as an administrator, double clicking on .sln files finally worked!


----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------

deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011
Thanks for the reply Wingfat. The solution you give of running IIS as an administrator is no good, as I don't want to have to manually launch it from the metro UI and specifically tell it to run as an administrator every time I want to use it :(

I was excited about your edit though as it looked promising, but digging further it appears that MS has removed the Compatibility Tab from the Properties menu in Windows 8, so that is not a work around either :(

Also another major concern is that AHK does not work at all when any programming running with Administrator priviledges has focus. So for example, I can manually run Notepad, Visual Studio, etc. as an Administrator, but if that app has focus then no hotkeys or hotstrings will work. This really sucks for me as I use AHK Command Picker to launch and do almost everything on my PC; basically I can access anything on my pc in a couple key strokes. I launch the utility with the Caps Lock key, but if I'm in an admin app they the AHK Command Picker does not launch :(

I live and breathe AHK, so if there isn't a work around for this then I'll be switching back to Windows 7 until this is overcome; yes I really do love and depend on AHK that much. It just sucks that Windows 8 has crippled it so badly :(

GodlyCheese
  • Members
  • 719 posts
  • Last active: Nov 11 2014 07:12 PM
  • Joined: 30 Aug 2012
"I don't want to have to manually launch it from the metro UI and specifically tell it to run as an administrator every time I want to use it"

I'm not sure if this works with Windows 8, but you should have a look at this thread: You might be able to have it work for Windows 8 with a bit of editing. I'd try to help more, but I don't have Windows 8 to test with (metro = lol).

Windows 7 is the only acceptable OS Microsoft has made.

deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011
Thanks GodleyCheese. While I wasn't actually able to get that RunAsAdmin script to work properly (it didn't seem to make any difference), I did discover that if I manually run my AHK script as administrator then it is able to interact with all windows as you would expect, including other apps that are running as administrator :) So that is the solution; you need to run your AHK scripts as administrator. Thanks for the help everyone :)

joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Nov 02 2019 08:38 PM
  • Joined: 20 May 2012
Yeah, i tried windows 8, and it sorta sucks, (Dont take it wrong, its just that, I hate it when they tried to force to one, to use the new things and it not being backwards compatible at all!) So, I think ill just stick with Windows 7, if not ill switch to mac or linux.. :P

HEAR ME MICROSOFT!!!

lolPosted Image
Why ahkscript.org? - autohotkey.com is outdated

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
joedf, your post is late and misguided. The OP's "problem" applies equally to Windows Vista, Windows 7 and Windows 8.

I have a little script that opens up the UAC window and is supposed to slide the slider down to Never notify:


This should be obvious by now: the OP's script was attempting to disable the very security feature which was preventing it from working. What do you think the purpose of UAC would be if any and every program could simply bypass it by sending keystrokes?

For future reference: Enable interaction with administrative programs.


FrostByte
  • Members
  • 148 posts
  • Last active: Sep 16 2015 05:56 PM
  • Joined: 08 Nov 2012
Wow, this is stupid. Just go to your Control Panel and disable UAC from there. Use common sense. Please.

FrostByte and the Artemis Asylrum® Corporation
View my projects: Artemis Media Player

FrostByte62.com is down. I'll find another place to host my stuff soon...after I get done procrastinating some more. :)


AutoHotkeyDragon
  • Members
  • 90 posts
  • Last active: Sep 01 2013 11:06 PM
  • Joined: 20 Oct 2012

Wow, this is stupid. Just go to your Control Panel and disable UAC from there. Use common sense. Please.


I realize that I
could also disable UAC completely through the registry, but my understanding is if I do this
then I cannot use the Windows Store.


Use common sense, FrostByte881741; read the full conversation before replying.
AHKDragon

—I should be able to help with your AHK needs, unless it has something to do with anything GUI or complex. I hold no guarantees that I WILL be able to help, though.—

joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Nov 02 2019 08:38 PM
  • Joined: 20 May 2012

joedf, your post is late and misguided. The OP's "problem" applies equally to Windows Vista, Windows 7 and Windows 8.


lol, no i was talking about the removal of the start menu! Posted Image
Posted Image
Why ahkscript.org? - autohotkey.com is outdated