Sign in to follow this  
Followers 0
zvvyt

Hiding and retriving 2 windows with same name from tray

4 posts in this topic

i got great help with making a window go down to tray and back, but here's the deal this time:

i'm playing a game called silkroad online (SRO) and i want to hide 2(or more) windows to tray and be able to show them again

and making a link to a homepage in the gui (not important)

#NoTrayIcon
#include <guiconstants.au3>
#include <Constants.au3>
#include <IE.au3>


Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1) 

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent")
;TraySetState(2); hide --> not needed

GUICreate("Hide Me",150,150)
$hide = GUICtrlCreateButton("HIDE ME",98,0)
;$hide2 = GUICtrlCreateButton("Hide 2nd ",98,25)
;$show = GUICtrlCreateButton("Bring me back, plzzzz",0,125)
$exit = guictrlcreatebutton("exit..",120,125)
GUICtrlCreateLabel("Donate and get your text here ",0,50)
GUICtrlCreateLabel("I'm out of words..",35,70)
GUICtrlCreateLabel("Brought to you by zvvyt btw",10,105)
guictrlsetcolor(-1,0xCC0000)
GUISetState (@sw_show)
while 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then Exit
    select 
    case $msg = $hide
        WinSetState("SRO_Client","",@sw_hide)
        TraySetState(1); show
        TraySetToolTip ("SRO Client - click here to restore")
        TraySetIcon("Silkroad.ico")
;   case $msg = $show
;   WinSetState("SRO_Client","",@sw_show)
;   TraySetState(2); hide
    Case $msg = $exit
    if not ProcessExists("sro_client.exe") then exit
    $state = WinGetState("SRO_Client","")
    if BitAnd($state, 2) then Exit
    if BitAnd($state, 2) = 0 then $asd = MsgBox(4,"DOH! You Fail!  or did you ...","SRO is still hidden. Wanna keep it that way?")
    if $asd = 7 then WinSetState("SRO_Client","",@sw_show)
        TraySetState(2); hide
        Exit
    if $asd = 6 Then Exit
    EndSelect
WEnd

Func SpecialEvent()
    WinSetState("SRO_Client","",@SW_Show)
    TraySetState(2); hide
EndFunc

Share this post


Link to post
Share on other sites



You want to be able to distinguish & manipulate two/several identical

SRO_Clients, right ?

My plan of attack would be

- Use WinList("client window title") to get handles for the clients

- Use WinGetProcess(handle) to get corresponding P(rocess) ID's

- Replace wintitles with handles in your WinGetState & WinSetState

- Replace process names with PID's in your ProcessExists

of course you will also need to adapt your script to generally

manage multi clients, such as different tray icon and/or

tray tooltips ...

Anyway, good luck, and I'll check back to see how you get along

wim

Share this post


Link to post
Share on other sites

thx for the commands

really helped me out

but now i just have to figure it out how to put this togeather

Share this post


Link to post
Share on other sites

#NoTrayIcon
#include <misc.au3>
#include <guiconstants.au3>
#include <Constants.au3>
#include <IE.au3>
FileInstall("intro.jpg","")
FileInstall("silkroad.jpg","")


SplashImageOn("Thx for using this!","intro.jpg")
sleep(2500)
SplashOff()
$array = WinList("SRO_Client")
$main = GUICreate("Hide Me",160,150)
GUISetIcon("silkroad.jpg")
GUICtrlCreateTab(0,129)
GUICtrlCreateTabitem("Main");Main
$1st = GUICtrlCreateButton("Hide",30,0)
GUICtrlCreateLabel("1st",5,5)
guictrlsetcolor(-1,0xCC0000)
$1stshow = GUICtrlCreateButton("Show",90,0)
$2ndshow = GUICtrlCreateButton("Show",90,25)
$2nd = GUICtrlCreateButton("Hide",30,25)
GUICtrlCreateLabel("2nd",5,30)
guictrlsetcolor(-1,0xCC0000)
$refresh = GUICtrlCreateButton("Refresh client info",30,70)
GUICtrlCreateTabitem("Help");Help
GUICtrlCreateLabel("Start program when all",0,2) 
GUICtrlCreateLabel("SRO clients are running",0,14) 
GUICtrlCreateLabel("Click 1st hide to hide 1st copy",0,30) 
GUICtrlCreateLabel("Click 2nd hide to hide 2nd copy",0,42)
GUICtrlCreateLabel("Click 1st show to show 1st copy",0,58)
GUICtrlCreateLabel("Click 2nd show to show 2nd copy",0,70)
GUICtrlCreateTabItem("Credits");Credits
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,0)
guictrlsetcolor(-1,0xCC0000)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,10)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,20)
guictrlsetcolor(-1,0xCC0000)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,30)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,40)
guictrlsetcolor(-1,0xCC0000)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,50)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,60)
guictrlsetcolor(-1,0xCC0000)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,70)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,80)
guictrlsetcolor(-1,0xCC0000)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,90)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,100)
guictrlsetcolor(-1,0xCC0000)
GUICtrlCreateLabel("zvvyt zvvyt zvvyt zvvyt zvvyt",10,110)
GUISetState (@SW_SHOW)
while 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then Exit
    select 
    case $msg = $refresh
        $array = WinList("SRO_Client")
        MsgBox(0,"Running copies",$array[0][0])
    case $msg = $1st
        if WinExists($array[1][1]) Then
        WinSetState($array[1][1],"",@sw_hide)
    EndIf
    case $msg = $1stshow
        WinSetState($array[1][1],"",@SW_SHOW)
    case $msg = $2nd
        if WinExists($array[2][1]) Then
        WinSetState($array[2][1],"",@sw_hide)
    EndIf
    case $msg = $2ndshow
        WinSetState($array[2][1],"",@SW_SHOW)
    EndSelect
WEnd

done without tray icons though

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