Jump to content
Sign in to follow this  
John Skilleter

Stuck trying to control Outlook window positions

Recommended Posts

John Skilleter

I'm trying to write a script to control the position of Outlook (not Outlook Express) window locations automatically and I'm getting somewhat stuck.

Outlook doesn't have fixed window titles, so I'm using WinTitleMatchMode set to 4 and matching against the window class name as, according to the AutoIT Window Info app, all Outlook windows have a classname of rctrl_renwnd32.

The problem is that I can't get the script to notice when an Outlook window becomes active. My simple-minded test script is as follows:

AutoItSetOption("WinTitleMatchMode", 4)

while 1

$Active = WinWaitActive("classname=rctrl_renwnd32")

if $Active then

MsgBox(0, "Outlook!", "Outlook window " & "'" & WinGetTitle("active") & "'")

endif

wend

and no matter which Outlook windows I activate, I never see the msgbox.

Can anyone show me where I'm being silly, or suggest a way of doing this that will actually work.

Share this post


Link to post
Share on other sites
gamerman2360

Works for me, must be something with the classname.

AutoItSetOption("WinTitleMatchMode", 4)

while 1
    $Active = WinWaitActive("classname=MozillaUIWindowClass")
    
    if $Active then
        MsgBox(0, "Outlook!", "Outlook window " & "'" & WinGetTitle("active") & "'")
    endif
wend
PS: Use [autoit] or [code ](no spaces) tags to represent code.

Share this post


Link to post
Share on other sites
John Skilleter

Yes, thanks, it works fine for other applications' windows, but it doesn't seem to want to work with Outlook!

I've double-checked the window classname using Winspector (http://www.windows-spy.com/) and it is correct, so I'm a bit baffled.

If I can't use the class name and I can't use the window title, is there any other way of determining whether a window belonging to a particular application has become active?

Works for me, must be something with the classname.

AutoItSetOption("WinTitleMatchMode", 4)

while 1
    $Active = WinWaitActive("classname=MozillaUIWindowClass")
    
    if $Active then
        MsgBox(0, "Outlook!", "Outlook window " & "'" & WinGetTitle("active") & "'")
    endif
wend
PS: Use [autoit] or [code ](no spaces) tags to represent code.

Share this post


Link to post
Share on other sites
John Skilleter

I've fixed the problem by checking to see which process owns the window, which seems a bit of a sledgehammer approach, but works:

while 1
   $Active = WinWaitActive("")
    
   if $Active then      
      $WinProcess = WinGetProcess("")       
      $Processes = ProcessList("Outlook.exe")
        
      for $i = 1 to $Processes[0][0]
         if $Processes[$i][1] == $WinProcess then
            MsgBox(0, "Message!", "Outlook window, PID=" & $WinProcess)
         endif
      next
   endif
wend

Yes, thanks, it works fine for other applications' windows, but it doesn't seem to want to work with Outlook!

I've double-checked the window classname using Winspector (http://www.windows-spy.com/) and it is correct, so I'm a bit baffled.

If I can't use the class name and I can't use the window title, is there any other way of determining whether a window belonging to a particular application has become active?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.