testmeout Posted June 10, 2007 Share Posted June 10, 2007 So I am getting really close to being able to complete my script, but I am running into a problem accessing the array from lParam. Here is the part of my script causing problems. Func msgrecieved($hwnd,$msg,$w,$l) Select Case $msg = $OTFEED_LISTEXCHANGES $RequestId= _LoWord($w) $exchangecount= _HiWord($w) Dim $Code[$exchangecount] Dim $Title[$exchangecount] Dim $Description[$exchangecount] Dim $SubscriptionURL[$exchangecount] Dim $Available[$exchangecount] Dim $struct[$exchangecount] For $i = 1 To $exchangecount $struct[$i]= DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, $l) $size = DllStructGetSize($struct[$i]) $Code[$i]=DllStructGetData($struct[$i], "Code") $Title[$i]=DllStructGetData($struct[$i], "Title") $Description[$i]=DllStructGetData($struct[$i], "Description") $SubscriptionURL[$i]=DllStructGetData($struct[$i], "SubscriptionURL") $Available[$i]=DllStructGetData($struct[$i], "Available") $l = ($l + $size) ConsoleWrite("listExchanges: reqId=" &$RequestId&" isAvailable="&$Available[$i]&" title="&$Title[$i]&" code="&$Code[$i]&" description="&$Description[$i]&" url="&$SubscriptionURL[$i]) Next Here is the info from the dll wrapper I am communicating with DllCalls, and then the dll is sending messages, which in this case would be $OTFEED_LISTEXCHANGES ($WM_USER + 2503) OTFEED_LISTEXCHANGES wParam = (LOWORD)RequestId, (HIWORD)exchangecount; lParam = (LPARAM)(OTFEEDMSG_EXCHANGE*); This message returns a pointer to the first exchange in an array. The HIWORD of wParam contains the number of exchanges in the array. [b]Increament the lParam value by sizeof(OTFEEDMSG_EXCHANGE) to read the next exchange array data.[/b] This data is kept in permanent memory - until app closes, or a new call to RequestListExchanges(), will delete this data and return a new base address for the array. typedef struct _OTFEEDMSG_EXCHANGE { char Code[SHORT_STR_LEN]; char Title[TITLE_STR_LEN]; char Description[DESCRIP_STR_LEN]; char SubscriptionURL[URL_PATH_LEN]; BOOL Available; } OTFEEDMSG_EXCHANGE; I can get it to return the first exchange in the array just fine, but cant get anything past that. What is the best way to write this? How can I Increament the lParam value by sizeof(OTFEEDMSG_EXCHANGE)? Thanks Link to comment Share on other sites More sharing options...
testmeout Posted June 10, 2007 Author Share Posted June 10, 2007 Does anyone have any ideas or can point me in the right direction? I know that the lParam is 0x01980048 and the structure size is 932. So when I manually add them it works, I can get other entries. Ex DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, 26741556) DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, 26742488) DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, 26743420) Do I even need to have DllStructCreate to recieve the message from the external dll? Link to comment Share on other sites More sharing options...
PaulIA Posted June 11, 2007 Share Posted June 11, 2007 Does anyone have any ideas or can point me in the right direction? I know that the lParam is 0x01980048 and the structure size is 932. So when I manually add them it works, I can get other entries. Ex DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, 26741556) DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, 26742488) DllStructCreate($StructDef_OTFEEDMSG_EXCHANGE, 26743420) Do I even need to have DllStructCreate to recieve the message from the external dll?No way to test this, but this is how I would write it: Opt("MustDeclareVars", 1) ; Set constants below to their real values Global Const $OTFEED_LISTEXCHANGES = 0 Global Const $tagOTFEEDMSG_EXCHANGE = "" Func MsgRecieved($hWnd, $Msg, $wParam, $lParam) Local $iRequestID, $iCount, $iI, $tStruct, $sCode, $sTitle, $sDescription, $sSubscriptionURL, $fAvailable if $Msg = $OTFEED_LISTEXCHANGES then $iRequestID = _LoWord($wParam) $iCount = _HiWord($wParam) For $iI = 1 To $iCount $tStruct = DllStructCreate ($tagOTFEEDMSG_EXCHANGE, $lParam) $sCode = DllStructGetData($tStruct, "Code" ) $sTitle = DllStructGetData($tStruct, "Title" ) $sDescription = DllStructGetData($tStruct, "Description" ) $sSubscriptionURL = DllStructGetData($tStruct, "SubscriptionURL") $fAvailable = DllStructGetData($tStruct, "Available" ) $lParam += DllStructGetSize($tStruct) ConsoleWrite("OTFEED_LISTEXCHANGES: " & $iI) ConsoleWrite(" Request ID .......: " & $iRequestID & @CR) ConsoleWrite(" Available ........: " & $fAvailable & @CR) ConsoleWrite(" Title ............: " & $sTitle & @CR) ConsoleWrite(" Code .............: " & $sCode & @CR) ConsoleWrite(" Description ......: " & $sDescription & @CR) ConsoleWrite(" Subscription URL .: " & $sSubscriptionURL & @CR) ConsoleWrite(@CR) Next endif EndFunc Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
testmeout Posted June 11, 2007 Author Share Posted June 11, 2007 PaulIA, Thanks for replying, but unfortunately it didn't work. Your script just like mine only returns the first entry in the array. I don't know if its a bug in autoit or the code is written wrong, but for whatever reason it won't change the value of $lParam, it stays the same value and therefore the data is repeated. Any other ideas? Should I post in the bug section? If you are willing to look over my code I would be more than happy to post the full thing. I plan on submitting it to the community once I am done. Interfacing to opentick, would be valuable to those in the financial stock trading realm Link to comment Share on other sites More sharing options...
PaulIA Posted June 11, 2007 Share Posted June 11, 2007 (edited) PaulIA,Thanks for replying, but unfortunately it didn't work. Your script just like mine only returns the first entry in the array. I don't know if its a bug in autoit or the code is written wrong, but for whatever reason it won't change the value of $lParam, it stays the same value and therefore the data is repeated.Any other ideas? Should I post in the bug section?If you are willing to look over my code I would be more than happy to post the full thing. I plan on submitting it to the community once I am done. Interfacing to opentick, would be valuable to those in the financial stock trading realmBefore you jump the gun, you need to put in some debug code to figure out what's wrong with your code. In the function, print out the values (like $iI, $lParam, etc) on every loop. I do the same thing with pointers to structures in the Auto3Lib eventlog modules, so I I'm sure it's not an AutoIt problem. If you're still stuck, you can PM me a zip file with the full code, dll, etc. and I would be willing to take a look at it for you. Edited June 11, 2007 by PaulIA Auto3Lib: A library of over 1200 functions for AutoIt 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