testmeout Posted June 9, 2007 Share Posted June 9, 2007 Well after trial and error I have finally been able to communicate with openticks dll through a dll wrapper. I can call the functions just fine, and get good results, but to achieve what I want, I need to be able to recieve messages from the dll, which is not working for me. So I am stuck agian and not sure where to go at this point. Does anyone have any ideas on how to debug GUIRegisterMsg? Here is my code so far. #include <GUIConstants.au3> Global Const $OTFEED_LOGIN = ($WM_USER + 2500) $gui = GUICreate("DataDump") $hwnd = WinGetHandle($gui) sleep(1000) $dll = DllOpen("OTFeedAPI.dll") If $dll = -1 Then MsgBox(0,"","Error - dll failed to open.") Exit EndIf $addhost = DllCall($dll,"none","AddHost","str","feed1.opentick.com","int",10010) ;$client.addHost("feed1.opentick.com", 10010) ; Real-time data ;$client.addHost("feed2.opentick.com", 10010) ; Real-time data sleep(200) $login = DllCall($dll,"none", "Login", "str", "myusername", "str", "mypassword") $callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd) GUIRegisterMsg($OTFEED_LOGIN, "onlogin") DllClose($dll) Func onlogin($hwnd,$msg,$w,$l) msgbox(0, "Status", "Success") EndFunc The script does not terminate so I am assuming it is frozen. When I remove the DllClose($dll) for some reason the taskbar icon disappears but the script has not terminated yet. Any help is greatly appreciated. Link to comment Share on other sites More sharing options...
Zedna Posted June 9, 2007 Share Posted June 9, 2007 Search for CallBack keyword on this forum.Here is link to some results. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
martin Posted June 9, 2007 Share Posted June 9, 2007 Well after trial and error I have finally been able to communicate with openticks dll through a dll wrapper. I can call the functions just fine, and get good results, but to achieve what I want, I need to be able to recieve messages from the dll, which is not working for me. So I am stuck agian and not sure where to go at this point. Does anyone have any ideas on how to debug GUIRegisterMsg? Here is my code so far. #include <GUIConstants.au3> Global Const $OTFEED_LOGIN = ($WM_USER + 2500) $gui = GUICreate("DataDump") $hwnd = WinGetHandle($gui) sleep(1000) $dll = DllOpen("OTFeedAPI.dll") If $dll = -1 Then MsgBox(0,"","Error - dll failed to open.") Exit EndIf $addhost = DllCall($dll,"none","AddHost","str","feed1.opentick.com","int",10010) ;$client.addHost("feed1.opentick.com", 10010) ; Real-time data ;$client.addHost("feed2.opentick.com", 10010) ; Real-time data sleep(200) $login = DllCall($dll,"none", "Login", "str", "myusername", "str", "mypassword") $callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd) GUIRegisterMsg($OTFEED_LOGIN, "onlogin") DllClose($dll) Func onlogin($hwnd,$msg,$w,$l) msgbox(0, "Status", "Success") EndFunc The script does not terminate so I am assuming it is frozen. When I remove the DllClose($dll) for some reason the taskbar icon disappears but the script has not terminated yet. Any help is greatly appreciated. Can't offer much with what you said so far, but this bit $callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd) looks wrong to me. I assume that there should be a pointer to a procedure passed as a parameter not the handle for your form. If you do not have a callback function then maybe you can pass 0 instead of $hwnd. Also, if the Callback is used by the Login function then presumably you must have to set it before you use the Login function. Are you sure that the Login really does not return anything? I don't know anything about openticks, this is all guesswork. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
testmeout Posted June 9, 2007 Author Share Posted June 9, 2007 Can't offer much with what you said so far, but this bit $callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd) looks wrong to me. I assume that there should be a pointer to a procedure passed as a parameter not the handle for your form. If you do not have a callback function then maybe you can pass 0 instead of $hwnd. Also, if the Callback is used by the Login function then presumably you must have to set it before you use the Login function. Are you sure that the Login really does not return anything? I don't know anything about openticks, this is all guesswork. Thanks for the reply, it is not actually a callback that is just poorly written code by me. I am calling an open source dll wrapper which has 2 options message based events and callbacks. I decided on message based events. Here is the setup for it Message based events Use this OR callback ptr table events - but NOT both (see Callback ptr table events) (see notes above) This function allows you to set a Windproc handle that all message event will be sent too. The message number constants are defined in the API, eg. "OTFEED_xxx". A message is sent when the matching event occurs. BOOL SetCallbackWindProcHandle(HWND hwnd); Returns false or true on success. I have added Return $GUI_RUNDEFMSG on my onlogin function and after doing so it actually worked, but it only seemed to work acouple of times, it is not consistent. 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