|
cuprohastes Wanderer
Joined: 22 Oct 2006 Posts: 92
|
Posted: Sat Dec 15, 2007 5:23 pm
Snarl and Out of Focus scripts |
I'm running Snarl from http://www.fullphat.net/ - it's a pop up notifications system. There's a command line tool you can use to send pop ups using the format:
Code: |
$path$/sncmd /m "Popup title" "Textline 1/n Textline2 /n Textline3" /t n |
Where n is the number of seconds for the pop up to time out and vanish after.
So I have an alias for testing:
Code: |
#launch "C:\Program Files\full phat\Snarl\sncmd /m "%1" "%2"" |
Which works fine. Typing:
results in a pop up - just fine!
Now: How do I make a trigger that will send me a pop up, but only when CMUD is not in focus? I don't want it firing while I'm looking - I want it to pop up while I'm not, to tell me there's activity! |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Sat Dec 15, 2007 6:41 pm |
Not really, the best I can think of is to trigger on %iconstate but you will still get some false positives while looking at it. The icon state goes green when there's a window that has received text that you haven't given focus to as yet.
|
|
_________________ Asati di tempari! |
|
|
|
cuprohastes Wanderer
Joined: 22 Oct 2006 Posts: 92
|
Posted: Sat Dec 15, 2007 6:58 pm |
Perhaps Zugg can be persuaded to do something about that - An OnFocus or OffFocus Event Type?
|
|
|
|
iljhar GURU
Joined: 10 Oct 2000 Posts: 1116 Location: USA
|
Posted: Tue Dec 18, 2007 5:55 pm |
okay, this is a hack, but it works.
1. Install AutoHotKey
2. Create an ahk file, I named mine snarl.ahk. Put this inside it and save:
Code: |
#NoTrayIcon
#Persistent
#SingleInstance, force
#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.
WinGetActiveTitle, a_t
Loop, %0% {
StringReplace, msg, %A_Index%, |n, \n, All
}
If !(InStr(a_t, "CMUD")) {
Run, C:\Program Files\full phat\Snarl\extras\sncmd\snarl_command.exe /m %1% %msg%
}
ExitApp |
3. Create a new trigger in CMUD (or update your old trigger). This is what I have:
#trigger {(%w) gossips-- '(*)'} {#launch "c:\snarl.ahk "%1" "%2""}
In the ahk file, you'll notice I send arguments to snarl based on the arguments from the trigger in CMUD. If you just want to have a generic message pop up, then just launch your ahk file and change the arguments in the ahk to whatever message you want. One thing I noticed is that running the command line briefly pops up a console window. I'm not sure if there's a way to stop that, but since I don't use it, I won't bother trying to fix it. ;)
Oh yeah, I also noticed that \n was not being passed correctly, so I passed |n and replaced it inside the ahk file, but if you don't deal with newlines, then you won't have to worry about it. |
|
|
|
Rainchild Wizard
Joined: 10 Oct 2000 Posts: 1551 Location: Australia
|
Posted: Tue Dec 18, 2007 11:11 pm |
I was going to suggest using VBScript to query the Windows API directly but the following declares don't seem to work :\
Code: |
Private Declare Function GetForegroundWindow Lib "user32" () as Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (byval hwnd as Long, byval lpString as string, byval cch as Long) as Long |
I get a compile error "Expected end of statement [Microsoft VBScript compilation error]" so it doesn't look feasable to support it "natively". Then again, maybe one of the guru's can tell us how to get access to the Windows API in which case it should be easy to pull off. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|