AutoHotkey Community

It is currently May 25th, 2012, 5:06 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Click a tray icon
PostPosted: September 13th, 2007, 4:49 pm 
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.

Code:

; 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


Report this post
Top
  
Reply with quote  
PostPosted: October 4th, 2007, 3:03 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2007, 3:35 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
Follow the tutorial.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Click a tray icon
PostPosted: October 6th, 2007, 9:51 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 2nd, 2009, 10:57 am 
Offline

Joined: March 26th, 2009, 4:41 am
Posts: 15
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:

Code:

;
; 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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: toddintr, Wicked and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group