Jump to content

How to receive WM_COPYDATA?


zeffy
 Share

Recommended Posts

Hi, I'm trying to use the Audiosurf API (see here) command

ascommand registerlistenerwindow MyWindowTitle

(see near the bottom of the top post for more info), so I can get the title and artist of the song that is being played, but I am totally confused as to how to receive WM_COPYDATA from another program. I have looked at several examples on the forum, but I need further explanation about how to use it, specifically for what I'm trying to do.

Thanks

Link to comment
Share on other sites

This should receive and display a string send via WM_COPYDATA.

#include <windowsconstants.au3>

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

Global $sWM_COPYDATA_Received_String

$hgui = GUICreate("Receiving hWnd")
GUIRegisterMsg($WM_COPYDATA, "WM_COPYDATA")
GUISetState()

While 1
    Sleep(10)
    If $sWM_COPYDATA_Received_String Then
        MsgBox(0, "Received String via WM_COPYDATA", $sWM_COPYDATA_Received_String)
        $sWM_COPYDATA_Received_String = ""
    EndIf
WEnd


Func WM_COPYDATA($hWnd, $MsgID, $wParam, $lParam)
    ; http://www.autoitscript.com/forum/index.php?showtopic=105861&view=findpost&p=747887
    ; Melba23, based on code from Yashied

    Switch $hWnd
        Case $hgui
            Local $tCOPYDATA = DllStructCreate("dword;dword;ptr", $lParam)
            Local $tMsg = DllStructCreate("char[" & DllStructGetData($tCOPYDATA, 2) & "]", DllStructGetData($tCOPYDATA, 3))
            $sWM_COPYDATA_Received_String = DllStructGetData($tMsg, 1)

    EndSwitch

    Return True

EndFunc   ;==>WM_COPYDATA

Func _Exit()
    Exit
EndFunc   ;==>_Exit
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...