mikered82 Posted September 7, 2011 Share Posted September 7, 2011 (edited) Hi! I need some help to convert the following C++ code to autoit: ;~ / COPYDATASTRUCT cds; ;~ // char buf[MAX_PATH]; ;~ // void *adr; ;~ // ;~ // adr=&buf; ;~ // cds.dwData=BSP_GetFileName; ;~ // cds.lpData=&adr; ;~ // cds.cbData=4; ;~ // SendMessage(bsp_hand,WM_COPYDATA,appHWND,(LPARAM)&cds); ;~ // available in BSPlayer version 0.84.484+ ;~ // ;~ // appHWND is calling application window handle ;~ // File name will be copied to buf ;~ // ;~ // Get open file name ;~ #define BSP_GetFileName 0x1010B What I got so far is: #Include <SendMessage.au3> $BS_FileName = BSP_GetFileName() MsgBox(0, "BSPlayer File Name", $BS_FileName) Func BSP_GetFileName() $hWndHandle = WinGetHandle("[CLASS:BSPlayer]") $WM_COPYDATA = 0x004A $BSP_GetFileName = 0x1010B $buf = DllStructCreate("CHAR[128]") $cds = DllStructCreate ("int;ptr;int") DllStructSetData ($cds, 1, $BSP_GetFileName) DllStructSetData ($cds, 2, DllStructGetPtr($buf)) DllStructSetData ($cds, 3, 4) _SendMessage($hWndHandle, $WM_COPYDATA, 0, $cds) Return DllStructGetData($buf, 1) EndFunc but, of course, it doesn't work. The function should return the file name currently playing in BSPlayer. Thank You! Edited September 7, 2011 by mikered82 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 7, 2011 Share Posted September 7, 2011 Open the helpfile and look what DllStructCreate() returns .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
mikered82 Posted September 7, 2011 Author Share Posted September 7, 2011 I did look in help file, but i don't know what I did wrong. If you do, please tell me! Link to comment Share on other sites More sharing options...
Zedna Posted September 7, 2011 Share Posted September 7, 2011 _SendMessage($hWndHandle, $WM_COPYDATA, 0, $cds) _SendMessage($hWndHandle, $WM_COPYDATA, 0, DllStructGetPtr($cds)) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
mikered82 Posted September 7, 2011 Author Share Posted September 7, 2011 _SendMessage($hWndHandle, $WM_COPYDATA, 0, $cds) _SendMessage($hWndHandle, $WM_COPYDATA, 0, DllStructGetPtr($cds)) Yes, it was a mistake, but it still doesn't work. Link to comment Share on other sites More sharing options...
Zedna Posted September 7, 2011 Share Posted September 7, 2011 (edited) According to MSDN your cds structure is badhttp://msdn.microsoft.com/en-us/library/ms649011%28v=vs.85%29.aspxhttp://msdn.microsoft.com/en-us/library/ms649010%28v=vs.85%29.aspx Search this forum for more examples of using WM_COPYDATA ... Edited September 7, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 7, 2011 Moderators Share Posted September 7, 2011 Curious, how did you come up with this struct? $cds = DllStructCreate ("int;ptr;int") These are backwards: DllStructSetData ($cds, 2, DllStructGetPtr($buf)) DllStructSetData ($cds, 3, 4) bsp_hnd is missing; no idea where/what that is. appHwnd should be in the wparam ---- I'd imagine it to look more like:Func _BSP_GetFileName() Local $h_bsphnd = 0 ; No idea what this is Local $h_wnd = WinGetHandle("[CLASS:BSPlayer]") If Not IsHWnd($h_wnd) Then Return SetError(1, 0, 0) Local Static $__WM_COPYDATA = 0x004A Local Static $BSP_GETFILENAME = 0x1010B Local Static $t_buff = DllStructCreate("CHAR[256]") Local Static $p_buff = DllStructGetPtr($t_buff) Local Static $tagCOPYDATASTRUCT = "ptr dwData;uint cbData;ptr lpData" Local Static $t_cbs = DllStructCreate($tagCOPYDATASTRUCT) DllStructSetData($t_cbs, "dwData", $BSP_GETFILENAME) DllStructSetData($t_cbs, "cbData", 4) DllStructSetData($t_cbs, "lpData", $p_buff) Local Static $p_cbs = DllStructGetPtr($cbs) DllCall("User32.dll", "int", "SendMessage", _ "hwnd", $h_bsphnd, "uint", $__WM_COPYDATA, _ "wparam", $h_wnd, "lparam", $p_cbs) Return DllStructGetData($t_buff, 1) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zedna Posted September 7, 2011 Share Posted September 7, 2011 Here is one post with example Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now