Jump to content

Window Tray Tool


IsleOfTechno
 Share

Recommended Posts

Hello everybody :-)

This is my first program that I want to share with you.

#comments-start

<=Window Tray Tool=>   by IsleOfTechno (korschenbroich@yahoo.de) 19.11.2006

This script can hide a window and show a Tray-symbol when you minimize the window.

You have to identify the window you want to use by a part of its Window-title AND a part of the 
Process-name of the application which has created this window, so you can be sure my tool
will hide the correct window ...

If your given iditifiers apply to two or more windows, the tool will hide them all and show 
them again with one click.

To save system performance i have included sleep(1000) so that it checks the windows every
second ... you can reduce this value if you have a fast CPU ^^

#comments-end


; Tray event values
Global Const $TRAY_EVENT_PRIMARYUP      = -8


Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   
Opt("TrayIconHide", 1)
AutoItWinSetTitle(@ScriptName)
TraySetClick ( 16 )
TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"make_visible")
$exititem = TrayCreateItem("Show")
TrayItemSetOnEvent(-1,"make_visible")
$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetState()
TraySetToolTip("Window Tray Tool")

Const $part_of_windowtitel =  "Editor"   ; the textpart of the window-title which you want to use to identify the correct window
Const $part_of_processname = "notepad"   ; the textpart of the processname of the process which has created the window as its in the task-manager 

Opt("TrayIconHide", 1) 

_Singleton("Window Tray Tool.exe")   ; allows only one inctance of this tool at the same time

While 1
    sleep(1000)   ; intervall to check the windows if the special one was just minimized by the user
    Opt( "WinTitleMatchMode", 2 )
    $window_array = WinList($part_of_windowtitel)
    Opt( "WinTitleMatchMode", 4 )
    for $i = 1 to $window_array[0][0]
        If StringInStr(_ProcessGetName(WinGetProcess ($window_array[$i][1])),$part_of_processname) <> 0 AND BitAnd(WinGetState ($window_array[$i][1]) , 16) = 16 AND BitAnd(WinGetState ($window_array[$i][1]) , 2)   Then
            WinSetState ( $window_array[$i][1] , "",@SW_HIDE)
            Opt("TrayIconHide", 0)
        EndIf
    Next
WEnd


Func make_visible()
    Opt( "WinTitleMatchMode", 2 )
    $window_array2 = WinList($part_of_windowtitel)
    Opt( "WinTitleMatchMode", 4 )
    For $i = 1 to $window_array2[0][0]
        If StringInStr(_ProcessGetName(WinGetProcess ($window_array2[$i][1])),$part_of_processname) <> 0 AND BitAnd(WinGetState ($window_array2[$i][1]) , 2) <> 2 Then
            WinSetState ( $window_array2[$i][1] , "",@SW_SHOW)
            WinSetState ( $window_array2[$i][1], "",@SW_RESTORE)
        EndIf
        Opt("TrayIconHide", 1) 
    Next
EndFunc   ;==>make_visible


Func _ProcessGetName( $i_PID )
    If Not ProcessExists($i_PID) Then
        SetError(1)
        Return ''
    EndIf
    Local $a_Processes = ProcessList()
    If Not @error Then
        For $i = 1 To $a_Processes[0][0]
            If $a_Processes[$i][1] = $i_PID Then Return $a_Processes[$i][0]
        Next
    EndIf
    SetError(1)
    Return ''
EndFunc   ;==>_ProcessGetName


Func _Singleton($occurenceName, $flag = 0)
    Local $ERROR_ALREADY_EXISTS = 183
    $occurenceName = StringReplace($occurenceName, "\", "") ; to avoid error
    ;    Local $handle = DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $occurenceName)
    Local $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $occurenceName)
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    If $lastError[0] = $ERROR_ALREADY_EXISTS Then
        If $flag = 0 Then
            Exit -1
        Else
            SetError($lastError[0])
            Return 0
        EndIf
    EndIf
    Return $handle[0]
EndFunc   ;==>_Singleton


Func ExitScript()
    make_visible()
    WinClose(@ScriptName)
    Exit
EndFunc   ;==>ExitScript

It would be nice to read some comments from you about it ...

IsleOfTechno from Germany ;)

Window_Tray_Tool.au3

Edited by IsleOfTechno
www.galenda.de - Der Kalender in AutoITwww.dsbot.de - Die Seite für Bot-Programmierung in AutoIt allgemein und für meinen dieStämme-Bot
Link to comment
Share on other sites

hmm i noticed you posted the code twice! lol oh yes i have comments.

i noticed when you minimze a window which is maximized. for example notepad, and when you click it from the system tray, it will show it as maximized and then it restores down and then maximizes again. if you dont get it, you try minimizing a maximized window

and yes, hopefully you can make the tray icon as the programme's icon file if possible

Link to comment
Share on other sites

ok, thanks to Cherry for programming so much bugs in their keyboard software ....

i have deleted the double-source ^^

i got it but i dont have this problem .... I dont know why ....

may by there is some problem with

WinSetState ( $window_array2[$i][1], "",@SW_RESTORE)

dont know, but it should just Undo the window minimization ...

the icon of the program ? when you can need this tool, just get the right icon and compile it with Aut2Exe.exe using your icon ;):lmao:

Edited by IsleOfTechno
www.galenda.de - Der Kalender in AutoITwww.dsbot.de - Die Seite für Bot-Programmierung in AutoIt allgemein und für meinen dieStämme-Bot
Link to comment
Share on other sites

ok, thanks to Cherry for programming so much bugs in their keyboard software ....

i have deleted the double-source ^^

i got it but i dont have this problem .... I dont know why ....

may by there is some problem with

WinSetState ( $window_array2[$i][1], "",@SW_RESTORE)oÝ÷ ÙÚ'¶IèÁ»­Û!¢é]ë-Rwh¶°whÂh§h³jبØ^Ê'¡ûaz趦§ÊjyÞyÛaËh¢Xî²Ø¶Ø^®('(©Ýr©W¢·­­ØL^{®²)àÊ«Ê'¬¶Wþ«¨µë-®)Ú'¶IèÂf²mè­²;¬µ¦î­l¢jnµêÞ®i¿²Úâá!8­Á«nè0ØfÊ趦¬µë-x(ºÜ"¶¨1NrzÈ¢¸(¶Ú-zYr¢ì!jÖ ­æ­ò¢èZ½çhàè騭ëax- rvíÊuÖ¥w¨}Êy«­¢+Ø)%9½Ð]¥¹á¥ÍÑÌ ÅÕ½ÐìÅÕ½ÐìµÀìÀÌØíÁÉÑ}½}ÁɽÍ͹µµÀìÅÕ½Ðì¹áÅÕ½Ðì¤Q¡¸á¥Ð(

which ensures that when the selected program exits the script will exit ;)

Edited by IcyFerno
Link to comment
Share on other sites

one more thing though, why dont you add a line of code:

If Not WinExists ("" & $part_of_processname & ".exe") Then Exit
oÝ÷ Ûbr§²êÞ²ØZ·^Ø^±é^rצº ­©Æ+l¶¬r¸©·¥ìb·ú®¢×¢¶§Øb²+'¢Û(mçºÇ¦Ê趦².Øz{b+a{§v-£
+­¼¥ªí¡ûb¶WÖ©j»h~èqë,©¶Þ²êÞ¶­Û"²Ø¢ºÞrÜ"Ú0jȬj'ZnÞ~ÞÅ©©èÊ¡j÷ìiÞ®^^­ê®¢ÑÚ+ªê-q®f§ÊËZÛ"+l¶+ezØ^¶¶²¶%Â)ez÷§ûaz·¢²{Z)èµêZv»§)àr^«-¡·¥G­+ºÚ"µÍ[ÈXZÙWÝÚXJ
BSÜ
    ][ÝÕÚ[]SX]Ú[ÙI][ÝË
BIÌÍÝÚ[Ý×Ø^LHÚ[Ý
    ÌÍÜÛÙÝÚ[ÝÝ][
BSÜ
    ][ÝÕÚ[]SX]Ú[ÙI][ÝË

BQÜ    ÌÍÚHHHÈ ÌÍÝÚ[Ý×Ø^LÌVÌBBRYÝ[Ò[ÝÔØÙÜÑÙ][YJÚ[Ù]ØÙÜÈ
    ÌÍÝÚ[Ý×Ø^LÉÌÍÚWVÌWJJK   ÌÍÜÛÙÜØÙÜÛ[YJH    ÉÝÈS][
Ú[Ù]Ý]H
    ÌÍÝÚ[Ý×Ø^LÉÌÍÚWVÌWJHH   ÉÝÈ[BBUÚ[Ù]Ý]H
    ÌÍÝÚ[Ý×Ø^LÉÌÍÚWVÌWH ][ÝÉ][ÝËÕ×ÔÒÕÊBBBUÚ[Ù]Ý]H
    ÌÍÝÚ[Ý×Ø^LÉÌÍÚWVÌWK ][ÝÉ][ÝËÕ×ÔTÕÔJBBQ[ÙRYÝ[Ò[ÝÔØÙÜÑÙ][YJÚ[Ù]ØÙÜÈ
    ÌÍÝÚ[Ý×Ø^LÉÌÍÚWVÌWJJK   ÌÍÜÛÙÜØÙÜÛ[YJH    ÉÝÈ[BQ[ÙBBBUÚ[ÛÜÙJØÜ[YJBBBQ^]BQ[YBSÜ
    ][ÝÕ^RXÛÛYI][ÝËJHS^[[ÈÏOIÝÛXZÙWÝÚXBoÝ÷ ØÚÂ)Ý£z{b~'o-7꫶ðwhÂØ­zV§wMú¥ªí¡úk¡Ç¬²v¦yìb²Û-éâ·¥©¥éç¢Øb®¶­sdVÇ6Tb7G&ætå7G"õ&ö6W74vWDæÖRvävWE&ö6W72b33c·væF÷uö'&%²b33c¶Õ³ÒÂb33c·'Eööe÷&ö6W76æÖRfÇC²fwC²FVoÝ÷ Ù»­Â§z÷§¶«z+'¢Ë§v-éÚºÚ"µÍ[ÙBBBUÚ[ÛÜÙJØÜ[YJBBBQ^]

You understand ? ;):lmao:

Edited by IsleOfTechno
www.galenda.de - Der Kalender in AutoITwww.dsbot.de - Die Seite für Bot-Programmierung in AutoIt allgemein und für meinen dieStämme-Bot
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...