Sign in to follow this  
Followers 0
Nahuel

Window title match problem.

8 posts in this topic

I use outlook express 5 and I hate that it doesn't have the 'hide' option. So I made this:

#Include <Constants.au3>
$title="Inbox - Outlook Express"
Opt("TrayMenuMode",1)
Opt("TrayAutoPause",0)

TraySetClick (8)
$hide_show=TrayCreateItem("Hide/Show outlook")
TrayCreateItem("")
$quit = TrayCreateItem("Exit")

If Not WinExists($title) Then
    Run(@ProgramFilesDir&"\Outlook Express\MSIMN.EXE")
EndIf

AdlibEnable("outlook_exists",1000)

While 1
    $msg=TrayGetMsg()
    Select
    Case $msg=$quit
        WinClose($title)
        Exit
    Case $msg=$TRAY_EVENT_PRIMARYDOUBLE
        hide_show()
    Case $msg=$hide_show
        hide_show()
    EndSelect
WEnd
Func hide_show()
If WinExists($title) Then
    If  BitAND(WinGetState($title),2) = 2 Then
        WinSetState($title,"",@SW_HIDE)
    Else
        WinSetState($title,"",@SW_SHOW)
        WinSetState($title,"",@SW_MAXIMIZE)
    EndIf
EndIf
EndFunc
Func outlook_exists()
    If NOT ProcessExists("MSIMN.EXE") Then
        Exit
    EndIf
EndFuncoÝ÷ Øp¢¹v«}ç-+§¶)mëb¶W¨|ë­$r§ç[yÆ®±â'$yÚ®¢Ó®µº1ªê-J&i×­+ºÚ"µÍÒ[ÛYH  ÐÛÛÝ[Ë]LÉÝÂÌÍÝ]OI][ÝÓÝ]ÛÚÈ^ÜÉ][ÝÂÜ
    ][ÝÕ^SY[S[ÙI][ÝËJBÜ
    ][ÝÕ^P]]Ô]ÙI][ÝË
BØØ]ÙÈÝXNOOOOOOOOOBÜ
    ][ÝÕÚ[]SX]Ú[ÙI][ÝËBÏOOOOOOOOOOOOOOOOOOOOOOOOB^TÙ]ÛXÚÈ

BÌÍÚYWÜÚÝÏU^PÜX]R][J    ][ÝÒYKÔÚÝÈÝ]ÛÚÉ][ÝÊB^PÜX]R][J  ][ÝÉ][ÝÊBÌÍÜ]Z]H^PÜX]R][J   ][ÝÑ^]    ][ÝÊBYX[XJ    ][ÝÛÝ]ÛÚ×Ù^ÝÉ][ÝËL
BYÝÚ[^ÝÊ    ÌÍÝ]JH[T[ÙÜ[Q[Ñ[É][ÝÉÌLÓÝ]ÛÚÈ^ÜÉÌLÓTÒSSVI][ÝÊB[YÚ[HBIÌÍÛÙÏU^QÙ]ÙÊ
BTÙ[XÝPØÙH  ÌÍÛÙÏIÌÍÜ]Z]BUÚ[ÛÜÙJ    ÌÍÝ]JBBQ^]PØÙH ÌÍÛÙÏIÌÍÕVWÑUSÔSPTQÕPBBZYWÜÚÝÊ
BPØÙH ÌÍÛÙÏIÌÍÚYWÜÚÝÂBZYWÜÚÝÊ
BQ[Ù[XÝÑ[[ÈYWÜÚÝÊ
BYÚ[^ÝÊ  ÌÍÝ]JH[RYP]S
Ú[Ù]Ý]J  ÌÍÝ]JKHH[BUÚ[Ù]Ý]J    ÌÍÝ]K    ][ÝÉ][ÝËÕ×ÒQJBQ[ÙBBUÚ[Ù]Ý]J  ÌÍÝ]K    ][ÝÉ][ÝËÕ×ÔÒÕÊBBUÚ[Ù]Ý]J   ÌÍÝ]K    ][ÝÉ][ÝËÕ×ÓPVSRVJBQ[Y[Y[[Â[ÈÝ]ÛÚ×Ù^ÝÊ
BRYÕØÙÜÑ^ÝÊ  ][ÝÓTÒSSVI][ÝÊH[BQ^]Q[Y[[

When I first run it, a new 'invisible' window (I can see it in the taskbar though) shows up with the title "Outlook Express FolderSync Window Class" and it won't let me do anything. I kill it with the task manager and then my script starts working UNTIL the window title changes again, if I move from the Inbox to Outbox for example, and all that happens again.

hum.. why?

Share this post


Link to post
Share on other sites



WinGetHandle(). Get the window's handle early on and just use that. It won't change even if the title does.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank you! :)

Share this post


Link to post
Share on other sites

If Outlook is closed and I run the script, it opens Outlook but nothing happens when I double-click the tray icon. Now, when I click the menu item "hide/show outlook" I get this:

Posted Image

;)

I close it and then it hides my taskbar :)

If outlook is already running when I run the script, it seems to work perfectly!

#Include <Constants.au3>
Opt("TrayMenuMode",1)
Opt("TrayAutoPause",0)

TraySetClick (8)

$esconder_mostrar=TrayCreateItem("Hide/Show outlook")
TrayCreateItem("")
$salir = TrayCreateItem("Exit")

If Not WinExists("Bandeja de entrada - Outlook Express") Then
    Run(@ProgramFilesDir&"\Outlook Express\MSIMN.EXE")
EndIf
$handle=WinGetHandle("Bandeja de entrada - Outlook Express")
AdlibEnable("outlook_exists",1000)
While 1
    sleep(50)
    $msg=TrayGetMsg()
    Select
    Case $msg=$salir
        WinClose($handle)
        Exit
    Case $msg=$TRAY_EVENT_PRIMARYDOUBLE
        hide_show()
    Case $msg=$esconder_mostrar
        hide_show()
    EndSelect
WEnd
Func hide_show()
If WinExists($handle) Then
    If  BitAND(WinGetState($handle),2) = 2 Then
        WinSetState($handle,"",@SW_HIDE)
    Else
        WinSetState($handle,"",@SW_SHOW)
        WinSetState($handle,"",@SW_MAXIMIZE)
    EndIf
EndIf
EndFunc
Func outlook_exists()
    If NOT ProcessExists("MSIMN.EXE") Then
        Exit
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If Not WinExists("Bandeja de entrada - Outlook Express") Then

Run(@ProgramFilesDir&"\Outlook Express\MSIMN.EXE")

EndIf

$handle=WinGetHandle("Bandeja de entrada - Outlook Express")

so leme understand this, you trying to see if win named "Bandeja de entrada - Outlook Express" not Exists and the name of the window is "Outlook Express"???

so the handle is returrn is "" $null and its activate (hide) the first active window (taskbar), and call the first activate window when you dubleclick (au3 script window becose its the first active when you dubleclick it)

, why dont you try to see if the $handle=WinGetHandle("Outlook Express") with combination on WinWait("Outlook Express") works

i think that your dooing something wrong with handle :)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Haha.. well, what I tried to do there was check if the window exists. If it doesn't, it opens outlook and now it exists, so I use $handle=WinGetHandle("Bandeja de entrada - Outlook Express") then, haha.

I tried doiing this:

If Not WinExists("Bandeja de entrada - Outlook Express") Then

Run(@ProgramFilesDir&"\Outlook Express\MSIMN.EXE")

sleep(1000)

EndIf

So it gives time to the window to be created? but no success. haha, i'm so confused.

Edited by Nahuel

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Haha.. well, what I tried to do there was check if the window exists. If it doesn't, it opens outlook and now it exists, so I use $handle=WinGetHandle("Bandeja de entrada - Outlook Express") then, haha.

I tried doiing this:

If Not WinExists("Bandeja de entrada - Outlook Express") Then

Run(@ProgramFilesDir&"\Outlook Express\MSIMN.EXE")

sleep(1000)

EndIf

So it gives time to the window to be created? but no success. haha, i'm so confused.

im sry if my coding isnt too good tonight, alot of drinks make my brain togo BUM, so sry if this dont work

#Include <Constants.au3>
Opt("TrayMenuMode",1)
Opt("TrayAutoPause",0)
Global $win1 = "Outlook Express"
Global $win2 = "Inbox - Outlook Express"
TraySetClick (8)
Opt("WinTitleMatchMode", 3)
$esconder_mostrar=TrayCreateItem("Hide/Show outlook")
TrayCreateItem("")
$salir = TrayCreateItem("Exit")
$winname = "Outlook Express"
If Not WinExists("Outlook Express") Then
If Not WinExists("Inbox - Outlook Express") Then
    Run(@ProgramFilesDir&"\Outlook Express\MSIMN.EXE")
EndIf
EndIf
WinWait("Outlook Express")
$handle = WinGetHandle("Outlook Express")
While 1
    sleep(50)
    $msg=TrayGetMsg()
    Select
    Case $msg=$salir
        WinClose($handle)
        Exit
    Case $msg=$TRAY_EVENT_PRIMARYDOUBLE
        hide_show()
    Case $msg=$esconder_mostrar
        hide_show()
    EndSelect
WEnd


Func hide_show()
$state1 = WinGetState("Outlook Express")
$state2 = WinGetState("Inbox - Outlook Express")
Select
    Case WinExists("Inbox - Outlook Express")
        If $state2 = "7" Then
            WinSetState($win2, "", @SW_HIDE)
        EndIf
        If $state2 = "5" Then
            WinSetState($win2, "", @SW_SHOW)
            WinSetState($win2, "", @SW_RESTORE)
        EndIf
    Case WinExists("Outlook Express")
        If $state1 = "7" Then
            WinSetState($win1, "", @SW_HIDE)
        EndIf
        If $state1 = "5" Then
            WinSetState($win1, "", @SW_SHOW)
            WinSetState($win1, "", @SW_RESTORE)
        EndIf   

    EndSelect
    
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

hahaha, thank you! I had to do a few modifications and it worked :) Keep partying.

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  
Followers 0