Wena Posted April 15, 2014 Share Posted April 15, 2014 Hi All I am trying to read a DLL but I am not getting a return code. It is supposed to return the KEYLOCK position on a Tipro POS keyboard. Below is from the CHM of the Tipro software: KeylockScanPosition Syntax int KeylockScanPosition (int nKeylockNum, unsigned char *nKeyData); Below is my code: $dlll = DllOpen("C:\Windows\System32\WKMidApi.dll") $POS = DllCall($dlll, "int","KeylockScanPosition") MsgBox(0,"pos","POS=" & $POS & " " & "error=" & @error) DllClose($dlll) (I am by no means a programmer and normally use Autoit for basic needs.) Kind Regards Wena Link to comment Share on other sites More sharing options...
FireFox Posted April 15, 2014 Share Posted April 15, 2014 Hi, The DllCall function returns an array (see helpfile). So it's not e.g $POS, but $POS[0] for the return value. Br, FireFox. Link to comment Share on other sites More sharing options...
Wena Posted April 15, 2014 Author Share Posted April 15, 2014 Hi Thanks for the quick reply I am getting "send dont send errors" now. Are there include files that I need to add? BR Wena Link to comment Share on other sites More sharing options...
JohnOne Posted April 15, 2014 Share Posted April 15, 2014 For a start it takes 2 parameters but you pass it none. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Wena Posted April 16, 2014 Author Share Posted April 16, 2014 Hi I think this is over my head. I have read and reread the help file and I am getting no where. I added some parameters( purely guess work as I have no idea what parameters to use) and at least the "send don't send has gone". I am getting error 11 which is "API function parameter refers to non existing module". I will google some more to learn about this. Thanks for all the help. Alistair Link to comment Share on other sites More sharing options...
JohnOne Posted April 16, 2014 Share Posted April 16, 2014 KeylockScanPosition Syntax int KeylockScanPosition (int nKeylockNum, unsigned char *nKeyData); Is that the whole documentation/ AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Wena Posted April 16, 2014 Author Share Posted April 16, 2014 Hi Below is the rest of the page. ******* Parameter Description nKeylockNum Keylock module reference number looking from the left side of the configuration. nKeyData Current keylock position number. Remark Scans keylock and returns current keylock position number. ******* It also has sample code, below is a vbscript supplied: **** Public Declare Function KeylockScanPosition Lib "WKMidApi" (ByVal nKeyLockNum As Integer, _ ByRef nKeyData As Byte) As Integer '/* Scans keylock and returns current keylock position. */ '/* arguments (IN) : selected Keylock module number */ '/* arguments (OUT) : current keylock position number */ '/* return value : command status : 0 == OK, else error code */ ******* KR Alistair Link to comment Share on other sites More sharing options...
JohnOne Posted April 16, 2014 Share Posted April 16, 2014 (edited) Function should probably look more like this... Func _KeylockScanPosition($nKeylockNum) ;$nKeyData = DllStructCreate('byte') ; test 1 $nKeyData = DllStructCreate('byte[1]') ; test 2 $POS = DllCall("WKMidApi.dll", "int", "KeylockScanPosition", 'int', $nKeylockNum, 'ptr', DllStructGetPtr($nKeyData)) $Error = @error ConsoleWrite('DllCall @error state -: ' & $Error & @LF) If Not $Error Then ;Return DllStructGetData($nKeyData, 1) ; test 1 Return DllStructGetData($nKeyData, 1, 1); test 2 EndIf Return SetError(1, 0, 0) EndFunc ;==>_KeylockScanPosition Although I have no Idea what nKeyLockNum actually is, but you definately need to know that, and pass it. EDIT: It may also be the case that you just pass $nKeyData rather than a pointer to it. So you might also try removing DllStructGetPtr(). EDIT2: It is also possible that the out param is infact of int size and wants a byte array of 'byte[4]'. I'd also just try passing struct of 'int' Edited April 16, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted April 16, 2014 Share Posted April 16, 2014 I think the right way is struct* and not ptr Link to comment Share on other sites More sharing options...
JohnOne Posted April 16, 2014 Share Posted April 16, 2014 Probably. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Wena Posted April 17, 2014 Author Share Posted April 17, 2014 Hi Guys I am not ignoring your posts and suggestions. I am busy testing some of the examples given. I had to remove the func as it (for some reason) when run it ignored it. I tested this with a message box before and after func. I have got a little further, I am now getting a hex code return but an error "11" which is "API function parameter refers to non existing module". I also have found out that the first parameter is "int, 1 Regards Wena Link to comment Share on other sites More sharing options...
JohnOne Posted April 17, 2014 Share Posted April 17, 2014 Post your full existing code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Wena Posted April 17, 2014 Author Share Posted April 17, 2014 Hi I put comments in of what is happenning. If FileExists("c:\windows\system32\WKMidApi.dll") Then $nKeyData = DllStructCreate("char[7]") ; test 2 $dopen = DllOpen("c:\windows\system32\WKMidApi.dll") $POS = DllCall($dopen, "int", "KeylockScanPosition", "int", 1, "ptr", DllStructGetPtr($nKeyData)) ;I am sure the ptr should be an unassigned char "UChar" but nothing in the help file about this. $data = DllStructGetData($nKeyData, 1, 1) MsgBox(0, "pos", $POS[0]) ;get return of 11 MsgBox(0, "pos", $POS[1]) ;get return of 1 MsgBox(0, "pos", $POS[2]) ;get return of hex number (changes after each compile) DllClose($dopen) Else MsgBox(0, "Notexists", "Notexists") EndIf KR Alistair Link to comment Share on other sites More sharing options...
JohnOne Posted April 17, 2014 Share Posted April 17, 2014 I believe that char is used for uchar, you could probably use also byte or booloean for uchar. Without knowing exactly what this library is for or does it's difficult to know what's going on. Maybe you have a link to somewhere to see how this call is used practically in code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted April 17, 2014 Share Posted April 17, 2014 Please attach your Dll or PM me and I'll try to have a successful dllcall. Link to comment Share on other sites More sharing options...
Danp2 Posted April 17, 2014 Share Posted April 17, 2014 Have you tried issuing the DllCall command using "byte *" instead of "ptr"? $POS = DllCall($dopen, "int", "KeylockScanPosition", "int", 1, "byte *", DllStructGetPtr($nKeyData)) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
FireFox Posted April 17, 2014 Share Posted April 17, 2014 (edited) byte* does not exist (in autoit), it's struct* Edited April 17, 2014 by FireFox Link to comment Share on other sites More sharing options...
Danp2 Posted April 17, 2014 Share Posted April 17, 2014 You may be correct. However, the help file shows BYTE as a valid type, so I figured byte* would work. Latest Webdriver UDF Release Webdriver Wiki FAQs 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