Jump to content

_IEImgClick on a image that works as multiple buttons


Recommended Posts

So last time i tried this it didnt work.

And thats cause i dont know what settings to use.

This is the image i want clicked:

Posted Image

But as you can see, this image is used on multiple buttons.

I want to be able to rigth click the tray and click Play/Pause, Previous or Next.

And thats not the problem.

The problem is separating the buttons from each other...

Changing the instance number didnt help last time.

Either i have done something wrong or there is something i just dont understand.

Edit:

I forgot to add the code :huh2:

But now i cant find it

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

This is what I've got so far.

_SetVolume doesn't work.

#AutoIt3Wrapper_Icon=grooveshark.ico
#AutoIt3Wrapper_UseX64=n
#include<ie.au3>
Opt('GuiOnEventMode', 1)
Opt('GUIResizeMode', 102)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

;Create tray items.
$Dummy = TrayCreateItem('Nothing playing')
TrayItemSetState($Dummy, 128)
TrayCreateItem('')

$sStr = StringSplit('Play|Next|Previous||Shuffle|Repeat||Exit', '|')
For $i = 1 To $sStr[0]
    TrayCreateItem($sStr[$i])
    If $sStr[$i] Then TrayItemSetOnEvent(-1, '_' & $sStr[$i])
Next

TraySetClick(8)
TraySetOnEvent(-8, '_GuiMini')

;Set hotkeys.
HotKeySet('!d', '_Debug')
;HotKeySet('{ESC}', '_Exit2')
HotKeySet('{MEDIA_PLAY_PAUSE}', '_Play')
HotKeySet('{MEDIA_NEXT}', '_Next')
HotKeySet('{MEDIA_PREV}', '_Prev')

;Variables.
Global $oIE, $hGUI, $bActive = False, $oArtist = 'Artist', $oSong = 'Song', $sCurrent
Global Const $iWidth = 800, $iHeight = 500, $iPid = @AutoItPID

;Create Gui.
$oIE = _IECreateEmbedded()
$hGUI = GUICreate('Grooveshark', $iWidth, $iHeight, -1, -1, BitOR(0x00010000, 0x00020000))
$oCtrl = GUICtrlCreateObj($oIE, -2, -2, $iWidth + 178, $iHeight - 24)
GUISetOnEvent(-3, '_Exit')
GUISetOnEvent(-4, '_GuiMini')
GUISetState()

_IENavigate($oIE, 'http://grooveshark.com')

;Media control.
Func _Next()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oNext = _IEGetObjByName($oIE, 'player_next')
    _IEAction($oNext, 'click')
EndFunc   ;==>_Next
Func _Play()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPlay = _IEGetObjByName($oIE, 'player_play_pause')
    _IEAction($oPlay, 'click')
EndFunc   ;==>_Play
Func _Prev()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPrev = _IEGetObjByName($oIE, 'player_previous')
    _IEAction($oPrev, 'click')
EndFunc   ;==>_Prev
Func _Shuffle()
    $oShuffle = _IEGetObjByName($oIE, 'player_shuffle')
    _IEAction($oShuffle, 'click')
EndFunc   ;==>_Shuffle
Func _Repeat()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oRepeat = _IEGetObjByName($oIE, 'player_loop')
    _IEAction($oRepeat, 'click')
EndFunc   ;==>_Repeat
Func _GetVolume()
;~  <A style="BOTTOM: 0%" class="ui-slider-handle ui-state-default ui-corner-all" href="#" jQuery15107891455831978822="11"></A>
    $hfind = _IETagNameGetCollection($oIE, "A")
    For $h In $hfind
        If String($h.className) = "ui-slider-handle ui-state-default ui-corner-all" Then
            $iVol = StringRegExp(_IEPropertyGet($h, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', 1)
            If IsArray($iVol) Then
                $iVol = $iVol[0]
                ConsoleWrite($iVol & @CRLF)
                Return $iVol
            Else
                Return -1
            EndIf
            ExitLoop
        EndIf
    Next
    Return -1

EndFunc   ;==>_GetVolume
Func _SetVolume($iVol)
    $oTags = _IETagNameGetCollection($oIE, "div")
    For $oTag In $oTags
        If String($oTag.id) = "volumeSlider" Then
            $iVol = StringRegExpReplace(StringRegExpReplace(_IEPropertyGet($oTag, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', '"BOTTOM: ' & $iVol & '%";', 1), '["]HEIGHT:.(.*?)%["]', '"HEIGHT: ' & $iVol & '%";', 1)
            _IEPropertySet($oTag, 'outerhtml', $iVol)
            ConsoleWrite($iVol & @CRLF)
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_SetVolume

;GUI.
Func _GuiMini()
    $bActive = ($bActive = False)
    If $bActive Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>_GuiMini

;Misc.
Func _Debug()
    ;~  _SetVolume(50)
EndFunc   ;==>_Debug
Func _Exit()
    Exit
EndFunc   ;==>_Exit
Func _Exit2()
    If WinActive($hGUI) Then Exit
EndFunc   ;==>_Exit2
Func _RM()
    Local $ai = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid)
    $ai = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai[0])
EndFunc   ;==>_RM

;Reduce memory usage every 5 seconds.
AdlibRegister('_RM', 5000)

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next
    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($Dummy, $sCurrent)
        ;Toast?
    EndIf
    Sleep(1000)
WEnd
Link to comment
Share on other sites

Whoah!

Thats awesome, but way to much :huh2:

I only need play/pause, next and previous...

But now i might have to include all.

I dont want your work to not be used!

But seriously, THATS AWESOME!!

Thank you!

Im gonna check trough the code when i get time.

I have oral exam prep and the oral exam itself next 3-4 day.

But this is just... awesome... i need to extend my vocabulary ;)

Ill read trough the code and tweak it until i love it, but im gonna learn alot from this!

Thank... wait for it... you!!!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

#AutoIt3Wrapper_Icon=grooveshark.ico
#AutoIt3Wrapper_UseX64=n
#include<ie.au3>
Opt('GuiOnEventMode', 1)
Opt('GUIResizeMode', 102)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)

;Create tray items.
$Dummy = TrayCreateItem('Nothing playing')
TrayItemSetState($Dummy, 128)
TrayCreateItem('')

$sStr = StringSplit('Play|Next|Previous||Shuffle|Repeat||Exit', '|')
For $i = 1 To $sStr[0]
    TrayCreateItem($sStr[$i])
    If $sStr[$i] Then TrayItemSetOnEvent(-1, '_' & $sStr[$i])
Next

TraySetClick(8)
;TraySetOnEvent(-8, '_GuiMini')

;Set hotkeys.
HotKeySet('!d', '_Debug')
;HotKeySet('{ESC}', '_Exit2')
HotKeySet('{MEDIA_PLAY_PAUSE}', '_Play')
HotKeySet('{MEDIA_NEXT}', '_Next')
HotKeySet('{MEDIA_PREV}', '_Prev')

;Variables.
Global $oIE, $hGUI, $bActive = False, $oArtist = 'Artist', $oSong = 'Song', $sCurrent
Global Const $iWidth = (@DesktopWidth/2 + @DesktopWidth/100*25), $iHeight = (@DesktopHeight/2 + @DesktopHeight/100*25), $iPid = @AutoItPID

;Create Gui.
$oIE = _IECreateEmbedded()
$hGUI = GUICreate('Grooveshark', $iWidth, $iHeight, -1, -1, BitOR(0x00010000, 0x00020000))
$oCtrl = GUICtrlCreateObj($oIE, -2, -2, $iWidth + 178, $iHeight - 24)
GUISetOnEvent(-3, '_Exit')
;GUISetOnEvent(-4, '_GuiMini')
_IENavigate($oIE, 'http://grooveshark.com')
GUISetState()



;Media control.
Func _Next()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oNext = _IEGetObjByName($oIE, 'player_next')
    _IEAction($oNext, 'click')
EndFunc   ;==>_Next


Func _Play()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPlay = _IEGetObjByName($oIE, 'player_play_pause')
    _IEAction($oPlay, 'click')
EndFunc   ;==>_Play


Func _Prev()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPrev = _IEGetObjByName($oIE, 'player_previous')
    _IEAction($oPrev, 'click')
EndFunc   ;==>_Prev


Func _Shuffle()
    $oShuffle = _IEGetObjByName($oIE, 'player_shuffle')
    _IEAction($oShuffle, 'click')
EndFunc   ;==>_Shuffle


Func _Repeat()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oRepeat = _IEGetObjByName($oIE, 'player_loop')
    _IEAction($oRepeat, 'click')
EndFunc   ;==>_Repeat


Func _GetVolume()
;~  <A style="BOTTOM: 0%" class="ui-slider-handle ui-state-default ui-corner-all" href="#" jQuery15107891455831978822="11"></A>
    $hfind = _IETagNameGetCollection($oIE, "A")
    For $h In $hfind
        If String($h.className) = "ui-slider-handle ui-state-default ui-corner-all" Then
            $iVol = StringRegExp(_IEPropertyGet($h, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', 1)
            If IsArray($iVol) Then
                $iVol = $iVol[0]
                ConsoleWrite($iVol & @CRLF)
                Return $iVol
            Else
                Return -1
            EndIf
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_GetVolume


Func _SetVolume($iVol)
    $oTags = _IETagNameGetCollection($oIE, "div")
    For $oTag In $oTags
        If String($oTag.id) = "volumeSlider" Then
            $iVol = StringRegExpReplace(StringRegExpReplace(_IEPropertyGet($oTag, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', '"BOTTOM: ' & $iVol & '%";', 1), '["]HEIGHT:.(.*?)%["]', '"HEIGHT: ' & $iVol & '%";', 1)
            _IEPropertySet($oTag, 'outerhtml', $iVol)
            ConsoleWrite($iVol & @CRLF)
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_SetVolume


#cs
;GUI.
Func _GuiMini()
    $bActive = ($bActive = False)
    If $bActive Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>_GuiMini
#ce


;Misc.
Func _Debug()
    ;~  _SetVolume(50)
EndFunc   ;==>_Debug


Func _Exit()
    Exit
EndFunc   ;==>_Exit


Func _Exit2()
    If WinActive($hGUI) Then Exit
EndFunc   ;==>_Exit2


Func _RM()
    Local $ai = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid)
    $ai = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai[0])
EndFunc   ;==>_RM

;Reduce memory usage every 5 seconds.
AdlibRegister('_RM', 5000)

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next

    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($Dummy, $sCurrent)
        ;Toast?
    EndIf

    If WinGetTitle ($hGUI) = "GrooveShark ~ Song ~ Artist" Then
        WinSetTitle ($hGUI, "", "GrooveShark")
    EndIf

    Sleep(1000)
WEnd

The code i edited a bit.

But can someone explain a thing.

The code below gets the song playing and the artist.

And thats realy neat and all, but what i dont understand is the last If WinGetTitle element i wrote.

Its so when you first start the program the title bar isnt "GrooveShark ~ Song ~ Artist" its just "GrooveShark".

But my problem is, that if i put it first in the While loop, it stays at "GrooveShark ~ Song ~ Artist" for a second before going to plain "GrooveShark"... Why?

I dont understand.

Since its in the top of the loop it should execute first, right ?

Am i doin' it wrong ? :huh2:

I got it now, just struck me ;)

Its cause it has to set the title to "GrooveShark ~ Song ~ Artist" first, before my ifstatement can change it and the reason it hangs for a second on the screen is the Sleep (1000)

I could probably put it at the top and then when declaring the variable set it to "GrooveShark ~ Song ~ Artist".

But hey, it works :alien:

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next

    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($Dummy, $sCurrent)
        ;Toast?
    EndIf

    If WinGetTitle ($hGUI) = "GrooveShark ~ Song ~ Artist" Then
        WinSetTitle ($hGUI, "", "GrooveShark")
    EndIf

    Sleep(1000)
WEnd
Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Sleep(1000)

This sleeps the whole script for 1 second every time you execute the While...Wend loop. Lower that to 100 or less and you might see a vast improvement in the update time.

Also, do you really need to lower the memory usage every 5 seconds? Does the script eat that much memory in a 5 second time frame? If you see that it's using a lot of memory, you could probably call that function once every 5 minutes or even once every minute, but every 5 seconds seems a bit excessive and probably has negative impact on the performance of your script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Its basicly BitByteBit's script and i wasnt 100% sure what that thing did, and i dont want to remove the wrong thing.

Also a minute after i posted it i realised what was wrong.

But it works now :huh2:

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

#AutoIt3Wrapper_Icon=GrooveShark.Ico
#AutoIt3Wrapper_UseX64=n
#include<ie.au3>
Opt('GuiOnEventMode', 1)
Opt('GUIResizeMode', 102)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)

;Create tray items.
$Dummy = TrayCreateItem('Nothing playing')
;TraySetToolTip('Nothing playing')
TraySetToolTip("GrooveShark")
TrayItemSetState($Dummy, 128)
TrayCreateItem('')

$sStr = StringSplit('Play|Next|Previous||Shuffle|Repeat||Exit', '|')
For $i = 1 To $sStr[0]
    TrayCreateItem($sStr[$i])
    If $sStr[$i] Then TrayItemSetOnEvent(-1, '_' & $sStr[$i])
Next

TraySetClick(8)
;TraySetOnEvent(-8, '_GuiMini')
Local $Icon = "GrooveShark.Ico"
TraySetIcon($Icon)


;Set hotkeys.
;HotKeySet('!d', '_Debug')
;HotKeySet('{ESC}', '_Exit2')
HotKeySet('{MEDIA_PLAY_PAUSE}', '_Play')
HotKeySet('{MEDIA_NEXT}', '_Next')
HotKeySet('{MEDIA_PREV}', '_Prev')

;Variables.
Global $oIE, $hGUI, $bActive = False, $oArtist = 'Artist', $oSong = 'Song', $sCurrent
Global Const $iWidth = (@DesktopWidth/2 + @DesktopWidth/100*25), $iHeight = (@DesktopHeight/2 + @DesktopHeight/100*25), $iPid = @AutoItPID

;Create Gui.
$oIE = _IECreateEmbedded()
$hGUI = GUICreate('Grooveshark', $iWidth, $iHeight, -1, -1, BitOR(0x00010000, 0x00020000))
$oCtrl = GUICtrlCreateObj($oIE, -2, -2, $iWidth + 178, $iHeight - 24)
GUISetOnEvent(-3, '_Exit')
;GUISetOnEvent(-4, '_GuiMini')
_IENavigate($oIE, 'http://grooveshark.com')
GUISetState()



;Media control.
Func _Next()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oNext = _IEGetObjByName($oIE, 'player_next')
    _IEAction($oNext, 'click')
EndFunc   ;==>_Next


Func _Play()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPlay = _IEGetObjByName($oIE, 'player_play_pause')
    _IEAction($oPlay, 'click')
EndFunc   ;==>_Play


Func _Prev()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPrev = _IEGetObjByName($oIE, 'player_previous')
    _IEAction($oPrev, 'click')
EndFunc   ;==>_Prev


Func _Shuffle()
    $oShuffle = _IEGetObjByName($oIE, 'player_shuffle')
    _IEAction($oShuffle, 'click')
EndFunc   ;==>_Shuffle


Func _Repeat()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oRepeat = _IEGetObjByName($oIE, 'player_loop')
    _IEAction($oRepeat, 'click')
EndFunc   ;==>_Repeat


Func _GetVolume()
;~  <A style="BOTTOM: 0%" class="ui-slider-handle ui-state-default ui-corner-all" href="#" jQuery15107891455831978822="11"></A>
    $hfind = _IETagNameGetCollection($oIE, "A")
    For $h In $hfind
        If String($h.className) = "ui-slider-handle ui-state-default ui-corner-all" Then
            $iVol = StringRegExp(_IEPropertyGet($h, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', 1)
            If IsArray($iVol) Then
                $iVol = $iVol[0]
                ConsoleWrite($iVol & @CRLF)
                Return $iVol
            Else
                Return -1
            EndIf
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_GetVolume


Func _SetVolume($iVol)
    $oTags = _IETagNameGetCollection($oIE, "div")
    For $oTag In $oTags
        If String($oTag.id) = "volumeSlider" Then
            $iVol = StringRegExpReplace(StringRegExpReplace(_IEPropertyGet($oTag, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', '"BOTTOM: ' & $iVol & '%";', 1), '["]HEIGHT:.(.*?)%["]', '"HEIGHT: ' & $iVol & '%";', 1)
            _IEPropertySet($oTag, 'outerhtml', $iVol)
            ConsoleWrite($iVol & @CRLF)
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_SetVolume


#cs
;GUI.
Func _GuiMini()
    $bActive = ($bActive = False)
    If $bActive Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>_GuiMini
#ce


;Misc.
Func _Debug()
    ;~  _SetVolume(50)
EndFunc   ;==>_Debug


Func _Exit()
    Exit
EndFunc   ;==>_Exit


Func _Exit2()
    If WinActive($hGUI) Then Exit
EndFunc   ;==>_Exit2


Func _RM()
    Local $ai = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid)
    $ai = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai[0])
EndFunc   ;==>_RM

;Reduce memory usage every 5 seconds.
AdlibRegister('_RM', 5000)

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next

    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist

        If $sCurrent = "Song ~ Artist" Then
        WinSetTitle ($hGUI, "", "GrooveShark")
        TrayItemSetText ($dummy,"Nothing Playing")
        ;TraySetToolTip("Nothing playing")
        Else
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($dummy, $sCurrent)
        ;TraySetToolTip($sCurrent)
        ;Toast?
        TrayTip("Now playing:", $sCurrent,5)
        EndIf
    EndIf

    Sleep(1000)
WEnd

When the song changes a trayttip pops up.

I think im going to add a loading bar so that the gui is ready to go when showed, now it has to load for a couple of seconds.

Maybe a splash screen.

Im gonna search but if anyone has an idea on how to show an image in the center of a screen, please tell!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

If you want to use an image on a splashscreen, look at the SplashImageOn, if you want it with just text, use SplashTextOn as a place to start.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I searched aroun the forum and found something useble i just have to fine tune it.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

By the way, I have a SplashScreen like GUI in my signature that has a progress bar built in that you could use to do that other than using a splash screen.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I was looking for something like your UDF, but then i got an idea from another topic about having the program logo on the center of the screen, so i searhed and found a pice of code wich is _GUI_Image()

I have the three _GUI_Image() functions in an external file just to have a cleaner code.

But im gonna se if i can use PNG instead of BMP.

If not im gonna have to fix the logo so there isn any pink around or look at other options.

#AutoIt3Wrapper_Icon=GrooveShark.Ico
#AutoIt3Wrapper_UseX64=n
#include<ie.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt('GuiOnEventMode', 1)
Opt('GUIResizeMode', 102)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)

Global Const $SC_DRAGMOVE = 0xF012
Global $ImgGUI


Func _GUI_Image()
    ;Creating GUI

    $ImgGUI = GUICreate("No DLL Required", 300, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    GUICtrlCreatePic(@ScriptDir & "\Groovesharksplash.bmp", 0, 0, 300, 300)
    GUICtrlSetState(-1, $GUI_DISABLE);Hide the GUI and so only the image is showed

;~     While 1
;~         Switch GUIGetMsg()
;~             Case $GUI_EVENT_PRIMARYDOWN;Click and drag funtion
;~                 _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
;~         EndSwitch
;~     WEnd
EndFunc ;==>_GUI_Image

Func _GUI_Image_Show()
GUISetState(@SW_SHOW,$ImgGUI);Show GUI, but the gui is disabled, therefore its the image.
EndFunc ;==> _GUI_Image_Show

Func _GUI_Image_Hide()
    GUISetState(@SW_HIDE,$ImgGUI);Hides the GUI
EndFunc;==> _GUI_Image_Hide



;Create tray items.
$Dummy = TrayCreateItem('Nothing playing')
;TraySetToolTip('Nothing playing')
TraySetToolTip("GrooveShark")
TrayItemSetState($Dummy, 128)
TrayCreateItem('')
$sStr = StringSplit('Play|Next|Previous||Shuffle|Repeat||Exit', '|')
For $i = 1 To $sStr[0]
    TrayCreateItem($sStr[$i])
    If $sStr[$i] Then TrayItemSetOnEvent(-1, '_' & $sStr[$i])
Next
TraySetClick(8)
;TraySetOnEvent(-8, '_GuiMini')
Local $Icon = "GrooveShark.Ico"
TraySetIcon($Icon)

;Load and shows splash image
_GUI_Image()
_GUI_Image_Show()

;Set hotkeys.
;HotKeySet('!d', '_Debug')
;HotKeySet('{ESC}', '_Exit2')
HotKeySet('{MEDIA_PLAY_PAUSE}', '_Play')
HotKeySet('{MEDIA_NEXT}', '_Next')
HotKeySet('{MEDIA_PREV}', '_Prev')

;Variables.
Global $oIE, $hGUI, $bActive = False, $oArtist = 'Artist', $oSong = 'Song', $sCurrent
Global Const $iWidth = (@DesktopWidth/2 + @DesktopWidth/100*25), $iHeight = (@DesktopHeight/2 + @DesktopHeight/100*25), $iPid = @AutoItPID

;Create Gui.
$oIE = _IECreateEmbedded()
$hGUI = GUICreate('Grooveshark', $iWidth, $iHeight, -1, -1, BitOR(0x00010000, 0x00020000))
$oCtrl = GUICtrlCreateObj($oIE, -2, -2, $iWidth + 178, $iHeight - 24)
GUISetOnEvent(-3, '_Exit')
;GUISetOnEvent(-4, '_GuiMini')
_IENavigate($oIE, 'http://grooveshark.com')
;Wait for page to load
_IELoadWait ($oIE)
;Wait for everyting else to load
Sleep (3500)
;Hides the splash image
_GUI_Image_Hide()
;Gives the splash time to disapear before showing GS GUI
Sleep (200)
;Show GS GUI
GUISetState(@SW_SHOW, $hGUI)

;Media control.
Func _Next()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oNext = _IEGetObjByName($oIE, 'player_next')
    _IEAction($oNext, 'click')
EndFunc   ;==>_Next

Func _Play()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPlay = _IEGetObjByName($oIE, 'player_play_pause')
    _IEAction($oPlay, 'click')
EndFunc   ;==>_Play

Func _Prev()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPrev = _IEGetObjByName($oIE, 'player_previous')
    _IEAction($oPrev, 'click')
EndFunc   ;==>_Prev

Func _Shuffle()
    $oShuffle = _IEGetObjByName($oIE, 'player_shuffle')
    _IEAction($oShuffle, 'click')
EndFunc   ;==>_Shuffle

Func _Repeat()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oRepeat = _IEGetObjByName($oIE, 'player_loop')
    _IEAction($oRepeat, 'click')
EndFunc   ;==>_Repeat

Func _GetVolume()
;~  <A style="BOTTOM: 0%" class="ui-slider-handle ui-state-default ui-corner-all" href="#" jQuery15107891455831978822="11"></A>
    $hfind = _IETagNameGetCollection($oIE, "A")
    For $h In $hfind
        If String($h.className) = "ui-slider-handle ui-state-default ui-corner-all" Then
            $iVol = StringRegExp(_IEPropertyGet($h, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', 1)
            If IsArray($iVol) Then
                $iVol = $iVol[0]
                ConsoleWrite($iVol & @CRLF)
                Return $iVol
            Else
                Return -1
            EndIf
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_GetVolume

Func _SetVolume($iVol)
    $oTags = _IETagNameGetCollection($oIE, "div")
    For $oTag In $oTags
        If String($oTag.id) = "volumeSlider" Then
            $iVol = StringRegExpReplace(StringRegExpReplace(_IEPropertyGet($oTag, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', '"BOTTOM: ' & $iVol & '%";', 1), '["]HEIGHT:.(.*?)%["]', '"HEIGHT: ' & $iVol & '%";', 1)
            _IEPropertySet($oTag, 'outerhtml', $iVol)
            ConsoleWrite($iVol & @CRLF)
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_SetVolume

#cs
;GUI.
Func _GuiMini()
    $bActive = ($bActive = False)
    If $bActive Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>_GuiMini
#ce

;Misc.
Func _Debug()
;~       _SetVolume(50)
EndFunc   ;==>_Debug

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Exit2()
    If WinActive($hGUI) Then Exit
EndFunc   ;==>_Exit2


Func _RM()
    Local $ai = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid)
    $ai = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai[0])
EndFunc   ;==>_RM

;Reduce memory usage every 5 seconds.
AdlibRegister('_RM', 5000)

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next

    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist

        If $sCurrent = "Song ~ Artist" Then
        WinSetTitle ($hGUI, "", "GrooveShark")
        TrayItemSetText ($dummy,"Nothing Playing")
        ;TraySetToolTip("Nothing playing")
        Else
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($dummy, $sCurrent)
        ;TraySetToolTip($sCurrent)
        ;Toast?
        TrayTip("GrooveShark", $sCurrent,5)
        EndIf
    EndIf

    Sleep(1000)
WEnd
Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

I noticed the comments in your code regarding the gui and the image display. Just a point of reference, the line GUICtrlSetState(-1, $GUI_DISABLE);Hide the GUI and so only the image is showed isn't accurate. The GUI_Disable state isn't disabling the GUI, it's disabling the image that you create just above it. If you don't disable the image with this command, then you can't interact with some or all of the controls on your GUI.

What creates the GUI with just the image showing is the $WS_EX_LAYERED extended style you use when you create the GUI.

I like the idea of your's to use the logo as the GUI image, I created a media player with something similar except I used a jpg of a CD as my GUI. :huh2:

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thats neat.

I thought it was disabling the GUI.

Thanks for clearing that up.

Il fix the Image tomorrow! :huh2:

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

This is v2.3!

It has a traytip on song change.

Im also addin the code bleow to the traytip so it doesnt popup if the window is active, as if you are chaning song manually.

If Not WinActive($hGUI) Then
;Traytip code here...
EndIf

#AutoIt3Wrapper_Icon=GrooveShark.Ico
#AutoIt3Wrapper_UseX64=n
#include<ie.au3>
#include<splash.au3>
Opt('GuiOnEventMode', 1)
Opt('GUIResizeMode', 102)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)

;Create tray items.
$Dummy = TrayCreateItem('Nothing playing')
;TraySetToolTip('Nothing playing')
TraySetToolTip("GrooveShark")
TrayItemSetState($Dummy, 128)
TrayCreateItem('')
$sStr = StringSplit('Play|Next|Previous||Shuffle|Repeat||Exit', '|')
For $i = 1 To $sStr[0]
    TrayCreateItem($sStr[$i])
    If $sStr[$i] Then TrayItemSetOnEvent(-1, '_' & $sStr[$i])
Next
TraySetClick(8)
;TraySetOnEvent(-8, '_GuiMini')
Local $Icon = "GrooveShark.Ico"
TraySetIcon($Icon)

;Load and shows splash image
_GUI_Image()
_GUI_Image_Show()

;Set hotkeys.
;HotKeySet('!d', '_Debug')
;HotKeySet('{ESC}', '_Exit2')
HotKeySet('{MEDIA_PLAY_PAUSE}', '_Play')
HotKeySet('{MEDIA_NEXT}', '_Next')
HotKeySet('{MEDIA_PREV}', '_Prev')

;Variables.
Global $oIE, $hGUI, $bActive = False, $oArtist = 'Artist', $oSong = 'Song', $sCurrent
Global Const $iWidth = (@DesktopWidth/2 + @DesktopWidth/100*25), $iHeight = (@DesktopHeight/2 + @DesktopHeight/100*25), $iPid = @AutoItPID

;Create Gui.
$oIE = _IECreateEmbedded()
$hGUI = GUICreate('Grooveshark', $iWidth, $iHeight, -1, -1, BitOR(0x00010000, 0x00020000))
$oCtrl = GUICtrlCreateObj($oIE, -2, -2, $iWidth + 178, $iHeight - 24)
GUISetOnEvent(-3, '_Exit')
;GUISetOnEvent(-4, '_GuiMini')
_IENavigate($oIE, 'http://grooveshark.com')
;Wait for page to load
_IELoadWait ($oIE)
;Wait for everyting else to load
Sleep (3500)
;Hides the splash image
_GUI_Image_Hide()
;Gives the splash time to disapear before showing GS GUI
Sleep (200)
;Show GS GUI
GUISetState(@SW_SHOW, $hGUI)

;Media control.
Func _Next()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oNext = _IEGetObjByName($oIE, 'player_next')
    _IEAction($oNext, 'click')
EndFunc   ;==>_Next

Func _Play()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPlay = _IEGetObjByName($oIE, 'player_play_pause')
    _IEAction($oPlay, 'click')
EndFunc   ;==>_Play

Func _Prev()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPrev = _IEGetObjByName($oIE, 'player_previous')
    _IEAction($oPrev, 'click')
EndFunc   ;==>_Prev

Func _Shuffle()
    $oShuffle = _IEGetObjByName($oIE, 'player_shuffle')
    _IEAction($oShuffle, 'click')
EndFunc   ;==>_Shuffle

Func _Repeat()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oRepeat = _IEGetObjByName($oIE, 'player_loop')
    _IEAction($oRepeat, 'click')
EndFunc   ;==>_Repeat

Func _GetVolume()
;~  <A style="BOTTOM: 0%" class="ui-slider-handle ui-state-default ui-corner-all" href="#" jQuery15107891455831978822="11"></A>
    $hfind = _IETagNameGetCollection($oIE, "A")
    For $h In $hfind
        If String($h.className) = "ui-slider-handle ui-state-default ui-corner-all" Then
            $iVol = StringRegExp(_IEPropertyGet($h, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', 1)
            If IsArray($iVol) Then
                $iVol = $iVol[0]
                ConsoleWrite($iVol & @CRLF)
                Return $iVol
            Else
                Return -1
            EndIf
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_GetVolume

Func _SetVolume($iVol)
    $oTags = _IETagNameGetCollection($oIE, "div")
    For $oTag In $oTags
        If String($oTag.id) = "volumeSlider" Then
            $iVol = StringRegExpReplace(StringRegExpReplace(_IEPropertyGet($oTag, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', '"BOTTOM: ' & $iVol & '%";', 1), '["]HEIGHT:.(.*?)%["]', '"HEIGHT: ' & $iVol & '%";', 1)
            _IEPropertySet($oTag, 'outerhtml', $iVol)
            ConsoleWrite($iVol & @CRLF)
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_SetVolume

#cs
;GUI.
Func _GuiMini()
    $bActive = ($bActive = False)
    If $bActive Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>_GuiMini
#ce

;Misc.
Func _Debug()
;~       _SetVolume(50)
EndFunc   ;==>_Debug

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Exit2()
    If WinActive($hGUI) Then Exit
EndFunc   ;==>_Exit2


Func _RM()
    Local $ai = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid)
    $ai = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai[0])
EndFunc   ;==>_RM

;Reduce memory usage every 5 seconds.
AdlibRegister('_RM', 5000)

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next

    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist

        If $sCurrent = "Song ~ Artist" Then
        WinSetTitle ($hGUI, "", "GrooveShark")
        TrayItemSetText ($dummy,"Nothing Playing")
        ;TraySetToolTip("Nothing playing")
        Else
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($dummy, $sCurrent)
        ;TraySetToolTip($sCurrent)
        ;Toast?
        TrayTip("GrooveShark", $sCurrent,5)
        EndIf
    EndIf

    Sleep(1000)
WEnd

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Here is the v2.5 code

The splash doesnt have the purpleo utline anymore but is really sharp.

And it sais i can use png, but i cant fix it.

That will be 2.6.

Also traytip only come up if the grooveshark window isnt active.

Im thinking about making an F1 function to set options.

And maybe have an about thing there

Main code

#AutoIt3Wrapper_Icon=GrooveShark.Ico
#AutoIt3Wrapper_UseX64=n
#include<ie.au3>
#include<splash.au3>
Opt('GuiOnEventMode', 1)
Opt('GUIResizeMode', 102)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)

;Create tray items.
$Dummy = TrayCreateItem('Nothing playing')
;TraySetToolTip('Nothing playing')
TraySetToolTip("GrooveShark")
TrayItemSetState($Dummy, 128)
TrayCreateItem('')
$sStr = StringSplit('Play|Next|Previous||Shuffle|Repeat||Exit', '|')
For $i = 1 To $sStr[0]
    TrayCreateItem($sStr[$i])
    If $sStr[$i] Then TrayItemSetOnEvent(-1, '_' & $sStr[$i])
Next
TraySetClick(8)
;TraySetOnEvent(-8, '_GuiMini')
Local $Icon = "GrooveShark.Ico"
TraySetIcon($Icon)

;Load and shows splash image
_GUI_Image()
_GUI_Image_Show()

;Set hotkeys.
;HotKeySet('!d', '_Debug')
;HotKeySet('{ESC}', '_Exit2')
HotKeySet('{MEDIA_PLAY_PAUSE}', '_Play')
HotKeySet('{MEDIA_NEXT}', '_Next')
HotKeySet('{MEDIA_PREV}', '_Prev')

;Variables.
Global $oIE, $hGUI, $bActive = False, $oArtist = 'Artist', $oSong = 'Song', $sCurrent
Global Const $iWidth = (@DesktopWidth/2 + @DesktopWidth/100*25), $iHeight = (@DesktopHeight/2 + @DesktopHeight/100*25), $iPid = @AutoItPID

;Create Gui.
$oIE = _IECreateEmbedded()
$hGUI = GUICreate('Grooveshark', $iWidth, $iHeight, -1, -1, BitOR(0x00010000, 0x00020000))
$oCtrl = GUICtrlCreateObj($oIE, -2, -2, $iWidth + 178, $iHeight - 24)
GUISetOnEvent(-3, '_Exit')
;GUISetOnEvent(-4, '_GuiMini')
_IENavigate($oIE, 'http://grooveshark.com')
;Wait for page to load
_IELoadWait ($oIE)
;Wait for everyting else to load
Sleep (3500)
;Hides the splash image
_GUI_Image_Hide()
;Gives the splash time to disapear before showing GS GUI
Sleep (200)
;Show GS GUI
GUISetState(@SW_SHOW, $hGUI)

;Media control.
Func _Next()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oNext = _IEGetObjByName($oIE, 'player_next')
    _IEAction($oNext, 'click')
EndFunc   ;==>_Next

Func _Play()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPlay = _IEGetObjByName($oIE, 'player_play_pause')
    _IEAction($oPlay, 'click')
EndFunc   ;==>_Play

Func _Prev()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oPrev = _IEGetObjByName($oIE, 'player_previous')
    _IEAction($oPrev, 'click')
EndFunc   ;==>_Prev

Func _Shuffle()
    $oShuffle = _IEGetObjByName($oIE, 'player_shuffle')
    _IEAction($oShuffle, 'click')
EndFunc   ;==>_Shuffle

Func _Repeat()
;~  TrayItemSetState(@TRAY_ID, 4)
    $oRepeat = _IEGetObjByName($oIE, 'player_loop')
    _IEAction($oRepeat, 'click')
EndFunc   ;==>_Repeat

Func _GetVolume()
;~  <A style="BOTTOM: 0%" class="ui-slider-handle ui-state-default ui-corner-all" href="#" jQuery15107891455831978822="11"></A>
    $hfind = _IETagNameGetCollection($oIE, "A")
    For $h In $hfind
        If String($h.className) = "ui-slider-handle ui-state-default ui-corner-all" Then
            $iVol = StringRegExp(_IEPropertyGet($h, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', 1)
            If IsArray($iVol) Then
                $iVol = $iVol[0]
                ConsoleWrite($iVol & @CRLF)
                Return $iVol
            Else
                Return -1
            EndIf
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_GetVolume

Func _SetVolume($iVol)
    $oTags = _IETagNameGetCollection($oIE, "div")
    For $oTag In $oTags
        If String($oTag.id) = "volumeSlider" Then
            $iVol = StringRegExpReplace(StringRegExpReplace(_IEPropertyGet($oTag, 'outerhtml'), '["]BOTTOM:.(.*?)%["]', '"BOTTOM: ' & $iVol & '%";', 1), '["]HEIGHT:.(.*?)%["]', '"HEIGHT: ' & $iVol & '%";', 1)
            _IEPropertySet($oTag, 'outerhtml', $iVol)
            ConsoleWrite($iVol & @CRLF)
            ExitLoop
        EndIf
    Next
    Return -1
EndFunc   ;==>_SetVolume

#cs
;GUI.
Func _GuiMini()
    $bActive = ($bActive = False)
    If $bActive Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>_GuiMini
#ce

;Misc.
Func _Debug()
;~       _SetVolume(50)
EndFunc   ;==>_Debug

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Exit2()
    If WinActive($hGUI) Then Exit
EndFunc   ;==>_Exit2


Func _RM()
    Local $ai = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid)
    $ai = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai[0])
EndFunc   ;==>_RM

;Reduce memory usage every 5 seconds.
AdlibRegister('_RM', 5000)

;Main Loop.
$oTags = _IETagNameGetCollection($oIE, "A")
While 1
    For $oTag In $oTags
        If StringInStr($oTag.className, 'currentSongLink') Then
            $oSong = String($oTag.title)
        ElseIf StringInStr($oTag.className, 'artist') Then
            $oArtist = String($oTag.title)
            ExitLoop
        EndIf
    Next

    If $oSong & ' ~ ' & $oArtist <> $sCurrent Then
        $sCurrent = $oSong & ' ~ ' & $oArtist

        If $sCurrent = "Song ~ Artist" Then
        WinSetTitle ($hGUI, "", "GrooveShark")
        TrayItemSetText ($dummy,"Nothing Playing")
        ;TraySetToolTip("Nothing playing")
        Else
        WinSetTitle($hGUI, '', 'GrooveShark ~ ' & $sCurrent)
        TrayItemSetText($dummy, $sCurrent)
        ;TraySetToolTip($sCurrent)
        ;Toast?
            If Not WinActive($hGUI) Then
                TrayTip("GrooveShark", $sCurrent,5)
            EndIf
        EndIf
    EndIf

    Sleep(1000)
WEnd

Splash code:

#include-once
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
;~ #NoTrayIcon

;Avilabele functions:
;_GUI_Image()       Will create the image.
;_GUI_Image_Show()  Will show the image.
;_GUI_Image_Hide()  Will hide the image.

;Variables
Global Const $SC_DRAGMOVE = 0xF012
Global $ImgGUI, $Percent = 35, $SplashSize = (@DesktopHeight/100*$Percent)

;~ $FilePath = FileOpenDialog ( "", @ScriptDir, "Jpg (*.jpg)|Png (*.png)|Bmp (*.Bmp)" , 3, "")


Func _GUI_Image()
    ;Creating GUI

    $ImgGUI = GUICreate("No DLL Required", $SplashSize, $SplashSize, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    GUICtrlCreatePic(@ScriptDir & "\Groovesharksplash.bmp", 0, 0, $SplashSize, $SplashSize)
;~  GUICtrlCreatePic($FilePath, 0, 0, $SplashSize, $SplashSize)
    GUICtrlSetState(-1, $GUI_DISABLE);Hide the GUI and so only the image is showed

;~     While 1
;~         Switch GUIGetMsg()
;~             Case $GUI_EVENT_PRIMARYDOWN;Click and drag funtion
;~                 _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
;~         EndSwitch
;~     WEnd
EndFunc ;==>_GUI_Image

Func _GUI_Image_Show()
GUISetState(@SW_SHOW,$ImgGUI);Show GUI, but the gui is disabled, therefore its the image.
EndFunc ;==> _GUI_Image_Show

Func _GUI_Image_Hide()
    GUISetState(@SW_HIDE,$ImgGUI);Hides the GUI
EndFunc;==> _GUI_Image


;~ _GUI_Image()
;~ _GUI_Image_Show()
;~ Sleep(2000)
;~ _GUI_Image_Hide()
;~ Exit

Splash image:

Posted Image

Put everything in the same folder and run the main file.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

So my friend (wich is the reason i made this program) had an issue with his page not properly loading.

So im gonna make it look for something on the grooveshark page, if it isnt found then navigate to groveshark.com

Also, something i didnt know, after 30 minutes it presents a popup with "Are you there" or something.

Is there a way to edit html with autoit?

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Can someone explain how i can keep this window at the top ?

Like... Always!

I tried editing the style, but it didnt work...

#include-once
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
;~ #NoTrayIcon

;Avilabele functions:
;_GUI_Image()       Will create the image.
;_GUI_Image_Show()  Will show the image.
;_GUI_Image_Hide()  Will hide the image.

;Variables
Global Const $SC_DRAGMOVE = 0xF012
Global $ImgGUI, $Percent = 35, $SplashSize = (@DesktopHeight/100*$Percent)

;~ $FilePath = FileOpenDialog ( "", @ScriptDir, "Jpg (*.jpg)|Png (*.png)|Bmp (*.Bmp)" , 3, "")


Func _GUI_Image()
    ;Creating GUI

    $ImgGUI = GUICreate("No DLL Required", $SplashSize, $SplashSize, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    GUICtrlCreatePic(@ScriptDir & "\Groovesharksplash.bmp", 0, 0, $SplashSize, $SplashSize)
;~  GUICtrlCreatePic($FilePath, 0, 0, $SplashSize, $SplashSize)
    GUICtrlSetState(-1, $GUI_DISABLE);Hide the GUI and so only the image is showed

;~     While 1
;~         Switch GUIGetMsg()
;~             Case $GUI_EVENT_PRIMARYDOWN;Click and drag funtion
;~                 _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
;~         EndSwitch
;~     WEnd
EndFunc ;==>_GUI_Image

Func _GUI_Image_Show()
GUISetState(@SW_SHOW,$ImgGUI);Show GUI, but the gui is disabled, therefore its the image.
EndFunc ;==> _GUI_Image_Show

Func _GUI_Image_Hide()
    GUISetState(@SW_HIDE,$ImgGUI);Hides the GUI
EndFunc;==> _GUI_Image


;~ _GUI_Image()
;~ _GUI_Image_Show()
;~ Sleep(2000)
;~ _GUI_Image_Hide()
;~ Exit
Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Use the extended style $WS_EX_TOPMOST

$ImgGUI = GUICreate("No DLL Required", $SplashSize, $SplashSize, -1, -1, $WS_POPUP, BitOr($WS_EX_TOPMOST,$WS_EX_LAYERED))

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Use the extended style $WS_EX_TOPMOST

$ImgGUI = GUICreate("No DLL Required", $SplashSize, $SplashSize, -1, -1, $WS_POPUP, BitOr($WS_EX_TOPMOST,$WS_EX_LAYERED))

i tried but it didnt work...

Ill try your code!

Or use:

WinSetOnTop

I'm looking into the problem of inactivity. As I see it there are two solutions.

Check to see if the continue listening button exists, click when it does.

Fake some sort of user activity within the IE window every 15 mins.

Click at position 1,1 maybe.

But my problem is that i cant make the window and button apear at all... hmm...

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

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...