AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

System Tray operation

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
valenock



Joined: 14 Sep 2004
Posts: 17

PostPosted: Tue Sep 14, 2004 10:17 pm    Post subject: System Tray operation Reply with quote

hello !

I am a newbie to AutoHotkey but it already seems to me like Perl for Windows (tm)
Wink

The problem I'm stuck with, is programming of system tray applications.
Nowadays a lot of programs use "system tray" to hide from task bar and save some place on it. As long as system tray is a special window of explorer.exe I thought I could easily minimize/maximize apps from it.

No way.

As long as this is a "special" window of explorer.exe there're no ways like WinRestore, or just some other SendMessage command to easily call a window from system tray.

The problem:
We have a tray icon of a program, let's say it's a well-known emule client.
We want to maximize it's window so that the icon from system tray is gone (maximizing with system tray icon still in it system tray is easy but leads to unpredictable results).

I tried two solutions:
1 - to make a special SendMessage to emule.exe window with all kind of messages; It can maximize the window, but it leaves the icon in the tray ...
2 - to ControlFocus, Notification, ahk_class Shell_TrayWnd
but then - there's no way to determine which application in system tray has got the focus and is ready to popup, because "Notification Area" of Shell_TrayWnd doesn't change its name or other parameters, depending on the current focused application - it just displays another nice tooltip, which I can not read with AutoHotkey ...

Or can ?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Tue Sep 14, 2004 10:55 pm    Post subject: Reply with quote

An application's tray icon is something it controls directly. If an application has no built-in way for you to hide its icon, you could use Windows XP's (and Me's?) feature for hiding unwanted icons: Right-click the task bar and select "properties", then press the "Customize" button next to "Hide inactive icons". If you don't have Windows XP/Me, I believe there are 3rd party utilities for hiding unwanted icons.

Also, if you unhide an application's window without it knowing that you unhid it, you can get unpredictable results (as you mentioned). The best way around this is to first see if the app accepts any command line parameters so that it can be run a 2nd time (while already running) to display its main window. If not, find out which message is sent when you select its "show window" item from its tray menu, then use PostMessage to send that message (you mentioned something about already having tried this).

Finally, here is another topic that discusses how to automate tray icons: http://www.autohotkey.com/forum/viewtopic.php?t=622&highlight=winb+appskey
Back to top
View user's profile Send private message Send e-mail
valenock



Joined: 14 Sep 2004
Posts: 17

PostPosted: Tue Sep 14, 2004 11:49 pm    Post subject: Yahoo ! Reply with quote

With all the help from you I managed to do it !

BTW, Does it sound like a good idea to have a list of well-known apps and a list of SendMessage commands which are known to work with them ?
like that of Gaim or this of Emule ?
For open-source you still have the possibility to find them in source but for commercial software the only way is to guess a couple values ...

Anyway here is my brick in the wall - a demo script which rules Emule client:


SetTitleMatchMode, 2
DetectHiddenWindows, On

#z:: ; emule window loops: started if not started previously => active+maximized => hidden in systray

IfWinExist,eMule
{


IfWinActive
{
; minimize to system tray - either way
ControlSend,,{ESC}
;SendMessage, 0x112,0xF020,, ; WM_SYSCOMMAND - mimize emule to systray
Exit
}
else
{
; restore to maximized state
PostMessage, 0x502, 1, 0x202, ; WM_USER + 258
PostMessage, 0x502, 1, 0x203, ; WM_USER + 258
;SendMessage, 0x502, 1, 0x205, ; WM_USER + 258 - OR show emule's right-click menu
WinMaximize
WinActivate
Exit
}


Run, %ProgramFiles%\emule\emule.EXE


}

return
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Sep 15, 2004 12:22 am    Post subject: Reply with quote

Thanks for posting your findings. Just by having it here is probably a good way for others to find it via the forum's search-function.
Back to top
View user's profile Send private message Send e-mail
valenock



Joined: 14 Sep 2004
Posts: 17

PostPosted: Wed Sep 15, 2004 6:45 pm    Post subject: Total Commander scripting Reply with quote

This is a script which does almost the same to Total Commander (former Windows Commander).

#t:: ; TOTAL COMMANDER =============================================================================

IfWinExist, Total Commander
{

IfWInActive
{
; minimize to tray
Send, +{ESC}
}
else
{
ControlSend,,{ENTER},TotalCmd ;TotalCmd is a special window which is not visible but exists for one purpose only
}

Exit
}

Run, %ProgramFiles%\Total Commander XP\TOTALCMD.EXE /I=".\Profiles\Prof\main.ini" /F=".\Profiles\Prof\ftp.ini",,max
return
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group