 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Grateful user Guest
|
Posted: Thu Sep 13, 2007 4:49 pm Post subject: Click a tray icon |
|
|
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 |
|
| Back to top |
|
 |
FrankCh Guest
|
Posted: Thu Oct 04, 2007 3:03 pm Post subject: How to use the click a tray icon script |
|
|
| 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? |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5438 Location: /b/
|
Posted: Thu Oct 04, 2007 3:35 pm Post subject: |
|
|
Follow the tutorial. _________________
 |
|
| Back to top |
|
 |
Grateful user Guest
|
Posted: Sat Oct 06, 2007 9:51 am Post subject: Click a tray icon |
|
|
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. |
|
| Back to top |
|
 |
hardcider09
Joined: 26 Mar 2009 Posts: 6
|
Posted: Tue Jun 02, 2009 10:57 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|