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 

Programatically right clicking on a tray icon

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



Joined: 30 Sep 2005
Posts: 58
Location: Fort Wayne, IN

PostPosted: Thu Oct 13, 2005 7:00 pm    Post subject: Programatically right clicking on a tray icon Reply with quote

Is there a way in AHK to right click on a tray icon so the context menu is displayed?

I know the applicantion's name and PID.

I've tried using WinActivate, but it doesn't set focus on the icon. If I can get focus on the icon, then I can send the {APPSKEY} keystroke to show the context menu.

Thanks,
Dean
Back to top
View user's profile Send private message
shimanov



Joined: 25 Sep 2005
Posts: 610

PostPosted: Thu Oct 13, 2005 9:19 pm    Post subject: Reply with quote

The code below will activate the AHk tray menu.

current limitation: target image must be unique and static

Code:

Sleep, 100

hw_notification := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )

WinGetPos, s_x, s_y, s_w, s_h, ahk_id %hw_notification%

CoordMode, Pixel, Screen
ImageSearch, t_x, t_y, s_x, s_y, s_x+s_w-1, s_y+s_h-1, *Icon1 %A_ProgramFiles%\autohotkey\autohotkey.exe

if ( ErrorLevel = 0 )
{
   CoordMode, Mouse, Screen
   MouseClick, Right, t_x, t_y, 1
}
return

FindWindow( p_tree )
{
   level_total = 0

   loop, parse, p_tree, |
   {
      level_total++
      
      ix := InStr( a_LoopField, "," )

      if ( ix )
      {
         StringMid, tree[%level_total%]?class, a_LoopField, 1, ix-1
         StringMid, tree[%level_total%]?title, a_LoopField, ix+1, StrLen( a_LoopField )-ix
      }
      else
      {
         tree[%level_total%]?class := a_LoopField
         tree[%level_total%]?title = 0
      }
   }
   
   hw_parent = 0
   hw_child = 0
   
   level = 1
   
   loop,
   {
      hw_child := FindWindowEx( hw_parent, hw_child, tree[%level%]?class, tree[%level%]?title )

      if ( hw_child )
      {
         if ( level = level_total )
            return, hw_child
      
         level++
         
         hw_parent_old := hw_parent
         hw_parent := hw_child
         
         hw_child_old := hw_child   
         hw_child = 0
      }
      else
      {
         if ( level = 1 )
            return, 0
      
         level--
         
         hw_parent := hw_parent_old
         
         hw_child := hw_child_old
      }
   }
}

FindWindowEx( p_hw_parent, p_hw_child, p_class, p_title=0 )
{
   if ( p_title = 0 )
      type_title = uint
   else
      type_title = str

   return, DllCall( "FindWindowEx"
                  , "uint", p_hw_parent
                  , "uint", p_hw_child
                  , "str", p_class
                  , type_title, p_title )
}
Back to top
View user's profile Send private message
deanhill1971



Joined: 30 Sep 2005
Posts: 58
Location: Fort Wayne, IN

PostPosted: Tue Oct 18, 2005 3:24 am    Post subject: Reply with quote

Thanks for the quick reply.

Your solution of looking for the icon is interesting. I'll play around with it some more, but I see two immediate problems. I'm trying to right click on the tray icon for my Nortel VPN connection. The icon changes color as data is sent/received. I guess I could look for more than one icon.

Also, I assume the icon won't be found if the icon gets auto-hidden (because it has not been used for a while).
Back to top
View user's profile Send private message
shimanov



Joined: 25 Sep 2005
Posts: 610

PostPosted: Tue Oct 18, 2005 7:40 am    Post subject: Reply with quote

There is a better way. I will provide the code for you, with the following disclaimer:

The following code has been tested with Windows XP SP2. It lacks comprehensive error checking and due to differences between systems, and especially between versions of Windows, may cause the Windows shell (i.e., Explorer) to crash.

If you're willing to run the code and report back the information presented in each dialog -- especially that in the "button information" dialog -- then I can help you further.

Code:
WM_USER = 0x400

hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
MsgBox, hw_notification_area = %hw_notification_area%

VarSetCapacity( pid_explorer, 4 )

WinGet, pid_explorer, PID, ahk_id %hw_notification_area%
MsgBox, pid_explorer: %pid_explorer%

hp_explorer := DllCall( "OpenProcess", "uint", 0x8|0x10, "int", true, "uint", pid_explorer )
MsgBox, openprocess: %ErrorLevel% - %hp_explorer%

remote_buffer := DllCall( "VirtualAllocEx"
                     , "uint", hp_explorer
                     , "uint", 0
                     , "uint", 0x1000
                     , "uint", 0x1000
                     , "uint", 0x4 )
MsgBox, virtualallocex: %ErrorLevel% - %remote_buffer%

TB_BUTTONCOUNT := WM_USER+24
SendMessage, TB_BUTTONCOUNT, 0, 0,, ahk_id %hw_notification_area%
MsgBox, button count = %ErrorLevel%

TB_GETBUTTON := WM_USER+23
SendMessage, TB_GETBUTTON, 0, remote_buffer,, ahk_id %hw_notification_area%
MsgBox, TB_GETBUTTON: %ErrorLevel%

remote_buffer2 := remote_buffer+200

TB_GETITEMRECT := WM_USER+29
SendMessage, TB_GETITEMRECT, index, remote_buffer2,, ahk_id %hw_notification_area%
MsgBox, TB_GETITEMRECT: %ErrorLevel%

VarSetCapacity( buffer, 1000, 0 )
VarSetCapacity( buffer_actual_size, 4, 0 )

pBuffer2 := &buffer+200

result := DllCall( "ReadProcessMemory"
                  , "uint", hp_explorer
                  , "uint", remote_buffer
                  , "uint", &buffer
                  , "uint", 1000
                  , "uint", &buffer_actual_size )
buffer_actual_size := ReadInteger( "uint", &buffer_actual_size, 0 )
MsgBox, readprocessmemory: %ErrorLevel% - %result% ~ %buffer_actual_size%

; -- data --
VarSetCapacity( buffer2, 1000, 0 )
VarSetCapacity( buffer_actual_size, 4, 0 )

result := DllCall( "ReadProcessMemory"
                  , "uint", hp_explorer
                  , "uint", ReadInteger( "int", &buffer, 12 )
                  , "uint", &buffer2
                  , "uint", 1000
                  , "uint", &buffer_actual_size )
buffer_actual_size := ReadInteger( "uint", &buffer_actual_size, 0 )
MsgBox, readprocessmemory: %ErrorLevel% - %result% ~ %buffer_actual_size%

; -- string --
VarSetCapacity( buffer3, 1000, 0 )
VarSetCapacity( buffer_actual_size, 4, 0 )

result := DllCall( "ReadProcessMemory"
                  , "uint", hp_explorer
                  , "uint", ReadInteger( "int", &buffer, 16 )
                  , "uint", &buffer3
                  , "uint", 1000
                  , "uint", &buffer_actual_size )
buffer_actual_size := ReadInteger( "uint", &buffer_actual_size, 0 )
MsgBox, readprocessmemory: %ErrorLevel% - %result% ~ %buffer_actual_size%

MsgBox, %
   ( Join
      "-- [" A_Index-1 "] button information --"
      "`n`ncommand = " ReadInteger( "int", &buffer, 4 )
      "`nstate = " ReadInteger( "uchar", &buffer, 8 )
      "`ndata = " ReadInteger( "uint", &buffer, 12 )
      "`nstring = " ReadInteger( "int", &buffer, 16 )
      "`n`nrect = " ReadInteger( "int", pBuffer2, 0, false )
         ", " ReadInteger( "int", pBuffer2, 4, false )
         ", " ReadInteger( "int", pBuffer2, 8, false )
         ", " ReadInteger( "int", pBuffer2, 12, false )
      "`n`ndata = " ReadInteger( "uint", &buffer2, 0 )
      "`nstring = " ReadStringA( &buffer3, 0, 1000 )
   )
ExitApp

TwosComplement( p_value, p_size )
{
   return, ( p_value^( 2**( p_size*8 )-1 ) )+1
}

ReadInteger( p_type, p_address, p_offset, p_hex=true )
{
   old_FormatInteger := a_FormatInteger

   if ( p_hex )
      SetFormat, integer, hex
   else
      SetFormat, integer, dec
     
   if ( p_type = "int" )
   {
      sign := true
      size = 4
   }
   else if ( p_type = "uint" )
   {
      sign := false
      size = 4
   }
   else if ( p_type = "short" )
   {
      sign := true
      size = 2
   }
   else if ( p_type = "ushort" )
   {
      sign := false
      size = 2
   }
   else if ( p_type = "char" )
   {
      sign := true
      size = 1
   }
   else if ( p_type = "uchar" )
   {
      sign := false
      size = 1
   }
   else
      MsgBox, [ReadInteger] error: the type %p_type% is undefined!

   value = 0

   loop, %size%
      value := value+( *( ( p_address+p_offset )+( a_Index-1 ) ) << ( 8*( a_Index-1 ) ) )
     
   if ( sign )
   {
      sign := ( *( p_address+p_offset+( size-1 ) ) ) >> 7
     
      if ( sign )
         value := -1*TwosComplement( value, size )
   }
     
   SetFormat, integer, %old_FormatInteger%

   return, value
}

ReadStringA( p_address, p_offset, p_size )
{
   text=
   
   address := p_address+p_offset-2

   loop, %p_size%
   {
      address += 2
   
      if ( *( address ) = 0 )
         break
     
      text := text Chr( *( address ) )
   }
   
   return, text
}

FindWindow( p_tree )
{
   level_total = 0

   loop, parse, p_tree, |
   {
      level_total++
     
      ix := InStr( a_LoopField, "," )

      if ( ix )
      {
         StringMid, tree[%level_total%]?class, a_LoopField, 1, ix-1
         StringMid, tree[%level_total%]?title, a_LoopField, ix+1, StrLen( a_LoopField )-ix
      }
      else
      {
         tree[%level_total%]?class := a_LoopField
         tree[%level_total%]?title = 0
      }
   }
   
   hw_parent = 0
   hw_child = 0
   
   level = 1
   
   loop,
   {
      hw_child := FindWindowEx( hw_parent, hw_child, tree[%level%]?class, tree[%level%]?title )

      if ( hw_child )
      {
         if ( level = level_total )
            return, hw_child
     
         level++
         
         hw_parent_old := hw_parent
         hw_parent := hw_child
         
         hw_child_old := hw_child   
         hw_child = 0
      }
      else
      {
         if ( level = 1 )
            return, 0
     
         level--
         
         hw_parent := hw_parent_old
         

         hw_child := hw_child_old
      }
   }
}

FindWindowEx( p_hw_parent, p_hw_child, p_class, p_title=0 )
{
   if ( p_title = 0 )
      type_title = uint
   else
      type_title = str

   return, DllCall( "FindWindowEx"
                  , "uint", p_hw_parent
                  , "uint", p_hw_child
                  , "str", p_class
                  , type_title, p_title )
}
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Tue Oct 18, 2005 11:41 am    Post subject: Reply with quote

Wow, that's amazing! Thanks for posting it.
Back to top
View user's profile Send private message Send e-mail
shimanov



Joined: 25 Sep 2005
Posts: 610

PostPosted: Tue Oct 18, 2005 4:02 pm    Post subject: Reply with quote

Chris wrote:
Thanks for posting it.


Remember, it is a work in progress and review the disclaimer before running the script. It is intended to provide deanhill1971 with the best possible answer to his specific question [and further my own education].
Back to top
View user's profile Send private message
deanhill1971



Joined: 30 Sep 2005
Posts: 58
Location: Fort Wayne, IN

PostPosted: Mon Oct 24, 2005 7:26 pm    Post subject: Reply with quote

Thanks shimanov.

At a high level I understand your script, but I have a couple questions.
The script says there are 13 "buttons". Is this the number of tray icons?

The last msgbox displayed by the script shows:

-- [-1] button information --
command = 0xc
state = 0x4
data = 0x16ec80
string = 0x120528
rect = 0, 0, 18, 18
data = 0x4053c
string = ActivateTrayIcon2.ahk

How can I use this resulting info to send a right click to the icon? Also, if there are 13 buttons, how do I iterate through all 13 so I can use the "string" value to find the one I want?

Thanks for all your help.
Back to top
View user's profile Send private message
shimanov



Joined: 25 Sep 2005
Posts: 610

PostPosted: Tue Oct 25, 2005 7:03 pm    Post subject: Reply with quote

deanhill1971 wrote:
The script says there are 13 "buttons". Is this the number of tray icons?


Yes and no. The tray notification area is implemented, in part, by a standard toolbar control. The icons are visible manifestations of the buttons within that toolbar. The number of buttons/icons may be more than are actually present. This is because there may be buttons which are not visible, but are not otherwise "hidden".

Quote:
How can I use this resulting info to send a right click to the icon?


The first step was to verify the script's operation on your system. Since it is functioning normally, I have attached another script which actually implements the function requested in your original post.

Assign the PID of interest to "pid_target" and run the script.

Limitations:

* Given a PID, there is no way to unambiguously select the target icon. This may be an issue if there is more than one icon in the tray associated with a given process.
* This method requires that the icon of interest be visible in the tray, in order to properly activate the icon's associated context menu. There is another method, which permits directly informing the icon's associated window of a relevant event. The simplest implementation of such a method, will require user interaction to implement. A completely automated implementation will require external (i.e., a custom program) help.

Code:
#NoTrayIcon

DetectHiddenWindows, On

OnExit, HandleExit

pid_target = 2532

hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
if ( ErrorLevel or ! hw_notification_area )
{
   MsgBox, [error] FindWindow failed: ToolbarWindow32,Notification Area
   ExitApp
}

WinGet, pid_explorer, PID, ahk_id %hw_notification_area%
if ( ErrorLevel or ! pid_explorer )
{
   MsgBox, [error] WinGet~PID failed: explorer
   ExitApp
}

hp_explorer := DllCall( "OpenProcess"
                     , "uint", 0x18                              ; PROCESS_VM_OPERATION|PROCESS_VM_READ
                     , "int", false
                     , "uint", pid_explorer )
if ( ErrorLevel or ! hp_explorer )
{
   MsgBox, [error] OpenProcess failed: explorer
   ExitApp
}

remote_buffer_size = 0x1000
remote_buffer := DllCall( "VirtualAllocEx"
                     , "uint", hp_explorer
                     , "uint", 0
                     , "uint", remote_buffer_size
                     , "uint", 0x1000                           ; MEM_COMMIT
                     , "uint", 0x4 )                              ; PAGE_READWRITE
if ( ErrorLevel or ! remote_buffer )
{
   MsgBox, [error] VirtualAllocEx failed: explorer ~ remote_buffer
   ExitApp
}

; TB_BUTTONCOUNT
SendMessage, 0x418, 0, 0,, ahk_id %hw_notification_area%
button_count := ErrorLevel

buffer_size = 40
VarSetCapacity( buffer, buffer_size )

loop, %button_count%
{
   ; TB_GETBUTTON
   SendMessage, 0x417, A_Index-1, remote_buffer,, ahk_id %hw_notification_area%
   if ( ! ErrorLevel )
   {
      MsgBox, [error] SendMessage~TB_GETBUTTON failed: hw_notification_area
      ExitApp
   }
   
   result := DllCall( "ReadProcessMemory"
                  , "uint", hp_explorer
                  , "uint", remote_buffer
                  , "uint", &buffer
                  , "uint", buffer_size
                  , "uint", 0 )
   if ( ErrorLevel or ! result )
   {
      MsgBox, [error] ReadProcessMemory failed: explorer ~ remote_buffer (TB_GETBUTTON)
      ExitApp
   }
                  
   data_address := *( &buffer+12 )+( ( *( &buffer+13 ) ) << 8 )+( ( *( &buffer+14 ) ) << 16 )+( ( *( &buffer+15 ) ) << 24 )
   
   result := DllCall( "ReadProcessMemory"
                     , "uint", hp_explorer
                     , "uint", data_address
                     , "uint", &buffer
                     , "uint", buffer_size
                     , "uint", 0 )
   if ( ErrorLevel or ! result )
   {
      MsgBox, [error] ReadProcessMemory failed: explorer ~ data_address
      ExitApp
   }
   
   wid := *( &buffer )+( ( *( &buffer+1 ) ) << 8 )+( ( *( &buffer+2 ) ) << 16 )+( ( *( &buffer+3 ) ) << 24 )
   
   WinGet, pid, PID, ahk_id %wid%
   
   if ( pid = pid_target )
   {
      ; TB_GETITEMRECT
      SendMessage, 0x41D, A_Index-1, remote_buffer,, ahk_id %hw_notification_area%
      if ( ! ErrorLevel )
      {
         MsgBox, [error] SendMessage~TB_GETITEMRECT failed: hw_notification_area
         ExitApp
      }
      
      result := DllCall( "ReadProcessMemory"
                        , "uint", hp_explorer
                        , "uint", remote_buffer
                        , "uint", &buffer
                        , "uint", buffer_size
                        , "uint", 0 )
      if ( ErrorLevel or ! result )
      {
         MsgBox, [error] ReadProcessMemory failed: explorer ~ remote_buffer (TB_GETITEMRECT)
         ExitApp
      }
      
      WinGetPos, x, y,,, ahk_id %hw_notification_area%

      x := x+*( &buffer )+( ( *( &buffer+1 ) ) << 8 )+( ( *( &buffer+2 ) ) << 16 )+( ( *( &buffer+3 ) ) << 24 )+8
      y := y+*( &buffer+4 )+( ( *( &buffer+5 ) ) << 8 )+( ( *( &buffer+6 ) ) << 16 )+( ( *( &buffer+7 ) ) << 24 )+8
      
      CoordMode, Mouse, Screen
      MouseClick, Right, x, y, 1, 0
      
      break
   }
}
return

HandleExit:
   result := DllCall( "VirtualFreeEx"
                     , "uint", hp_explorer
                     , "uint", remote_buffer
                     , "uint", 0
                     , "uint", 0x8000 )                           ; MEM_RELEASE
   if ( ErrorLevel or ! result )
      MsgBox, [warning] VirtualFreeEx failed: explorer ~ remote_buffer
   
   result := DllCall( "CloseHandle", "uint", hp_explorer )
   if ( ErrorLevel or ! result )
      MsgBox, [warning] CloseHandle failed: explorer
ExitApp

FindWindow( p_tree )
{
   level_total = 0

   loop, parse, p_tree, |
   {
      level_total++
      
      ix := InStr( a_LoopField, "," )

      if ( ix )
      {
         StringMid, tree[%level_total%]?class, a_LoopField, 1, ix-1
         StringMid, tree[%level_total%]?title, a_LoopField, ix+1, StrLen( a_LoopField )-ix
      }
      else
      {
         tree[%level_total%]?class := a_LoopField
         tree[%level_total%]?title = 0
      }
   }
   
   hw_parent = 0
   hw_child = 0
   
   level = 1
   
   loop,
   {
      hw_child := FindWindowEx( hw_parent, hw_child, tree[%level%]?class, tree[%level%]?title )

      if ( hw_child )
      {
         if ( level = level_total )
            return, hw_child
      
         level++
         
         hw_parent_old := hw_parent
         hw_parent := hw_child
         
         hw_child_old := hw_child   
         hw_child = 0
      }
      else
      {
         if ( level = 1 )
            return, 0
      
         level--
         
         hw_parent := hw_parent_old
         
         hw_child := hw_child_old
      }
   }
}

FindWindowEx( p_hw_parent, p_hw_child, p_class, p_title=0 )
{
   if ( p_title = 0 )
      type_title = uint
   else
      type_title = str

   return, DllCall( "FindWindowEx"
                  , "uint", p_hw_parent
                  , "uint", p_hw_child
                  , "str", p_class
                  , type_title, p_title )
}
Back to top
View user's profile Send private message
deanhill1971



Joined: 30 Sep 2005
Posts: 58
Location: Fort Wayne, IN

PostPosted: Wed Oct 26, 2005 7:09 pm    Post subject: Reply with quote

Wow, that works very well shimanov. Surprised
Thanks for all your assistance.


For my own education, I have another question. The script repositions the mouse to the tray icon and does a right click. Can the right click be done without moving the mouse?

For example:
I can manually press the Windows key then Escape to get to the task bar. If I then press Tab 2-3 times, the focus moves to the tray's arrow button (that looks like "<"). Then I can Right Arrow several times to the icon I want and press the Context Menu (aka right-click) key.

I ran the following experiments:
(1) I tried the following command to set focus to the tray icon, but it doesn't work.
Code:

ControlFocus, , ahk_id %wid%


(2) I used the following command. But both the right click for the icon and the right for the Task Bar popup. The right click for the icon pops up where the mouse is currently located.
Code:

x := *( &buffer )+( ( *( &buffer+1 ) ) << 8 )+( ( *( &buffer+2 ) ) << 16 )+( ( *( &buffer+3 ) ) << 24 )+8
y := *( &buffer+4 )+( ( *( &buffer+5 ) ) << 8 )+( ( *( &buffer+6 ) ) << 16 )+( ( *( &buffer+7 ) ) << 24 )+8
ControlClick, x%x% y%y%, ahk_id %hw_notification_area%, , RIGHT
Back to top
View user's profile Send private message
hps



Joined: 19 Aug 2005
Posts: 14
Location: Germany

PostPosted: Wed Oct 26, 2005 7:16 pm    Post subject: Reply with quote

I have coded this recently to right click a icon in the notificationarea.
because it has a special color I was able to lock for a single pixel.
It works with the taskbar in all positions, even on the second screen, and if it is auto-hidden.



Code:
CoordMode,Pixel,Screen
CoordMode,Mouse,Screen
WinActivate,ahk_class Shell_TrayWnd                    ; Activate the taskbar
WinGetPos,XT,YT,,,ahk_class Shell_TrayWnd               ; Get its position
IfEqual,XT,,return
MouseMove,% XT,% YT                        ; put the mouse on it
Sleep,500                           ; Wait, perhaps it was auto-hidden
WinGetPos,XT,YT,,,ahk_class Shell_TrayWnd               ; Get its position again
ControlGetPos, X, Y, Width, Height, ToolBarWIndow321, ahk_class Shell_TrayWnd    ; get position of notification area
IfEqual,X,,return                           ; notification area not found
PixelSearch, X, Y,% X+XT,% Y+YT,% X+XT+width,% YT+Y+Height, 0x01C7FF , ,    ; search pixel in whole notification area
IfNotEqual,X,,MouseClick,right,%X%,%Y%,1,0,                ; got it, so click it right
Back to top
View user's profile Send private message
shimanov



Joined: 25 Sep 2005
Posts: 610

PostPosted: Wed Oct 26, 2005 7:56 pm    Post subject: Reply with quote

deanhill1971 wrote:
Wow, that works very well shimanov. Surprised
Thanks for all your assistance.


Cool!

Quote:
The script repositions the mouse to the tray icon and does a right click. Can the right click be done without moving the mouse?


It is unlikely. Each program provides a custom handler for events associated with its tray icon. The standard notification does not explicitly specify position. For example, AHk determines position with the following code (independent of the event context):

Code:
GetCursorPos(&pt)


Quote:
For example:
I can manually press the Windows key then Escape to get to the task bar. If I then press Tab 2-3 times, the focus moves to the tray's arrow button (that looks like "<"). Then I can Right Arrow several times to the icon I want and press the Context Menu (aka right-click) key.


Again, the behavior related to the tray icon can be highly custom. For example, AHk will only react to left-button-down, left-button-double click, and right-button-up events.

With my current understanding, to position the menu over/near its associated tray icon, it is necessary for the mouse cursor to be at that position before triggering the menu. This seems to be the minimum standard behavior.
Back to top
View user's profile Send private message
deanhill1971



Joined: 30 Sep 2005
Posts: 58
Location: Fort Wayne, IN

PostPosted: Wed Oct 26, 2005 9:53 pm    Post subject: Reply with quote

Okay.

I'll start using the script this week.

Thanks again for the help.
Back to top
View user's profile Send private message
Lemming



Joined: 20 Dec 2005
Posts: 165
Location: Malaysia

PostPosted: Mon May 01, 2006 3:29 am    Post subject: icon search instead Reply with quote

Shimanov's method probably works, but is too complicated for me. I went with hps's method instead.

hps's method involves doing a pixel search, but I've modified it to do an icon search instead.

This produces more accurate results, but you would need to find and extract the icon you're interested in first.

There are a number of icon utilities out there, but I go with IconsExtract - http://www.nirsoft.net/utils/iconsext.html (free)

What you need is the 16x16 icon embedded in the program - this is used by Windows for display in the system tray.

Save it as an ICO file, and ImageSearch will be able to look for it.
Back to top
View user's profile Send private message
Rnon
Guest





PostPosted: Mon Jul 03, 2006 11:58 am    Post subject: love the second one of Shimanov Reply with quote

Thanks Shimanov,
I just love the second script though I wanted to add one thing - if any of you is trying to use it on a wink2 machine - at least in my case the win 2k machines couldn't run it.
Back to top
OrelseIamfired



Joined: 13 Mar 2006
Posts: 65
Location: Ottawa, Canada

PostPosted: Wed Jul 05, 2006 7:02 pm    Post subject: Reply with quote

Hi Rnon,

Try changing
Code:
hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
to
Code:
  if A_OSVersion = WIN_XP
    hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
  else
    hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|ToolbarWindow32" )

/ Louis
Back to top
View user's profile Send private message
Display posts from previous:   
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