Mark emails as read in Outlook

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
usser
Posts: 145
Joined: 22 Oct 2014, 13:03

Mark emails as read in Outlook

26 Mar 2024, 17:09

Hello

I am trying to mark emails as read in Outlook Desktop when I right click on an email in the email list.

I tried:

Code: Select all

#If WinActive("ahk_exe outlook.exe")
RButton::Send {LButton down}{LButton up}{LControl down}{q}{LControl up}
Return
and

Code: Select all

#If WinActive("ahk_exe outlook.exe")
RButton::
KeyWait LButton
Send ^q
Return
None seems to work. Any idea? Thanks!


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

[Mod action: Moved topic to the v1 section since this is v1 code. The main section is for v2. Please post in the correct section going forward.]
User avatar
mikeyww
Posts: 26977
Joined: 09 Sep 2014, 18:38

Re: Mark emails as read in Outlook

26 Mar 2024, 17:39

An idea is below.

Code: Select all

#Requires AutoHotkey v1.1.33.11

#If WinActive("ahk_exe OUTLOOK.exe") && mouseOver("OutlookGrid1")
~RButton Up::
Sleep 200
Send k ; Mark as read
SoundBeep 1500
Return
#If

mouseOver(ctl) {
 MouseGetPos,,,, overCtl
 Return overCtl = ctl
}
ShatterCoder
Posts: 77
Joined: 06 Oct 2016, 15:57

Re: Mark emails as read in Outlook

27 Mar 2024, 09:31

Mikey's method is probably the simplest. If for any reason you find that sending k is inconsistent you can use the COM method for setting the email as unread (Note this method requires that the item is selected/'clicked on' in the tree view)

Code: Select all

#If WinActive("ahk_exe outlook.exe")
RButton::
Send {LButton down}{LButton up}
ol := ComObjActive("Outlook.Application")
ol.ActiveExplorer.Selection.Item(1).Unread := 0
return
In my limited testing this seemed to work well. Though you may want to incorporate Mikey's mouseOver() function and secondary verification to avoid locking out your right click utility for the rest of the time you are using outlook.
User avatar
mikeyww
Posts: 26977
Joined: 09 Sep 2014, 18:38

Re: Mark emails as read in Outlook

27 Mar 2024, 10:08

I like COM, too, though there might be issues if attempting it with new Outlook. In any case, it warrants testing.
usser
Posts: 145
Joined: 22 Oct 2014, 13:03

Re: Mark emails as read in Outlook

27 Mar 2024, 10:52

Thank you but this was intended to be for AHK v2, can you provide some v2 code to test?
Thanks!
User avatar
mikeyww
Posts: 26977
Joined: 09 Sep 2014, 18:38

Re: Mark emails as read in Outlook

27 Mar 2024, 11:04

This is the v1 forum.

Code: Select all

#Requires AutoHotkey v2.0

#HotIf WinActive('ahk_exe OUTLOOK.exe') && mouseOver('OutlookGrid1')
~RButton Up:: {
 Sleep 200
 Send 'k' ; Mark as read
 SoundBeep 1500
}
#HotIf

mouseOver(ctl) {
 MouseGetPos ,,, &overCtl
 Return overCtl = ctl
}
gregster
Posts: 9035
Joined: 30 Sep 2013, 06:48

Re: Mark emails as read in Outlook

27 Mar 2024, 14:54

usser wrote:
27 Mar 2024, 10:52
Thank you but this was intended to be for AHK v2, can you provide some v2 code to test?
When you post obvious v1 code in your original post, but actually want v2 code, it would make sense to mention this from the start.
Otherwise, your topic will be (and has been) moved to the v1 help subforum, assuming that you posted in the wrong place (like stated in the moderator's comments in the OP).
usser
Posts: 145
Joined: 22 Oct 2014, 13:03

Re: Mark emails as read in Outlook

28 Mar 2024, 08:51

gregster wrote:
27 Mar 2024, 14:54
usser wrote:
27 Mar 2024, 10:52
Thank you but this was intended to be for AHK v2, can you provide some v2 code to test?
When you post obvious v1 code in your original post, but actually want v2 code, it would make sense to mention this from the start.
Otherwise, your topic will be (and has been) moved to the v1 help subforum, assuming that you posted in the wrong place (like stated in the moderator's comments in the OP).
OK but most of the times I would need both codes :)
User avatar
mikeyww
Posts: 26977
Joined: 09 Sep 2014, 18:38

Re: Mark emails as read in Outlook

28 Mar 2024, 08:56

You can switch to v2 to simplify your life.
usser
Posts: 145
Joined: 22 Oct 2014, 13:03

Re: Mark emails as read in Outlook

28 Mar 2024, 09:08

mikeyww wrote:
26 Mar 2024, 17:39
An idea is below.

Code: Select all

#Requires AutoHotkey v1.1.33.11

#If WinActive("ahk_exe OUTLOOK.exe") && mouseOver("OutlookGrid1")
~RButton Up::
Sleep 200
Send k ; Mark as read
SoundBeep 1500
Return
#If

mouseOver(ctl) {
 MouseGetPos,,,, overCtl
 Return overCtl = ctl
}
Unfortunately, this does not seem to work with AHK v1.1.35.
I have set up Win11 to RButton with Two Finger tap. So when I Two Finger Tap on Outlook message list, the Right Click Menu appears.
Is there a way to detect this specific context menu?
User avatar
mikeyww
Posts: 26977
Joined: 09 Sep 2014, 18:38

Re: Mark emails as read in Outlook

28 Mar 2024, 09:21

This is not set up for a touchpad, so I would try with the mouse first. If you run Window Spy, you can see what ClassNN corresponds to your message list. I would start by removing the #If directive completely, so that you can first test the hotkey itself.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww and 26 guests