Save up to 50% off any of our desktop apps in our 2021 spring sale, including
DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!




<< DiscussionsReply

Triggers to manage Outlook "message" windows positions

2 discussion posts
I'm trying to set up triggers for "message" windows in Outlook, meaning when I open a specific message as a new window or reply/create a message. Due to the way Outlook re-uses windows handles, I'm struggling to get the behavior I want.

Ideally I would like to set it up (in concept) as a "Window Created" trigger to then set the size and location, therefore when a new message window appears it will put it in my specified location but if I choose to move it somewhere else that particular window will stay where I put it. Opening another message would then put the new message in the specified trigger location, but leave the previously opened message where I had moved it. I will often open 2 or 3 different message windows and move them around to see contents all at the same time.

I've reviewed these other discussions that have a lot of great info in them:
Focus Event Trigger not just top level
Open Outlook on specific monitor
How to force app child windows (modal/modeless) to open in the same display

It seems that setting my trigger to "Window Focused" and Frequency "Always" manages to overcome the issue with Outlook re-using window handles, however if I move a message to a different location manually, then flip back and forth between windows, that message snaps back to the trigger location. If I switch the Frequency to any of the other settings (Process ID, Process Name, or Once-Per-Window) it rarely ever activates the trigger since, I assume, the same handles are being re-used over and over.

Has anyone found a decent work-around to this issue?
May 8, 2020  • #1
Keith Lammers (BFS)'s profile on
I had a thought on this last night, that this could be done with a Scripted Function that polls for new Outlook message windows.

Window Created triggers don't work because they're not actually newly created windows, but we can tell if they're visible windows or not. I've written a script that polls every second for visible Outlook message windows, and moves them if it sees them. It keeps a list of visible windows that it's already seen and moved, so that they won't get re-moved if you have dragged them somewhere else. If a window is closed, on the next script run it will remove it from the list of already seen windows. That way, if you close a window, it gets removed from the list, then the next one you open gets seen as a "new" window.

Could you try this out?

  • On the DisplayFusion Settings > Triggers tab, disable any Outlook triggers
  • On the DisplayFusion Settings > Functions tab, click the "Download Scripted" button
  • Double-click the script named "Move New Outlook Message Windows to Monitor 2"
  • Assign it a hotkey (this is just for testing)
  • Click OK to save the script
  • Click Apply on the main Settings window
  • Run the script using the hotkey
  • Try opening some new Outlook message windows
  • If it works, you can create a new Trigger rule, using the "DisplayFusion Starts" Trigger Event to run that Scripted Function on startup
  • The script runs in an endless loop, so if you ever need to stop it, you can right-click its icon in the system tray (it looks like a DF logo with a green "play button" icon on it)

Note, this moves to monitor 2 and maximizes the window. If you want to specify a size and location instead, change line 40 from:
BFS.Window.MoveToMonitorMaximized(targetMonitor, window);

BFS.Window.SetSizeAndLocation(window, 200, 200, 800, 600);

Hopefully this works for you!
May 12, 2020  • #2
2 discussion posts
Ooo, that's awesome, seems to be working quite well for my initial testing. This gives me a framework to tweak it for a lot of things as well, appreciate this response very much! Not only did you solve my problem, but you provided a very well laid out script and pointed out options to modify myself. Since I have a C# background, this just opened a whole new world for me, now I'm sure to get myself in trouble...

Also, special kudos for the detailed comments in the script. As a fellow developer, having well-commented code is icing on the cake!
May 16, 2020  • #3
Keith Lammers (BFS)'s profile on
Glad to hear it, thanks for the kind words!
May 20, 2020  • #4
Was this helpful?    
<< DiscussionsReply