Sign in to follow this  
Followers 0
Kreatorul

Little help :D

7 posts in this topic

I want to make a small media "player" it comes very handy when winamp runs in tray but if i send the play_pause....it only plays the song if i try to press again to pause it dosen't work...:P help :D:)

#include <GUIConstants.au3>
$gui = GUICreate("AForm1", 145, 58, 270, 264, $WS_POPUP)
GuiRoundCorners($gui, 10, 10, 20, 20)
GUISetBkColor(0x0E1010)
$Button1 = GUICtrlCreateButton("(Not allowed)", 18, 16, 29, 16, $BS_BITMAP)
GUICtrlSetImage($Button1, "D:\Documents and Settings\Kreatorul\Desktop\play.bmp")
$Button2 = GUICtrlCreateButton("(Not allowed)", 48, 16, 25, 16, $BS_BITMAP)
GUICtrlSetImage($Button2, "D:\Documents and Settings\Kreatorul\Desktop\stop.bmp")
$Button3 = GUICtrlCreateButton("(Not allowed)", 108, 16, 29, 16, $BS_BITMAP)
GUICtrlSetImage($Button3, "D:\Documents and Settings\Kreatorul\Desktop\next.bmp")
$Button4 = GUICtrlCreateButton("(Not allowed)", 78, 16, 29, 16, $BS_BITMAP)
GUICtrlSetImage($Button4, "D:\Documents and Settings\Kreatorul\Desktop\prev.bmp")
$Button5 = GUICtrlCreateButton("(Not allowed)", 18, 35, 29, 16, $BS_BITMAP)
GUICtrlSetImage($Button5, "D:\Documents and Settings\Kreatorul\Desktop\op.bmp")
$Button6 = GUICtrlCreateButton("(Not allowed)", 48, 35, 25, 16, $BS_BITMAP)
GUICtrlSetImage($Button6, "D:\Documents and Settings\Kreatorul\Desktop\mute.bmp")
$Button7 = GUICtrlCreateButton("(Not allowed)", 78, 35, 29, 16, $BS_BITMAP)
GUICtrlSetImage($Button7, "D:\Documents and Settings\Kreatorul\Desktop\volm.bmp")
$Button8 = GUICtrlCreateButton("(Not allowed)", 108, 35, 29, 16, $BS_BITMAP)
GUICtrlSetImage($Button8, "D:\Documents and Settings\Kreatorul\Desktop\volp.bmp")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $gui Or $msg = $GUI_EVENT_PRIMARYDOWN
            _Drag($gui)
        Case $msg=$Button1
            Send("{MEDIA_PLAY_PAUSE}")
               Case $msg=$button2
            Send("{MEDIA_STOP}")
               Case $msg=$button3
            Send("{MEDIA_NEXT}")
               Case $msg=$button4
            Send("{MEDIA_PREV}")
               Case $msg=$button5
            Send("{LAUNCH_MEDIA}")
               Case $msg=$button6
            Send("{VOLUME_MUTE}")
               Case $msg=$button7
            Send("{VOLUME_DOWN}")
               Case $msg=$button8
            Send("{VOLUME_UP}")
            EndSelect
        WEnd
        
        Func _Drag ($h_gui)
    DllCall("user32.dll", "int", "ReleaseCapture")
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $h_gui, "int", 0xA1, "int", 2, "int", 0)
EndFunc   ;==>_Drag
 
Func GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
   $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
  EndIf
EndFunc ;==>_GuiRoundCorners

Share this post


Link to post
Share on other sites



c'mon it isn't that hard :)

Share this post


Link to post
Share on other sites

What you're relying on here is Windows to make sure your media keys get sent to the correct current media application. Which I guess it isn't. It doesn't for me. Perhaps Microsoft feels that those buttons are better used for Media Player. Try replacing your Send with ControlSend, and using the WinAmp defalt hotkey set. This works for me:

Global $playing = True

WinAmpPlayToggle()
sleep(5000)
WinAmpPlayToggle()

Func WinAmpPlayToggle()
    if $playing = True Then
        ControlSend ( "Winamp", "", "", "c") ; pause
        $playing = False
    Else
        ControlSend ( "Winamp", "", "", "x") ; play
        $playing = True
    EndIf
EndFunc


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Oh, for cryin' out loud. The hotkeys didn't work for me because I didn't go into WinAmp prefs and check on "Global Hotkeys". Try that first.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

It's not about that, because in that "keyboard simulator" u helped me with the play_pause button worked fine in winamp and media player....

Share this post


Link to post
Share on other sites

No, winamp is visible but same thing....anyway thanks for help guys I'll try your advices :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0