Jump to content

Last.FM to Ventrilo Comment Integration


Recommended Posts

CODE
Opt("WinTitleMatchMode", 4)

$lastfm = WinGetTitle("[CLASS:QWidget","")

Func TitleUpdate()

ControlClick("Ventrilo", "Comment", 1060)

sleep(500)

ControlSend("Comment - Advanced ", "", "", $lastfm & "Last.FM")

sleep(500)

ControlClick("Comment - Advanced", "OK", 1)

sleep(4000)

EndFunc

While 1

TitleUpdate()

wend

Here I thought it was just simple enough to work. The Last.FM Player window is the only thing I have up with the QWidget as it's class, but the Title changes depending on the song. I thought this would be the right way to go about things using the WinTitleMatchMode 4...

Thoughts?

Link to comment
Share on other sites

CODE
Opt("WinTitleMatchMode", 2)

$lastfm = WinGetTitle("")

Global $Paused

HotKeySet("{ESC}", "TogglePause")

Func TogglePause()

$Paused = NOT $Paused

While $Paused

ToolTip("Press ESC to continue or ALT+ESC to stop the script.",0,0)

HotKeySet("!{ESC}", "Exitt")

sleep(100)

WEnd

ToolTip("")

EndFunc

Func Exitt()

Exit

EndFunc

Func TitleUpdate()

ControlClick("Ventrilo", "Comment", 1060)

sleep(500)

$lastfm = WinGetTitle("")

ControlSend("Comment - Advanced ", "", "", $lastfm & " @ Last.FM" )

sleep(500)

ControlClick("Comment - Advanced", "OK", 1)

sleep(4000)

EndFunc

While 1

$lastfm = WinGetTitle("")

TitleUpdate()

wend

So this will have to do. I didn't want to use the substring match mode, but it turns out the - is different than most others. - , slightly longer. Should work fine. However, now I just have the issue of it going into the most recent Ventrilo instance running, and I can't find any distinguishing factor between the two to modify it. This works at the moment for a single vent instance if you feel like broadcasting what you're listening to. I was setting it up for a vent music bot, and whenever I touch my instance, it changes my comment instead of the bot.

Ah well. :)

Link to comment
Share on other sites

Horrible with conditions and loops, but would there be a way to have it do the title update only when it needs to be changed? I was fiddling around with it last night for a while, but I couldn't come up with a good way of doing it. Keep in mind it's using Opt("WinTitleMatchMode", 2) which is for any part of the requested string.

I think I was along the right lines with storing the result of $lastfm into a second variable, then checking the second variable against the WinGetTitle result and updating or sleeping if necessary. I just couldn't get my head around it correctly.

Link to comment
Share on other sites

CODE
Opt("WinTitleMatchMode", 4)

$lastfm = WinGetTitle("[CLASS:QWidget","")

Func TitleUpdate()

ControlClick("Ventrilo", "Comment", 1060)

sleep(500)

ControlSend("Comment - Advanced ", "", "", $lastfm & "Last.FM")

sleep(500)

ControlClick("Comment - Advanced", "OK", 1)

sleep(4000)

EndFunc

While 1

TitleUpdate()

wend

Here I thought it was just simple enough to work. The Last.FM Player window is the only thing I have up with the QWidget as it's class, but the Title changes depending on the song. I thought this would be the right way to go about things using the WinTitleMatchMode 4...

Thoughts?

The advance window title match mode works by default without having to declare WinTitleMatchMode=4, since several version ago.

Your match string is badly formatted (missing closing square bracket"]").

Instead of getting the title, get the handle with WinGetHandle() and use that from that point on. Even if the title changes, the handle should remain constant.

I don't use that app, so I don't have any idea what the rest of your posts are about.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The advance window title match mode works by default without having to declare WinTitleMatchMode=4, since several version ago.

Your match string is badly formatted (missing closing square bracket"]").

Instead of getting the title, get the handle with WinGetHandle() and use that from that point on. Even if the title changes, the handle should remain constant.

I don't use that app, so I don't have any idea what the rest of your posts are about.

:)

Yeah, I probably caught the bracket thing amidst the hour I was working with it.

www.last.fm

Last.FM has a dedicated player that displays the artist and song title in the window title. I couldn't find any text within the app itself, so I was grabbing for the title instead, and sending it to Ventrilo as the comment for the bot playing the music. Even if I go for the handle to grab the app, I still want the Title, as that contains the relevant information and appeared to be the easiest way to hook onto it.

That being so, I should be able to use WinGetHandle("[CLASS:QWidget]","") and have the Title as the result?

OR would I need to WinGetHandle("0x00000000") based on the HWND of the window itself?

I think the reason I passed over that in the help file was because it appeared to need the title/text to search for, the example itself doesn't use it like that. If the second instance there is how it works, retrieving the title based off the HWND hex, that'd be great. I'll give it a shot when I get home.

Edited by Silverel
Link to comment
Share on other sites

Yeah, I probably caught the bracket thing amidst the hour I was working with it.

www.last.fm

Last.FM has a dedicated player that displays the artist and song title in the window title. I couldn't find any text within the app itself, so I was grabbing for the title instead, and sending it to Ventrilo as the comment for the bot playing the music. Even if I go for the handle to grab the app, I still want the Title, as that contains the relevant information and appeared to be the easiest way to hook onto it.

That being so, I should be able to use WinGetHandle("[CLASS:QWidget]","") and have the Title as the result?

OR would I need to WinGetHandle("0x00000000") based on the HWND of the window itself?

I think the reason I passed over that in the help file was because it appeared to need the title/text to search for, the example itself doesn't use it like that. If the second instance there is how it works, retrieving the title based off the HWND hex, that'd be great. I'll give it a shot when I get home.

Everywhere you see the window title used to identify a window in the native functions, you can put the handle instead:
Global $hWin, $sTitle, $sTemp

$hWin = WinGetHandle("[CLASS:QWidget]", "")
$sTitle = WinGetTitle($hWin, "")
ConsoleWrite("Title = " & $sTitle & @LF)

While WinExists($hWin, "")
    $sTemp = WinGetTitle($hWin, "")
    If $sTemp <> $sTitle Then
        $sTitle = $sTemp
        ConsoleWrite("Changed title = " & $sTitle & @LF)
    EndIf
    Sleep(100)
WEnd

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Everywhere you see the window title used to identify a window in the native functions, you can put the handle instead:

Global $hWin, $sTitle, $sTemp

$hWin = WinGetHandle("[CLASS:QWidget]", "")
$sTitle = WinGetTitle($hWin, "")
ConsoleWrite("Title = " & $sTitle & @LF)

While WinExists($hWin, "")
    $sTemp = WinGetTitle($hWin, "")
    If $sTemp <> $sTitle Then
        $sTitle = $sTemp
        ConsoleWrite("Changed title = " & $sTitle & @LF)
    EndIf
    Sleep(100)
WEnd

:)

Not sure why, but all that did was return "Diagnostics" when looking for the QWidget class. Manually assigning the HWND works just fine.

I did manage to use the HWND to keep the second ventrilo instance in check as well.

It's a bit goofy to assign it manually, but at least it works this way, they're be running all the time anyways, and I can reset them once every couple days as needed.

Thanks for the help! This is about as finished as I need. :)

CODE
Opt("WinTitleMatchMode", 2)

Global $lastfm, $previous, $Paused, $hwndvent, $hwndlast

HotKeySet("{ESC}", "TogglePause")

Func TogglePause()

$Paused = NOT $Paused

While $Paused

ToolTip("Press ESC to continue or ALT+ESC to stop the script.",0,0)

HotKeySet("!{ESC}", "Exitt")

sleep(100)

WEnd

ToolTip("")

EndFunc

Func Exitt()

Exit

EndFunc

Func TitleUpdate()

$hwndvent = (HWND(0x0001098C))

$hwndlast = (HWND(0x00040828))

ControlClick($hwndvent, "Comment", 1060)

sleep(500)

$lastfm = WinGetTitle($hwndlast)

ControlSend("Comment - Advanced ", "", "", $lastfm & " @ Last.FM" )

sleep(500)

ControlClick("Comment - Advanced", "OK", 1)

sleep(4000)

$previous = $lastfm

EndFunc

While 1

if $previous = WinGetTitle($hwndlast) Then

Sleep (10000)

Else

TitleUpdate()

EndIf

wend

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...