Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Click a tray icon


  • Please log in to reply
5 replies to this topic
Grateful user
  • Guests
  • Last active:
  • Joined: --
Hi,

I needed to just click a tray icon (of a plugin that deletes the song currently playing in winamp) and then have the mouse in the initial position. Searching this excellent forum I found relevant scripts, yet none of them did exactly that simple function. Although I'm not very familiar with the syntax I managed to combine and arrange elements of various scripts, and I post here the result, a short, simple, script, in case someone else needs it.

Warm congratulations on AutoHotKey and its Community.


; the number of the tray icon that you need to click, followed by a space and then the filename containing the icon :

iconstr = 3 C:\Program Files\Winamp\Plugins\gen_delete.dll 

;replace this with your filename. I used beardboys Icon Browser - http://www.autohotkey.com/forum/viewtopic.php?t=5587&highlight=iconviewer - to find the icon inside the dll

   coordmode, mouse, screen
   MouseGetPos, mouseX, mouseY
   coordmode, pixel, screen
   WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd
   ImageSearch, imageX, imageY, trayX, trayY, trayX+trayWidth, trayY+trayHeight, *Icon%iconstr%
MouseMove,%imageX%,%imageY%,0    
MouseClick,left,%imageX%,%imageY%,1,0
   MouseMove,%mouseX%,%mouseY%,0 
Return



Best wishes

George

FrankCh
  • Guests
  • Last active:
  • Joined: --
I downloaded autohotkey and I need to use this click tray icon script, but I don't know how to do it. Can you tell me what to do?

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Follow the tutorial.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


Grateful user
  • Guests
  • Last active:
  • Joined: --
Hi Frank,

Here is how I use this script. You can do the same if you can't understand the tutorial. First copy the script above into a txt file, and then add two more lines

To the very top add:

#singleinstance


To the bottom add:

Exit


Save this file as e.g. "ClickTrayDeleter.ahk" or however you like. Don't forget that the file must have the extension "ahk", not txt. Then open AutoHotkey.ahk, the file that is used by the main AutoHotKey application. You can access this file by right clicking the AutoHotKey tray icon and choosing the option "Edit this script". In that file add a line

#=::Run, "c:\ahkscripts\ClickTrayDeleter.ahk"

Replace c:\ahkscripts\ with the location in your computer where you saved the deleter script. Save, Close and Reload AutoHotkey.ahk (right click the main ahk tray icon and select the "Reload this script" option).

From now on, supposing that AutoHotKey starts whenever you open your computer, you will be able to run the deleter script by pressing the WinKey and =. You can change this shortcut to whatever is convenient for you.

hardcider09
  • Members
  • 15 posts
  • Last active: Jan 08 2010 02:14 PM
  • Joined: 26 Mar 2009
Hi, I'm a newbie trying to use this script.

When I ran beardboys Icon Browser on the .exe file with the icon, I got: IconFileName = C:\Program Files\TeamScope\Linker for Windows\Linker for Windows.exeIL_Add(ImageListID1, IconFileName, 1)
Gui,add, pic, Icon1, C:\Program Files\TeamScope\Linker for Windows\Linker for Windows.exe

So the icon number is: 1

And the file name that contained the icon is: C:\Program Files\TeamScope\Linker for Windows\Linker for Windows.exe

Correct?

I made #I be the hotkey for the script. So my script is as follows:


;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#I::

; the number of the tray icon that you need to click, followed by a space and then the filename containing the icon :

iconstr = 1 C:\Program Files\TeamScope\Linker for Windows\Linker for Windows.exe


;replace this with your filename. I used beardboys Icon Browser - http://www.autohotkey.com/forum/viewtopic.php?t=5587&highlight=iconviewer - to find the icon inside the dll

   coordmode, mouse, screen
   MouseGetPos, mouseX, mouseY
   coordmode, pixel, screen
   WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd
   ImageSearch, imageX, imageY, trayX, trayY, trayX+trayWidth, trayY+trayHeight, *Icon%iconstr%
MouseMove,%imageX%,%imageY%,0   
MouseClick,left,%imageX%,%imageY%,1,0
   MouseMove,%mouseX%,%mouseY%,0
Return


But when I run it by pressing #I, nothing seems to happen.

What am I doing wrong?

Dogway
  • Members
  • 39 posts
  • Last active: Jan 04 2015 01:48 AM
  • Joined: 04 Feb 2012
Thank you! works for me, I added Alt+Tab at the end so it goes back to winamp where you can keep using all the playback shortcuts:
#singleinstance 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; ctrl+<
^<::

; the number of the tray icon that you need to click, followed by a space and then the filename containing the icon :

iconstr = 3 C:\Archivos de Programa\Winamp\Plugins\gen_delete.dll

;replace this with your filename. I used beardboys Icon Browser - http://www.autohotkey.com/forum/viewtopic.php?t=5587&highlight=iconviewer - to find the icon inside the dll

   coordmode, mouse, screen
   MouseGetPos, mouseX, mouseY
   coordmode, pixel, screen
   WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd
   ImageSearch, imageX, imageY, trayX, trayY, trayX+trayWidth, trayY+trayHeight, *Icon%iconstr%
MouseMove,%imageX%,%imageY%,0   
MouseClick,left,%imageX%,%imageY%,1,0
   MouseMove,%mouseX%,%mouseY%,0

Send, {ALT DOWN}{TAB}{ALT UP}
Return

exit

Just one note though, it has conflicts with TaskBarShuffle, so you better kill that process beforehand.