hyperjase Posted January 6, 2015 Share Posted January 6, 2015 Hi, This is my first time attempting to access a DLL file via AutoIT, but I just keep crashing the script editor (presumably because I'm doing something wrong...) My code is- $fOpen = DllOpen ("jeti_core.dll") If $fOpen = -1 Then MsgBox(0,"Warning!","DLL File Not Found") Else DllCall($fOpen,"DWORD",1,"DWORD",0) $sTest = DllCall($fOpen,"DWORD",13,"hwnd",1) MsgBox(0,"",$sTest) EndIf DllClose("jeti_core.dll") Now I'm confident it doesn't work as I have no idea that it is correct, I've had a good search and checked the manual, but from what I see, I'm just not sure how to achieve this. What I'm trying to achieve above it to turn a laser light on in a light calibration unit, which can be accessed through Ordinal #13 (#1 should open the first device). I've attached the part of the manual that relates to this part. Can anyone give me a gentle push in the right direction? Many thanks Link to comment Share on other sites More sharing options...
JohnOne Posted January 6, 2015 Share Posted January 6, 2015 For a start, you did not specify a function in the dll, or a return type. 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...
JohnOne Posted January 6, 2015 Share Posted January 6, 2015 (edited) DllCall($fOpen,"DWORD", "jeti_setlaserstat", "DWORD", 1, "BOOL", 0) Probably a bit more like that from the image you post. Also return from dllcall is an array, please read the helpfile again. Edited January 6, 2015 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...
hyperjase Posted January 6, 2015 Author Share Posted January 6, 2015 Thank you, I shall alter the code and try again - I was so wrapped up in trying to get it working, I didn't take into account that it was an array. Many thanks for the swift response. Link to comment Share on other sites More sharing options...
hyperjase Posted January 6, 2015 Author Share Posted January 6, 2015 Final question; Screenshot attached shows open device, which has dwDevice called by reference, I have to connect first then turn the laser on or off - how do I deal with the reference? Doing some testing I've found that I'm usually not connecting for one and keep ending up with an invalid handle error (using hex to get the code) Link to comment Share on other sites More sharing options...
Danyfirex Posted January 6, 2015 Share Posted January 6, 2015 $Ret=DllCall($fOpen,"DWORD", "JETI_OpenDevice", "dword", 0, "dword*", 0) $hDevice=$Ret[2] Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
hyperjase Posted January 6, 2015 Author Share Posted January 6, 2015 $DLL = DllOpen("jeti_core.dll") $conn = DllCall($DLL,"DWORD", "JETI_OpenDevice", "DWORD", 0, "DWORD", 0) $Test = DllCall($DLL,"DWORD", "JETI_SetLaserStat", "DWORD", 0, "BOOL", 1) MsgBox(0,"",Hex($Test[0])) Running that results in 0000000000000015 which checking in the SDK manual gives me an error of "invalid device handle". Sorry if I'm being thick, uncharted territory for me! Link to comment Share on other sites More sharing options...
JohnOne Posted January 6, 2015 Share Posted January 6, 2015 Look again atn the example given to open device. 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...
hyperjase Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) Thanks - I understand how the asterisk now integrates with this (also found a handy PDF quick guide and followed that example). The code I now have is $DLL = DllOpen("jeti_core.dll") Local $Ret Local $hDevice Local $Close Local $cDevice ; Open Device #0 $Ret = DllCall($DLL,"DWORD", "JETI_OpenDevice", "DWORD", "0", "DWORD*", $hDevice) $hDevice = $Ret[1] ; Set laser BOOL = 1 DllCall($DLL,"DWORD", "JETI_SetLaserStat", "DWORD", $hDevice, "BOOL", 1) ; Close Device $Close = DllCall($DLL,"DWORD", "JETI_CloseDevice", "DWORD", $hDevice) $cDevice = $Close[1] ; $hDevice gives us 0000000000000000 code which according to Jeti manual = JETI_SUCCESS MsgBox(0,"",Hex($hDevice)) But still doesn't turn the laser on -- have I got this right? Was making good progress using the MsgBox to show what error codes I ended up with - what I have here seems to return sucess from open and close. Edited January 8, 2015 by hyperjase Link to comment Share on other sites More sharing options...
Danyfirex Posted January 8, 2015 Share Posted January 8, 2015 (edited) try to pass the index without put "0" just use 0. (lol I don't remember how to write "" in english) Saludos Edited January 8, 2015 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
hyperjase Posted January 8, 2015 Author Share Posted January 8, 2015 Sadly makes no difference; still getting a 0x00 code meaning connected OK, but I'm not totally convinced it's working. Link to comment Share on other sites More sharing options...
JohnOne Posted January 8, 2015 Share Posted January 8, 2015 Show exact current 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...
hyperjase Posted January 8, 2015 Author Share Posted January 8, 2015 I've gone a little more specific with targeting the unit, namely selecting the COM port (3) and baud rate (9600). Here is the current code: $DLL = DllOpen("jeti_core.dll") Local $Ret Local $hDevice Local $Close Local $cDevice ; Open Device #0 $Ret = DllCall($DLL,"DWORD", "JETI_OpenCOMDevice", "DWORD", "3", "DWORD", "9600", "DWORD*", $hDevice) $hDevice = $Ret[3] ; Set laser BOOL = 1 DllCall($DLL,"DWORD", "JETI_SetLaserStat", "DWORD", $hDevice, "BOOL", 1) ; Close Device $Close = DllCall($DLL,"DWORD", "JETI_CloseDevice", "DWORD", $hDevice) $cDevice = $Close[1] ; $hDevice gives us 0000000000000000 code which according to Jeti manual = JETI_SUCCESS MsgBox(0,"",Hex($hDevice)) The one thing I'm curious about is $hDevice become the handle? As I find I keep getting 0000000000000015 codes which are "JETI_INVALID_HANDLE" Link to comment Share on other sites More sharing options...
JohnOne Posted January 8, 2015 Share Posted January 8, 2015 do you have a link to full dll 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...
hyperjase Posted January 8, 2015 Author Share Posted January 8, 2015 I've attached the whole PDF file. JETI_SDK_Programmers_Guide_Core.pdf Link to comment Share on other sites More sharing options...
Danyfirex Posted January 8, 2015 Share Posted January 8, 2015 mate try with JETI_GetNumDevices. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
hyperjase Posted January 8, 2015 Author Share Posted January 8, 2015 I've been testing with that possibility but can't get back useful info - I always seem to find zero devices. Link to comment Share on other sites More sharing options...
JohnOne Posted January 8, 2015 Share Posted January 8, 2015 Then it would appear the problem is not a scripting one, rather a connectivity one, a dll one. 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...
JohnOne Posted January 8, 2015 Share Posted January 8, 2015 How is your device connected? 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...
JohnOne Posted January 8, 2015 Share Posted January 8, 2015 (edited) Try... $DLL = DllOpen("jeti_core.dll") $STRUCT = DllStructCreate("DWORD") $CALL = DllCall($DLL, "DWORD", "JETI_GetNumDevices", "DWORD*", DllStructGetPtr($STRUCT)) If Not $CALL[0] Then MsgBox(0, "Num:", DllStructGetData($STRUCT, 1)) DllClose($DLL) Exit EndIf DllClose($DLL) MsgBox(0, "Num:", "Error") Edited January 8, 2015 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...
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