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 

[module] Tray 1.0 - Tray icon controller

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Wed Nov 28, 2007 4:07 pm    Post subject: [module] Tray 1.0 - Tray icon controller Reply with quote


_________________


Last edited by majkinetor on Fri Jan 18, 2008 3:40 pm; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
Andreone



Joined: 20 Jul 2007
Posts: 257
Location: Paris, France

PostPosted: Wed Nov 28, 2007 5:16 pm    Post subject: Reply with quote

Great Very Happy Thank you very much.
It's good to know that we are not limited with the number of tray icons anymore.
Back to top
View user's profile Send private message
Dragonscloud



Joined: 16 Jul 2005
Posts: 96

PostPosted: Wed Nov 28, 2007 11:22 pm    Post subject: Reply with quote

I will find this useful. Thanks. Looks pretty easy to use. Very Happy
_________________
“yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.
Back to top
View user's profile Send private message
Junyx



Joined: 11 Jul 2005
Posts: 84
Location: Germany

PostPosted: Thu Nov 29, 2007 10:51 pm    Post subject: Reply with quote

this piece of soft is very interesting!

@majkinetor:
is there a way to attach different menus to the tray icons?
with your test script every created icon shares the same menu.

i tried different things but wasn't able to do it the right way(tm).

regards...
Junyx
_________________
C.R.E.A.M.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Thu Nov 29, 2007 11:50 pm    Post subject: Reply with quote

Yes, something like:

Code:
hIcon1 := Tray_Add(...)
hIcon2 := Tray_Add(...)

OnTrayIcon(wparam, lparam) {
   local msg
   static LBUTTONDOWN=0x201, LBUTTONUP=0x202, LBUTTONDBLCLK=203, RBUTTONDOWN=0x204, ....
   msg := lparam & 0xFFFF

   if (msg != RBUTTONUP)
      return

   if (wparam = hIcon1)
         ShowMenu(menu1)

   if (wparam = hIcon2)
         ShowMenu(menu2)
}

_________________
Back to top
View user's profile Send private message MSN Messenger
Junyx



Joined: 11 Jul 2005
Posts: 84
Location: Germany

PostPosted: Fri Nov 30, 2007 2:45 pm    Post subject: Reply with quote

thanks, man!
will try it on weekend.
i thought my "solution" looked similar but didn't work out as expected...
_________________
C.R.E.A.M.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Mon Dec 03, 2007 1:31 pm    Post subject: Reply with quote

interesting.

glanced at code but did not see, is there a reason is placing only lo-res version of icons ?
_________________
Joyce Jamce
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Mon Dec 03, 2007 2:18 pm    Post subject: Reply with quote

LOL... well, there is a reason.
I am totaly bored by that topic (icons in the menus) and didn't find the way back then (while developing MMenu) to 1) load shell icons in any other size then 32 or 16, 2) make them hi res.

I beleive lexikos answered both of those questions, so perhaps we can summon him here for help instead of taking it hard way and browsing his Menu function.
_________________
Back to top
View user's profile Send private message MSN Messenger
Junyx



Joined: 11 Jul 2005
Posts: 84
Location: Germany

PostPosted: Mon Dec 03, 2007 7:02 pm    Post subject: Reply with quote

majkinetor wrote:
Code:
hIcon1 := Tray_Add(...)
hIcon2 := Tray_Add(...)
OnTrayIcon(wparam, lparam) {
   local msg
   static LBUTTONDOWN=0x201, LBUTTONUP=0x202, LBUTTONDBLCLK=203, RBUTTONDOWN=0x204, ....
   msg := lparam & 0xFFFF
   if (msg != RBUTTONUP)
      return
   if (wparam = hIcon1)
         ShowMenu(menu1)
   if (wparam = hIcon2)
         ShowMenu(menu2)
}

i tried the code (merged it with your _Test.ahk) - but i won't work.
menu2 will be displayed, but not only for tray icon no. 2.
instead both tray menus will be set to menu2.

did you try your code yourself?
_________________
C.R.E.A.M.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Tue Dec 04, 2007 12:12 am    Post subject: Reply with quote

you didn't do something correctly.

This example works:

Code:
#NoTrayIcon
#SingleInstance force

   Gui,  +LastFound
   hwnd := WinExist()

   menus =
   (LTrim
         [TrayMenu1]
         11
         12

         [TrayMenu2]
         21
         22
         23
   )

   h1 := Tray_Add( hwnd, "OnTrayIcon", "res\new.ico")
   h2 := Tray_Add( hwnd, "OnTrayIcon", "res\new.ico")
return

TrayMenu1:
   msgbox Hi from menu1
return

TrayMenu2:
   msgbox Hi from menu2
return

OnTrayIcon(wparam, lparam) {
   local msg
   static LBUTTONDOWN=0x201, LBUTTONUP=0x202, LBUTTONDBLCLK=203, RBUTTONDOWN=0x204, RBUTTONUP=0x205, RBUTTONDBLCLK=0x206, MBUTTONDOWN=0x207, MBUTTONUP=0x208, MBUTTONDBLCLK=0x209
   msg := lparam & 0xFFFF

   if (msg != RBUTTONUP)
      return


   if (wparam=h1)
       ShowMenu(menus, "TrayMenu1")
   else ShowMenu(menus, "TrayMenu2")
}

#include Tray.ahk
#include res\ShowMenu.ahk

_________________
Back to top
View user's profile Send private message MSN Messenger
Junyx



Joined: 11 Jul 2005
Posts: 84
Location: Germany

PostPosted: Wed Dec 05, 2007 8:29 pm    Post subject: Reply with quote

okay, thanks. your last code worked for me.

Junyx
_________________
C.R.E.A.M.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Fri Jan 18, 2008 3:30 pm    Post subject: Reply with quote

v1.0
http://www.autohotkey.net/~majkinetor/Tray/Tray.html
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions 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