Script for Outlook Reminder seems to have issues Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
boban70
Posts: 3
Joined: 20 Apr 2022, 07:15

Script for Outlook Reminder seems to have issues

20 Apr 2022, 07:26

While searching for a solution to the outlook notification behind other windows issue (an issue MS has allowed to plague a decades worth of versions), https://support.microsoft.com/en-us/office/set-or-remove-reminders-7a992377-ca93-4ddd-a711-851ef3597925#ID0EBD=Newer_versions, I found reference to an AHK script to help resolve it, https://superuser.com/questions/1443152/how-to-make-outlook-calendar-reminders-stay-on-top-in-windows, the post by Jeff Allen.

In my organization, users are not admins, and therefore can't install things. We can use "portable" apps with no support and the practice is long known. Using guidance here, this seems to be possible to operate this product without admin rights within the user env, https://www.thenickmay.com/how-to-install-autohotkey-even-without-administrator-access/#:~:text=Open%20your%20Documents%20folder%20(or,should%20open%20your%20startup%20folder. I have extracted the AHK zip file contents to a location I can save and modify files. I intentionally ran the organization's AV product against the directory, the files were not flagged or removed by their malware and PUP policies (AFAIK).

My batch file looks like the below, with the quotes around the file executable (with directory) and the script file (with directory).

"C:\Users\removed\AppData\Local\Local Items\AutoHotkey\AutoHotkeyU64.exe" "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\Monitor Outlook Reminder v2.ahk

If I intentionally misspell the name of .ahk file referenced by the above batch file, then AHK does error out and let me know the file can't be found.

The AHK script file looks like this;

Code: Select all

;Monitor Outlook Reminder, restore and pin always on Top every ~4 min.
OutlookRemndrs_Init:
SetTimer, OutlookRemndrs_OnTop, 380000
OutlookRemndrs_OnTop:
   SetTitleMatchMode 2
   WinSet, AlwaysOnTop, on, 1 Reminder(s)
   WinSet, AlwaysOnTop, on, 2 Reminder(s)
   WinSet, AlwaysOnTop, on, 3 Reminder(s)
   WinSet, AlwaysOnTop, on, 4 Reminder(s)
   WinSet, AlwaysOnTop, on, 5 Reminder(s)
   WinSet, AlwaysOnTop, on, 6 Reminder(s)
   WinSet, AlwaysOnTop, on, 7 Reminder(s)
   WinSet, AlwaysOnTop, on, 8 Reminder(s)
   WinSet, AlwaysOnTop, on, 9 Reminder(s)
   WinRestore, 1 Reminder(s)
   WinRestore, 2 Reminder(s)
   WinRestore, 3 Reminder(s)
   WinRestore, 4 Reminder(s)
   WinRestore, 5 Reminder(s)
   WinRestore, 6 Reminder(s)
   WinRestore, 7 Reminder(s)
   WinRestore, 8 Reminder(s)
   WinRestore, 9 Reminder(s)
   return
I'm not a scripter/programmer, I couldn't tell you if the script file is even close to proper.

It isn't working for me, the reminder never comes to the front of outlook or other windows, it is always behind other windows. I'm not sure what I'm missing. Can someone help? Thanks.


[Mod edit: Added [code][/code] tags.]
User avatar
mikeyww
Posts: 27198
Joined: 09 Sep 2014, 18:38

Re: Script for Outlook Reminder seems to have issues  Topic is solved

20 Apr 2022, 08:05

I had trouble getting WinSet to work with that window. The script below has a slightly different effect-- as on-top windows can be active or inactive-- but it might serve your need. If needed, this can be done with a timer instead of a loop. You would simply WinActivate the window at whatever frequency you need. WinSet, Top might also have some benefits, but I did not test it.

Code: Select all

#SingleInstance Force
SetTitleMatchMode, 2
Loop {
 WinWait, Reminder ahk_exe OUTLOOK.exe
 WinActivate
 SoundBeep, 1500
 WinWaitNotActive ; Alternative is WinWaitClose
}
boban70
Posts: 3
Joined: 20 Apr 2022, 07:15

Re: Script for Outlook Reminder seems to have issues

04 May 2022, 06:39

Mike, thanks, that definitely worked to keep the outlook meeting notice window in the foreground and force my acknowledgement.

I'm wondering if you've got an idea on this.... The batch file launches a cmd window that calls the ahk exe combined with the script. Is there a way to have it just run without the cmd window? I use cmd windows for my job often and have to close many in bulk sometimes, I've close the ahk cmd window by accident. Do you happen to also know of a way to have this script run without a cmd window or just in the background not easily disturbed?

Thanks.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Script for Outlook Reminder seems to have issues

04 May 2022, 07:38

Code: Select all

Run %comspec%		/k dir c:				; kiosk mode. will keep the window open.
Run %comspec%		/c dir c:				; close mode. guess what?!
Run %comspec%		/c dir c: | clip,, Hide	; close mode. executing hidden style. copy result to clipboard
MsgBox % clipboard							; showing the outcome of the previous cmd session
HTH
RussF
Posts: 1296
Joined: 05 Aug 2021, 06:36

Re: Script for Outlook Reminder seems to have issues

04 May 2022, 07:57

@BoBo, I don't think you read @boban70's post carefully. AHK must be run from a DOS batch file because their company won't allow installations.

Use Start to run your script, i.e. your batch file should look something like this:

Code: Select all

@echo off
Start "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\AutoHotkeyU64.exe" "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\Monitor Outlook Reminder v2.ahk"
The command window will disappear as soon as your script is started.
Russ
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Script for Outlook Reminder seems to have issues

04 May 2022, 08:26

@RussF - Oops. Was already irritated about that Batchfile-conversation without seeing one :silent: :shh:
For running an AHK-script no "installation" is needed, AFAIK. Correct me if I'm wrong. The (main) issue I'd guess is that there's no ahk-file extension assignment to the AHK interpreter, a thing that is hard to accomplish if restricted by whatever company policy. OTOH, can't see why someone should allow executing 'dangerous' AHK stuff using batch files :crazy: in the first place but isn't able/willing to set up that missing file extension registry setting. :wtf: :think:

Workaround. Create a Desktop shortcut as a command-line dummy that will run AutoHotkey.exe + whateverScript.ahk with a single click/Hotkey.
RussF
Posts: 1296
Joined: 05 Aug 2021, 06:36

Re: Script for Outlook Reminder seems to have issues

04 May 2022, 08:40

BoBo wrote: Workaround. Create a Desktop shortcut as a command-line dummy that will run AutoHotkey.exe + whateverScript.ahk with a single click/Hotkey.
Yes, you could certainly create a shortcut for a single script, however, if the user has multiple scripts they start up and run every day, putting them all into a BAT file makes it easier than launching each shortcut. Even if you wanted the ability to occasionally run one or two without the others, you could set up a separate BAT file for each of them, and then create a "master" BAT file that uses Call to execute all the individual BATs in one go. Many possibilities/permutations.

Russ
boban70
Posts: 3
Joined: 20 Apr 2022, 07:15

Re: Script for Outlook Reminder seems to have issues

05 May 2022, 07:07

RussF wrote:
04 May 2022, 07:57
@BoBo, I don't think you read @boban70's post carefully. AHK must be run from a DOS batch file because their company won't allow installations.

Use Start to run your script, i.e. your batch file should look something like this:

Code: Select all

@echo off
Start "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\AutoHotkeyU64.exe" "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\Monitor Outlook Reminder v2.ahk"
The command window will disappear as soon as your script is started.
Russ
Thanks.

I've prepended the word start and have the application calling the script exactly as you have above.

However, with the "start" in their, it loads the script in notepad++ editor, notepad yet another program my employer will not install because they've called it a virus. N++ is not installed, rather it is in an executable location, much lik AHK.
RussF
Posts: 1296
Joined: 05 Aug 2021, 06:36

Re: Script for Outlook Reminder seems to have issues

05 May 2022, 08:38

I honestly don't understand what's going on. I recreated (mostly) your path environment and created two batch files:

Code: Select all

@echo off
"C:\Users\removed\AppData\Local\Local Items\AutoHotkey\AutoHotkey.exe" "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\Test Script.ahk"
and:

Code: Select all

@echo off
Start "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\AutoHotkey.exe" "C:\Users\removed\AppData\Local\Local Items\AutoHotkey\Test Script.ahk"
The first one loads the test script, but keeps the Cmd window open until the script exits. The second one loads the script, and the Cmd window immediately disappears, leaving the script running. I have absolutely no idea why NP++ would load (especially if it is not installed and has no file extension associations.)

Are you SURE you are saving and running the correct BAT file? There is NO WAY NP++ would load with the above commands.

Russ

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: daiweisc and 214 guests