Thank you for posting the examples SKAN. This may be a dumb question, but by "dependency" do you mean that anyone who uses your examples should "#include" the dependency too, or is there some other (better) way/command to call the linked function?
I'm trying your method out with
Ghost-It, a tiny stand-alone system tray based utility for making windows translucent.
But I have 2 issues:
1. There's an unusually long delay (~5 sec) until the penultimate line of my code below is implemented. That is, Ghost-It's tray menu pops up as soon as I hit the hotkey (Ctrl+Win+RightClick), but AHK does not "SEND {DOWN 2}{ENTER}" to the menu for another 5 seconds; I can click 'Un-Ghost' or press down-down-enter to select it faster myself. What's wrong with the code?
#Include TrayIcon.ahk
^#LBUTTON:: ; Ctrl + Win + Left-Click to ghost
IfWinNotExist, ahk_class _GhostIt_Class
{
Run, "C:\Program Files\ghostit\GhostIt.exe"
Sleep, 200
TI := TrayIcons( "GhostIt.exe" )
StringSplit,TIV, TI, |
uID := RegExReplace( TIV4, "uID: " )
Msg := RegExReplace( TIV5, "MessageID: " )
hWnd := RegExReplace( TIV6, "hWnd: " )
}
SendMessage, Msg, uID,0x203,, ahk_id %hWnd% ; Dbl Left-Click
Return
^#LBUTTON:: ; Ctrl + Win + Right-Click to un-ghost
SendMessage, Msg, uID,0x204,, ahk_id %hWnd% ; Right-Click down
SendMessage, Msg, uID,0x205,, ahk_id %hWnd% ; Right-Click Up
Send {DOWN 2}{ENTER} ; select Un-Ghost from pop-up menu
Return2. TrayIcon.ahk popup: How do I dismiss it automatically? And for that matter, am I using TrayIcon.ahk correctly by including it at the start of the script, or is there a better way?
I mean, if I run TrayIcon first to look up the values for Ghost-It's uID (10001), Msg (1224) and hWnd (2490766), then all I need is the code below:
DetectHiddenWindows, On
^#LBUTTON::SendMessage, 1224, 10001,0x203,, ahk_id 2490766
^#RBUTTON::
SendMessage, 1224, 10001,0x204,, ahk_id 2490766
SendMessage, 1224, 10001,0x205,, ahk_id 2490766
Send {DOWN 2}{ENTER}
ReturnThe problem is that hWnd changes each time I restart Ghost-It, so that's why I've included TrayIcon.ahk in the script. But since it wasn't explicitly "included" in the other examples I've seen, I'm wondering if that's just something that's assumed to be obvious, or whether I missed something because I'm new to the forum and new to AHK?