Jump to content

Need Help with WinActivate


Recommended Posts

hi,

i am writing on a script that should change some outlook express settings. my problem is that i am not able to activate outlook express if "Outlook Express" is not the begin of the window-title. If the inbox is activated then the window-title is something like "Inbox - Outlook Express" - and this is the point where i get in trouble with using winactivate.

This is my code:

Opt("WinTitleMatchMode", 2)

Opt("WinTextMatchMode", 2)

$title = WinGetTitle("Outlook Express")

WinActivate($title)

What am I doing wrong?

Thanks in advance :whistle:

Link to comment
Share on other sites

You have already set the Opt() for substring, so just use the substring.

Opt("WinTitleMatchMode", 2) 
Opt("WinTextMatchMode", 2)
WinWait("Outlook Express"); wait for window
$title = WinGetTitle("Outlook Express"); get full title
WinActivate($title); activate window
WinWaitActive($title); wait for window to become active

WinGetTitle() is perhaps not needed to use unless another window appears that may have the same substring in the title.

:whistle:

Link to comment
Share on other sites

Hi MHz,

thanks for your very quick answer!!!

I tried your script but Outlook Express still won't activate until "Outlook Express" is at the beginning of the window-title...

I am using the german version so don't worry about the titles... They are:

"Outlook Express - Hauptidentität": Everything works fine

"Posteingang - Outlook Express - Hauptidentität": Activation of the window won't work

"Postausgang - Outlook Express - Hauptidentität": Activation of the window won't work, too

Maybe it depends on the "ä" in the title?

Edited by Mantris
Link to comment
Share on other sites

Maybe it depends on the "ä" in the title?

Works for my English version.

The accented character could be the issue. Test with a MsgBox to confirm.

Opt("WinTitleMatchMode", 2) 
Opt("WinTextMatchMode", 2)
WinWait("Outlook Express"); wait for window
$title = WinGetTitle("Outlook Express")
MsgBox(0, 'Check title', $title); show full title in msgbox
WinActivate($title); activate window
WinWaitActive($title); wait for window to become active

Edit:

An issue I found myself through the test when select Outbox. OutLook Express would not activate as the title was different.

I have 3 windows titles I get the 1st returned so ruins the activation of following functions.

Outlook Express FolderSync Window Class (Hidden)
Outlook Express (hidden)
Outbox - Outlook Express (visable)
Edited by MHz
Link to comment
Share on other sites

THX :whistle:

Here are the results (tested on the 3 folders as listed above):

- "Outlook Express - Hauptidentität": correct

- "Outlook Express FolderSync Window Class": hmmm...

- "Outlook Express FolderSync Window Class": hmmm, too :)

But no matter if the title is wrong... "Outlook Express" is always part of the title... This is confusing me a little bit...

EDIT: Sorry, i was too slow :)

Edited by Mantris
Link to comment
Share on other sites

Have you tried leaving out the WinGetTitle()? It seems you would need to use this pretty often throughout your script, where as if you leave that out it should just go by the "Outlook Express" that is in each title.

Dim $title = "Outlook Express"
Opt("WinTitleMatchMode", 2)
Opt("WinTextMatchMode", 2)
WinWait($title); wait for window
WinActivate($title); activate window
WinWaitActive($title); wait for window to become active
;Do something once window is active.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

THX :whistle:

Here are the results (tested on the 3 folders as listed above):

- "Outlook Express - Hauptidentität": correct

- "Outlook Express FolderSync Window Class": hmmm...

- "Outlook Express FolderSync Window Class": hmmm, too :lmao:

But no matter if the title is wrong... "Outlook Express" is always part of the title... This is confusing me a little bit...

EDIT: Sorry, i was too slow :)

Get the handle using classname to avoid the other titles

Opt("WinTitleMatchMode", 4) 
Opt("WinTextMatchMode", 2)
WinWait("classname=Outlook Express Browser Class"); wait for window
$handle = WinGetHandle("classname=Outlook Express Browser Class"); get handle
WinActivate($handle); activate window
WinWaitActive($handle); wait for window to become active

:)

Edited by MHz
Link to comment
Share on other sites

@JS

Thanks, but that won't work, too...

@MHz

That's it! Many THX and best wishes from good-old germany to australia :whistle:

Well I am glad you got it resolved.

I am curious as to why it wasnt working though. I know sometimes I have gotten errors when I have told it I will be using a "sub string" and then used the whole title, which was the entire basis for my posting the above code.

GJ MHz as always :)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...