Can't get Send to work...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Can't get Send to work...

29 Mar 2014, 19:00

I'm new to AHK but did a lot of programming before I retired.

I'm visually impaired and find I have to swap between High Contrast Theme and a standard theme using NegativeScreen. The key grab for swapping to/from High Contrast mode is <shift><alt>PrintScrn. I wanted to map a hotkey to something closer to NegativeScreen hot keys (and something easier to grab). So the Windows key + Alt + b.

I can't seem to get Send or SendInput to work. Any ideas?

The script -

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; switch to/from high contrast easier
#!b::
;Send {Shift down}
;Send {Alt down}
SendInput !+{PrintScreen}
;Send {Alt up}
;Send {Shift up}
MsgBox "Sent it rev5"
return
Thanks!

Keith
Guest

Re: Can't get Send to work...

30 Mar 2014, 04:53

I'm not sure but that might be one of those Windows shortcuts that you can't send just like ctrl-alt-del, so you might be better off trying to "Run" your theme, [c]Run, c:\Windows\Resources\Ease of Access Themes\hc1.theme[/c] that should switch the theme and open the theme editor - just add a winwait and winclose after the Run command to automatically close the theme editor and you're done (you may need to add a toggle state to keep track of what theme to run).
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

30 Mar 2014, 20:03

Thanks for that response.

Having the settings dialog raised and dismissed is more of an interruption than grabbing the shift+alt+printscrn keys.

But, on further investigation, the left shift and left alt must be pressed for Win8.1 to swap in/out of high contrast mode. So that sent me on another dozen attempts to have AHK send out that key sequence. Still no luck though.

Basic question -
1) What does SendInput {LShift}{LAlt}{PrintScreen} do? Send 3 discrete keys? In Sequence?
2) What does SendInput <!<+{PrintScreen} do? Are the < modifiers bound to only the next key?
3) What does SendInput {LShift down}{LAlt down}{PrintScreen}{LAlt up}{LShift up} do?

Yes, I read the help pages...

Wish I had a better way to debug this...

Thanks!

Keith
teleric_tentacle
Posts: 7
Joined: 30 Mar 2014, 20:57

Re: Can't get Send to work...

03 Apr 2014, 11:08

*edit* What I originally posted seems to be half-wrong. Manually pressing win+alt+shift+printscreen won't launch HC mode, but no amount of input blocking or delays that I tried would work. I did some testing and can send !+{Tab} just fine, but not !+{PrintScreen}. Some poking around seems to suggest that guest may be right, though I didn't find anything definitive.
Spoiler
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

03 Apr 2014, 12:19

Thanks for the follow-up. I found a few articles on the web that make it seem like it is possible if one goes deep enough down the call stack. But .net SendKeys lists PRINT SCREEN as reserved for future use. (http://word.mvps.org/faqs/macrosvba/PrtSc.htm; http://delphi.about.com/od/adptips2004/ ... 0604_4.htm, etc.)

So I thought about trying to write a c or c++ app to do the low level call, and then running the app via an AHK hotkey.

But, this is all a bit tangential to what I really want to do with AHK, which is automated screen scraping into Excel. (Or at least, that is my highest priority...)

I've moved on to reading Dunning's books, watching AHKTuts videos, and playing with script to get a fuller understanding of what is possible and how it all works. Impressive tool!

Still, if someone figures this out, I'd love a solution! :-)

Cheers

Keith
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Can't get Send to work...

03 Apr 2014, 13:09

kmcintyre wrote:Thanks for that response.
But, on further investigation, the left shift and left alt must be pressed for Win8.1 to swap in/out of high contrast mode. So that sent me on another dozen attempts to have AHK send out that key sequence. Still no luck though.
From what I understand Windows blocks the simulation of certain Windows hotkeys unless the application trying to do it is an assistive technology application which has UIAccess privileges.

Giving the application the needed UIAccess privileges requires an application with the proper security certificates which could probably be done but is complicated and would need to do a bunch of stuff in Windows to get your application to run with the correct access.

Long story short, what you want to do sounds simple but because of Windows security it is quite complicated to do.

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
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

03 Apr 2014, 17:09

Thanks for all the info. Guess I'll need to keep reaching for the LShift+LAlt+PrintScrn combo! :-)

Cheers

Keith
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Can't get Send to work...

03 Apr 2014, 18:21

FanaticGuru wrote:Giving the application the needed UIAccess privileges requires an application with the proper security certificates which could probably be done but is complicated and would need to do a bunch of stuff in Windows to get your application to run with the correct access.
That's what EnableUIAccess.ahk is for.
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

03 Apr 2014, 18:44

So it sounds like I would create an ahk script to do the LShift+LAlt+PrintScrn (call it HCSwitch.ahk for now), compile it, move it to the Program Files directory, run the EnableUIAccess.ahk script to tag my exe for EnableUI. (Excuse me if I got it a little wrong...)

Should I then be able to "Run HCSwitch.exe" from another ahk script?

(I know, try it and find out! lol)

Thanks for the lead...

Keith
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Can't get Send to work...

03 Apr 2014, 20:49

The second line of the post I linked to is:
Modifies AutoHotkey.exe to allow scripts to do the following even while UAC is enabled
You can probably use it on a compiled script, but if you just apply it to AutoHotkey.exe (which should already be in Program Files), it will work for all uncompiled scripts.
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

04 Apr 2014, 01:06

Thanks for that clarification. I'll try it tomorrow!

Keith
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

04 Apr 2014, 12:07

A couple issues -

When I installed AHK (Unicode 64bit) I installed it to my d:\Program Files. My Win8.1 boot disk is c:\. So I'm considering uninstalling and reinstalling to the default path. Do I really need to in order for EnableUIAccess to work?

I downloaded and unzipped the EnableUIAccess.ahk script and associated lib directory. When I run the script (from the Downloads library) I get an error re. line 24, #include <Cert>, library not found. So should I copy the EnableUIAccess script and lib directory to my Program Files directory? Does it have to be in c:\Program Files\... too?

Also, since AHK doesn't have a GUI of its own (ttbomk), how does one know the version one is running? I stumbled on the info when uninstalling AHK via Control Panel. (I cancelled the uninstall until I hear back from this post...) Is there a better way? Does AHK autoupdate? Does one need to periodically uninstall before installing undated versions. (Off topic...)

Thanks for all the help.

Keith
kmcintyre
Posts: 20
Joined: 29 Mar 2014, 18:35

Re: Can't get Send to work...

05 Apr 2014, 22:05

I had some time tonight so I uninstalled AHK, reinstalled to the default location (c:\Program Files\AutoHotKey). I then downloaded EnableUIAccess.zip, extracted all files, ran EnableUIAccept, followed the instuctions and modified AutoHotKey.exe in place. I also added the context menu for Run with UI Access.

Next I ran my HighContrast.ahk via the Run with UI Access context menu.

But I still had no luck getting the script to send out a LShift+LAlt+PrintScrn.

I'm going to wait a day or two to see if anyone posts any new insights that I can chase down. Then I'll reinstall AHK so I can compile .exe files that can be distributed.

Thanks for all your seasoned insights.

Cheers

Keith

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 316 guests