How to use AutoHotkey to fix outlook keyboard shortcuts?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by reverberation » 09 Jun 2021, 19:50

There are 2 variations of the Outlook Reminder - one that comes with "Join Online" and one that doesn't. Rightfully, pressing "D" should dismiss either notification, but it only works in the first and not the second. Any idea what I can do to fix this annoyance?
image.png
image.png (21.66 KiB) Viewed 1128 times
image.png
image.png (44.04 KiB) Viewed 1128 times

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 10 Jun 2021, 02:00

Create a hotkey for the D key that is active only when an Outlook reminder popup is the active window:

Code: Select all

SetTitleMatchMode, 2

#IfWinActive, Reminder(s) ahk_class #32770 ahk_exe OUTLOOK.EXE
d::WinClose, Reminder(s) ahk_class #32770 ahk_exe OUTLOOK.EXE

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 15 Jun 2021, 01:33

interested to know too. d closes the window but doesn't dismiss the event and a doesn't work for Dismiss All and J doesn't work for Join Teams meeting (depending on which screen is activated). any idea how to resolve it?


User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 20 Jun 2021, 07:49

I didn’t answer this question yet because I use Outlook but not Teams, so I was seeing if someone who does might reply.

Instead of using WinClose, you should be able to have it click the desired button, which should dismiss or join as applicable. I haven’t tried ControlClick, but that would be best — if it works on these windows. Apparently sending keyboard shortcuts wouldn’t work. Worst case, you could Click the buttons by known location or by found image location.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 20 Jun 2021, 07:55

boiler wrote:
20 Jun 2021, 07:49
I didn’t answer this question yet because I use Outlook but not Teams, so I was seeing if someone who does might reply.

Instead of using WinClose, you should be able to have it click the desired button, which should dismiss or join as applicable. I haven’t tried ControlClick, but that would be best — if it works on these windows. Apparently sending keyboard shortcuts wouldn’t work. Worst case, you could Click the buttons by known location or by found image location.
May I check - is it possible to specify coordinates relative to the prompt window only, and is this independent of what resolution OR font scaling the computer uses?

I tried controlclick, but think it doesn't detect the underlined A in All :

Image
Attachments
image.png
image.png (19.61 KiB) Viewed 1045 times

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 20 Jun 2021, 08:03

milkygirl90 wrote: May I check - is it possible to specify coordinates relative to the prompt window only, and is this independent of what resolution OR font scaling the computer uses?
Yes, you should only specify coordinates relative to the prompt window, not based on screen coordinates. It would be independent of screen resolution, but I wouldn’t be sure about whether it would work across different Windows scaling settings without testing it. If it does differ by scaling factor, you should be able to scale the coordinates by the ratio of A_ScreenDPI/96.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 20 Jun 2021, 08:06

milkygirl90 wrote: I tried controlclick, but think it doesn't detect the underlined A in All
Try using the ControlNN if available (check using the Window Spy tool) instead of the button text.
Last edited by boiler on 20 Jun 2021, 08:07, edited 1 time in total.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 20 Jun 2021, 08:06

boiler wrote:
20 Jun 2021, 08:03
milkygirl90 wrote: May I check - is it possible to specify coordinates relative to the prompt window only, and is this independent of what resolution OR font scaling the computer uses?
Yes, you should only specify coordinates relative to the prompt window, not based on screen coordinates. It would be independent of screen resolution, but I wouldn’t be sure about whether it would work across different Windows scaling settings without testing it. If it does differ by scaling factor, you should be able to scale the coordinates by the ratio of A_ScreenDPI/96.
Do I just use the Click command with the R modifier for Relative?

Also, what's the difference between Client vs Window position?

Code: Select all

Screen:	1029, 538 (less often used)
Window:	1038, 547 (default)
Client:	1029, 538 (recommended)
Color:	F0F0F0 (Red=F0 Green=F0 Blue=F0)

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 20 Jun 2021, 08:10

boiler wrote:
20 Jun 2021, 08:06
milkygirl90 wrote: I tried controlclick, but think it doesn't detect the underlined A in All
Try using the ControlNN if available (check using the Window Spy tool) instead of the button text.
It's "Buton 5" in WinSpy, but do I still use the ControlClick command? Sorry as I never used ControlNN before..

Image

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 20 Jun 2021, 08:13

milkygirl90 wrote: Do I just use the Click command with the R modifier for Relative?
No, that’s relative to the mouse pointer’s current position which has no correlation to the window position. It means you need to set CoordMode appropriately: CoordMode, Mouse, Relative or Window or Client. If you use Client, then get the coordinates as shown for Client in the Spy tool.

milkygirl90 wrote: Also, what's the difference between Client vs Window position?
Window position is relative to the upper-left corner of the overall window. The client area is the area inside any caption (title bar) and border the window has.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 20 Jun 2021, 08:17

milkygirl90 wrote:
20 Jun 2021, 08:10
It's "Buton 5" in WinSpy, but do I still use the ControlClick command? Sorry as I never used ControlNN before..
It’s actually Button5 with two t’s and no space. It must be exact. It would be like this:

Code: Select all

ControlClick, Button5, Reminder(s) ahk_class #32770 ahk_exe OUTLOOK.EXE

Btw, I mistakenly said ControlNN instead of ClassNN.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 20 Jun 2021, 08:19

boiler wrote:
20 Jun 2021, 08:13
milkygirl90 wrote: Do I just use the Click command with the R modifier for Relative?
No, that’s relative to the mouse pointer’s current position which has no correlation to the window position. It means you need to set CoordMode appropriately: CoordMode, Mouse, Relative or Window or Client. If you use Client, then get the coordinates as shown for Client in the Spy tool.

milkygirl90 wrote: Also, what's the difference between Client vs Window position?
Window position is relative to the upper-left corner of the overall window. The client area is the area inside any caption (title bar) and border the window has.
pardon my ignorance.. I just tested it and I have no idea why the cursor misses the exact coordinates and ends up higher than I'd like:

Code: Select all

CoordMode, Mouse, Client
a::Click, 530,371
530,371 should land squarely on the Dismiss All button but it landed above instead. I know I can just adjust the Y coordinates, but I'm just triyng to understand why the WSpy is unreliable.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 20 Jun 2021, 08:29

Was the Reminder(s) window the active window when you pressed the hotkey? Using Relative, Window, or Client positioning is relative to the window that is active at the time that you use Click. Try this:

Code: Select all

CoordMode, Mouse, Client

a::
	WinActivate, Reminder(s) ahk_class #32770 ahk_exe OUTLOOK.EXE
	Click, 530,371
return	

It’s better to use ControlClick if that works.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 21 Jun 2021, 00:14

boiler wrote:
20 Jun 2021, 08:29
Was the Reminder(s) window the active window when you pressed the hotkey? Using Relative, Window, or Client positioning is relative to the window that is active at the time that you use Click. Try this:

Code: Select all

CoordMode, Mouse, Client

a::
	WinActivate, Reminder(s) ahk_class #32770 ahk_exe OUTLOOK.EXE
	Click, 530,371
return	

It’s better to use ControlClick if that works.
ControlClick only highlights the button, and I still have to send a {Enter} to hit the button.. not sure why.

For the client position, yes the window was active and I used the exact coordinates, but the mouse cursor still missed the button.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 21 Jun 2021, 20:06

Then you should be able to follow the ControlClick with ControlSend to send {Enter} and not have to click by position.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by milkygirl90 » 21 Jun 2021, 20:51

boiler wrote:
21 Jun 2021, 20:06
Then you should be able to follow the ControlClick with ControlSend to send {Enter} and not have to click by position.
yes it works.. just wanted to understand why controlClick doesn't just click and instead requires another step..

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: How to use AutoHotkey to fix outlook keyboard shortcuts?

Post by boiler » 21 Jun 2021, 22:05

It’s just a quirk of that particular control for that window. That’s the nature of this type of automation. It often requires some trial and error. Programs aren’t typically developed with the idea that they should behave normally when a script simulates the actions of a human user, and the various techniques are not the same as human clicking a mouse or whatever, so there is no guarantee that they will produce the same result.

Sometimes a ControlClick alone will work, sometimes the control responds if you focus it before clicking (perhaps that would also be the case here), sometimes the window must be active for anything to work, sometimes the mouse pointer actually needs to be over the target window for any type of click to work, etc.

Post Reply

Return to “Ask for Help (v1)”