找回密码
 加入
搜索
查看: 2351|回复: 8

[系统综合] [已解决]请教程序运行后如何关联相应文件播放

  [复制链接]
发表于 2011-1-27 00:12:26 | 显示全部楼层 |阅读模式
本帖最后由 kxing 于 2011-1-30 12:10 编辑

我想写一个播放器。在双击某音乐文件时自动调用该波放器播放。
当该播放器已经处于运行状态时直接载入该音乐播放。不要另开进程。
重点在载入播放的问题上,希望高手们解答。
多谢!
发表于 2011-1-27 00:32:09 | 显示全部楼层
这个不太懂的..
发表于 2011-1-27 01:40:46 | 显示全部楼层
这个东西好像从注册表入手
 楼主| 发表于 2011-1-27 22:23:52 | 显示全部楼层
注册表的也只能做到关联调用程序.
但是程序运行后就没辙了!!!!
发表于 2011-1-27 23:16:47 | 显示全部楼层
本帖最后由 xxoojoeooxx 于 2011-1-29 00:49 编辑

之前写过给个部分代码出来看看
透过传送wm_copydata讯息

GUIRegisterMsg(0x4A, '_Rec')



$FileN="" ;档名
$hWnd = WinGetHandle('Player ')
If NOT @error Then 
        $message = 'play' ;传送播放讯息
        $struct = DllStructCreate('wchar var1[1000]')
        DllStructSetData($struct, 1, $message&"|"& $FileN)
        $pStruct = DllStructGetPtr($struct)
        $struct2 = DllStructCreate('dword;dword;ptr')
        DllStructSetData($struct2, 1, 0)
        DllStructSetData($struct2, 2, 1000)
        DllStructSetData($struct2, 3, $pStruct)
        $pStruct2 = DllStructGetPtr($struct2)
        _SendMessage($hWnd, 0x4A, 0, $pStruct2)
        Exit 0;
EndIf


接收

Func _Rec($hWnd, $iMsg, $iwParam, $ilParam)
         $S1 = DllStructCreate('dword var1;dword var2;ptr var3', $ilParam)
         $S2 = DllStructGetData($S1, 3)
         $S3 = DllStructCreate('wchar var1[1000]', $S2)
         $S4 = DllStructGetData($S3, 1)
        $Split= StringSplit($S4,'|')
        $file = $Split[2]
        $message =$Split[1]
         ;加入播放动作
 EndFunc   ;==>_Rec
 楼主| 发表于 2011-1-28 10:55:10 | 显示全部楼层
many thanks!!!
 楼主| 发表于 2011-1-28 10:57:12 | 显示全部楼层
能简单写个例子吗,小弟不才看不太明白.
发表于 2011-1-29 01:11:53 | 显示全部楼层

#include <Sound.au3>
#include <Constants.au3>
#include <SendMessage.au3>
Opt("TrayMenuMode",1)
Dim $FileN
#Region 
        If $CmdLine[0] >0 Then
                $FileN= $CmdLine[1]
                $hWnd = WinGetHandle('Player ')
                If NOT @error Then 
                        $message = 'play' 
                        $struct = DllStructCreate('wchar var1[1000]')
                        DllStructSetData($struct, 1, $message&"|"& $FileN)
                        $pStruct = DllStructGetPtr($struct)
                        $struct2 = DllStructCreate('dword;dword;ptr')
                        DllStructSetData($struct2, 1, 0)
                        DllStructSetData($struct2, 2, 1000)
                        DllStructSetData($struct2, 3, $pStruct)
                        $pStruct2 = DllStructGetPtr($struct2)
                        _SendMessage($hWnd, 0x4A, 0, $pStruct2)
                        Exit 0;
                Else
                        $sound=_SoundOpen ($FileN, "Startup")
                        _SoundPlay($sound,0)
                EndIf
        EndIf
#EndRegion 
#Region 
        GUICreate("Player ")
        GUISetState(@SW_HIDE)
        $Nameitem        = TrayCreateItem($FileN)
        TrayCreateItem("")
        $Openitem        = TrayCreateItem("Open")
        $Playitem        = TrayCreateItem("Play")
        $Exititem        = TrayCreateItem("Exit")
#EndRegion
;~ AutoItWinSetTitle("Player ")
ConsoleWrite(AutoItWinGetTitle())
GUIRegisterMsg(0x4A, '_Rec')
While 1
        $msg = TrayGetMsg()
        Select
                Case $msg = $openitem
                        $File = FileOpenDialog("Choose file...","","Music (*.mp3;*.wma;*.wav)")
                        if $File<>"" then
                                if $FileN<>"" then _SoundClose ($sound)
                                $FileN=$File
                                $sound=_SoundOpen ($FileN)
                                _SoundPlay($sound,0)
                                TrayItemSetText($nameitem,$FileN)
                        Endif
                Case $msg = $playitem
                        if $FileN<>"" then
                                _SoundPlay($sound,0)
                        Endif
                Case $msg = $exititem
                        Exit 0
        EndSelect
WEnd
Func _Rec($hWnd, $iMsg, $iwParam, $ilParam)
        $S1 = DllStructCreate('dword var1;dword var2;ptr var3', $ilParam)
        $S2 = DllStructGetData($S1, 3)
        $S3 = DllStructCreate('wchar var1[1000]', $S2)
        $S4 = DllStructGetData($S3, 1)
        $Split= StringSplit($S4,'|')
        $File = $Split[2]
        $message =$Split[1]
        if $File<>"" then
                if $FileN<>"" then _SoundClose ($sound)
                $FileN=$File
                $sound=_SoundOpen ($FileN)
                _SoundPlay($sound,0)
                TrayItemSetText($nameitem,$FileN)
        Endif
 EndFunc   ;==>_Rec

评分

参与人数 1金钱 +10 收起 理由
kxing + 10 小小新意!!

查看全部评分

 楼主| 发表于 2011-1-30 11:57:05 | 显示全部楼层
感谢老兄,十分感谢!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 16:24 , Processed in 0.081665 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表