Issues automatically pulling window to front when it apppears

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
098098
Posts: 2
Joined: 01 Jun 2020, 14:45

Issues automatically pulling window to front when it apppears

01 Jun 2020, 15:00

Dear AHK Community,

I'm doing some work for an IT customer, and they have a Windows remote app (Epicor P21) that creates a new Outlook message with pre-filled info. The issue is that the new message window appears beneath the main remote app window. I'm desperately trying to build a script to pull this email window to the front, and this is what I've gotten. When I test with manually created new message windows on my own computer, it works intermittently, but it never pulls the desired window forward on the customer computer. Could someone do a sanity check on what I've written here, or help me understand where I've got things wrong? Thanks in advance!

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.

;Automatically run EmailTemplateToFront every 250ms
#Persistent
#SingleInstance force
Critical
SetTimer, EmailTemplateToFront, 250
Return

;Automatically bring new message Outlook message windows to the front so clicking in the task bar is not necessary
EmailTemplateToFront:
DetectHiddenWindows, On
SetTitleMatchMode RegEx
SetTitleMatchMode, slow
WinSet, AlwaysOnTop, On, Message \(HTML\)
return
Albireo
Posts: 1776
Joined: 16 Oct 2013, 13:53

Re: Issues automatically pulling window to front when it apppears

01 Jun 2020, 16:19

Welcome to AHK!
Have you tried to run your AHK-script "as administrrator"?
mshafer1
Posts: 54
Joined: 16 Jul 2017, 14:49
Contact:

Re: Issues automatically pulling window to front when it apppears

01 Jun 2020, 20:16

(just a couple of thoughts/immediate reaction)

this part could/should be at the top of the script rather than in the loop as it only needs to run once
(maybe, maybe improve loop speed?? not likely, but cleaner code anyways)

Code: Select all

DetectHiddenWindows, On
SetTitleMatchMode RegEx
SetTitleMatchMode, slow
Is the message gauranteed to always be "Message (Html)"? if not, would using contains mode (setTitleMatchMode, 2) work better?
Similarly, when I'm trying to bring a window to the front, I use WinActivate - like in the ActivateOrOpen method on ahkgen.com: https://preview.ahkgen.com/?indexes=0&c ... vateOrOpen
098098
Posts: 2
Joined: 01 Jun 2020, 14:45

Re: Issues automatically pulling window to front when it apppears

02 Jun 2020, 09:47

Have you tried to run your AHK-script "as administrrator"?
I have not tried running as administrator, but the fact that the script works intermittently makes me think that's not the issue. It's also not really viable since the user I'm working with should not have those permissions. Thanks though!
if not, would using contains mode (setTitleMatchMode, 2) work better?
How is this mode different from RegEx mode? is it just a simpler matching mode?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CodeKiller and 202 guests