You are not logged in.
Hi Denis,
Just came up with ideas for the following new events:
I see you have a general event for Process start/stop, and one specifically for Winamp stops. I suppose the latter triggers when playback ends in Winamp? I actually stopped using Winamp years ago and switched to foobar2000. Unfortunately, the normal Process stop event fails to detect the end of playback in fb2k. Would it be possible to add another event for this? (Best of all would be a generic way to detect end of playback in any audio/video player, but I don't think this is possible, right?)
It would be simply fantastic to have an event that's triggered when the laptop lid is closed. That way, one can automatically launch something like a defrag utility or torrent client, or maybe mute the sound or do anything else one wishes whenever the lid is closed! I think the possibilities would be endless, and this would be a very useful option indeed. I even did some research into this and found a few pages (1, 2, 3 and comments, 4) that discuss how this can be done. That last link even has sample (C++?) code and an app (that someone in the comments managed to convert to VB.Net), but unfortunately both versions simply lock on lid close and don't have the ability to execute any other user-selected event like Shutter does.
Of course, if the lid close event is added I don't think one for lid open would be too difficult either.
Thanks, and I'm really looking forward to hearing what you think of these.
Last edited by Andrew (2013-02-24 02:19)
Offline
Hi Andrew,
I did a quick search for foobar2000 API and found SDK and command line options so far. Unfortunately, the SDK is for a different development environment and command line options can perform actions like add files, play/stop, but can't query the state of the playback.
Winamp has an API which can be easily accessed using standard messages via SendMessage() function of Windows API. This allows any application to easily integrate with Winamp. foobar2000 doesn't have this kind of interface. I did find this interesting plugin for foobar2000 which actually mimics the Winamp API: foo_winamp_spam.
Can you try this plugin and check it Shutter's event work with it?
I need to do a bit more research on the laptop lid closing, a bit later.
Offline
Thanks for the research Denis. foo_winamp_spam seems pretty old (last version dates back to 2007), so I'm not even sure whether it works properly with the latest version of foobar (there have been major API changes since then and old plugins broke around the time fb2k 1.0 was released). I will check it out, but I think there should be a better way to do this. I'll ask on their forum - surely someone will know what to do.
There's one thing that occurred to me though. In fb2k the titlebar, statusbar and tray icon tooltip text are all fully configurable. For example, my titlebar text is set to:
[%album artist% - ]['['%album%[ CD%discnumber%][ #%tracknumber%]']' ]%title%[ '//' %track artist%]
So when a song is playing, the titlebar looks something like this:
But when there's no song playing or playback ends, the titlebar text reverts to the default:
Is it possible to search for the appropriate window handle, detect this text and accordingly act upon it? Could be an easy way to accomplish this. What do you think?
Offline
This is a bit of a homebrew, but it should work for you.
Set your custom title in foobar and then add "Window" event in Shutter to be triggered when window closes matching window name: [foobar2000*]. Shutter will periodically check whether a window with the specified name exists. This will allow you to detect when foobar has stopped/start the playback.
We can't really make it a general event as we are dependent on the custom title of the foobar window.
Offline
Regarding the "closing the lid" idea...
I made a small test application which monitors for power related system notifications and logs them on screen and in a file (in the same directory as exe). However, I can't test the lid related events as I don't have a laptop with Windows Vista/7/8 installed on it (lid events are available on Vista and later releases).
Can someone test it and post here the log file?
http://www.den4b.com/temp/PowerTest.zip
Run the application, then, close the lid, wait few seconds, open the lid, send me the log file.
Offline
Set your custom title in foobar and then add "Window" event in Shutter to be triggered when window closes matching window name: [foobar2000*]. Shutter will periodically check whether a window with the specified name exists. This will allow you to detect when foobar has stopped/start the playback.
Thanks, but looks like my titlebar text detection idea wasn't optimal. Problem is that I normally run foobar (just like I did Winamp) minimized as a tray icon, so window title text detection doesn't work. As long as the window's on-screen this option works ok though, so at least that's something. Any way to work around this issue?
I made a small test application which monitors for power related system notifications and logs them on screen and in a file (in the same directory as exe). However, I can't test the lid related events as I don't have a laptop with Windows Vista/7/8 installed on it (lid events are available on Vista and later releases).
Can someone test it and post here the log file?
I will have access to a Windows 7 laptop later so will definitely run the program and post the log here. Thanks for looking into this!
Offline
Thanks, but looks like my titlebar text detection idea wasn't optimal. Problem is that I normally run foobar (just like I did Winamp) minimized as a tray icon, so window title text detection doesn't work. As long as the window's on-screen this option works ok though, so at least that's something. Any way to work around this issue?
Have you tried with it open? I made tests without minimizing, and it (*[foobar2000*]) detects when it opens, but not when it closes. Strange, because with other programs doesn't happen this...
Also, did you notice that opening a square bracket but not closing it causes an error? but not a single error, one error each check!
If this software has helped you, consider getting your pro version. :)
Offline
I completely forgot that square brackets [ and ] are used to define character sets in masks.
Basically, the mask the[foobar]test will be matched against theftest, theotest, etc.
If we want to use the sqaure brackets as actual characters we must put them as a character set, i.e. [[] and []].
Offline
Have you tried with it open? I made tests without minimizing, and it (*[foobar2000*]) detects when it opens, but not when it closes. Strange, because with other programs doesn't happen this...
I think I completely forgot the square brackets! I simply tried with foobar2000* on window open, and as long as the window's on-screen this option works ok. When foobar's minimized to the tray though, the detection routine fails. Perhaps this can be fixed?
BTW Denis, here's the log:
[03:47:54.180] Application started
[03:47:54.180] Log: D:\PowerTest.txt
[03:47:54.180] Power library loaded: True
[03:47:54.180] Found RegisterPowerSettingNotification: True
[03:47:54.180] Found UnregisterPowerSettingNotification: True
[03:47:54.190] Registered GUID_MONITOR_POWER_ON: True
[03:47:54.190] Registered GUID_VIDEO_POWERDOWN_TIMEOUT: True
[03:47:54.190] Registered GUID_LIDCLOSE_ACTION: True
[03:47:54.190] Registered GUID_LIDSWITCH_STATE_CHANGE: True
[03:47:54.250] =================================
[03:47:54.250] PBT_POWERSETTINGCHANGE
[03:47:54.250] GUID_MONITOR_POWER_ON
[03:47:54.250] GUID: {02731015-4510-4526-99E6-E5A17EBD1AEA}
[03:47:54.260] DataLength: 4
[03:47:54.260] Data: 01000000
[03:47:54.270] =================================
[03:47:54.270] PBT_POWERSETTINGCHANGE
[03:47:54.270] GUID_VIDEO_POWERDOWN_TIMEOUT
[03:47:54.280] GUID: {3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E}
[03:47:54.280] DataLength: 4
[03:47:54.280] Data: 3C000000
[03:47:54.290] =================================
[03:47:54.290] PBT_POWERSETTINGCHANGE
[03:47:54.300] GUID_LIDCLOSE_ACTION
[03:47:54.310] GUID: {5CA83367-6E45-459F-A27B-476B1D01C936}
[03:47:54.320] DataLength: 4
[03:47:54.330] Data: 00000000
[03:47:54.330] =================================
[03:47:54.340] PBT_POWERSETTINGCHANGE
[03:47:54.350] GUID_LIDSWITCH_STATE_CHANGE
[03:47:54.350] GUID: {BA3E0F4D-B817-4094-A2D1-D56379E6A0F3}
[03:47:54.360] DataLength: 4
[03:47:54.370] Data: 01000000
[03:47:59.863] =================================
[03:47:59.863] PBT_POWERSETTINGCHANGE
[03:47:59.863] GUID_LIDSWITCH_STATE_CHANGE
[03:47:59.879] GUID: {BA3E0F4D-B817-4094-A2D1-D56379E6A0F3}
[03:47:59.879] DataLength: 4
[03:47:59.879] Data: 00000000
[03:48:13.537] =================================
[03:48:13.537] PBT_POWERSETTINGCHANGE
[03:48:13.552] GUID_LIDSWITCH_STATE_CHANGE
[03:48:13.552] GUID: {BA3E0F4D-B817-4094-A2D1-D56379E6A0F3}
[03:48:13.552] DataLength: 4
[03:48:13.568] Data: 01000000
[03:49:33.434] Application is closing
Hope that helps!
Offline
Thanks for the log Andrew!
Lid notifications seem to be working fine and I will be able to add it as an event.
Offline