I know that this theme was discussed several times but I read all These threats with no helping result.
I have two pieces of TEMPer1F USB Thermometer.
It is a Standard Windows HID device with no add. Driver needed.
With the device I got an App reading from it and showing Graphs and much more and which can handle several devices.
With the Software came also a RDingUSB.dll file handling the communication with the device.
I can call the dll without any error. But the Problem is how to Access the device using the DLL and Access more than one of same VID/PID
by Serial or anything else useful.
I have also sources in c# doing the Job, but no experience in C# to successfuly port it to AutoIT.
So my question: Can anyone help me to realize the simple pull of the temperature value from the devices based on C# source?
The rest to write it to MySQL DB and repeat it etc. is no Problem for me.
The C# part with the DLL functions class:
internal class RDing
public static extern IntPtr OpenUSBDevice(int VID, int PID);
public static extern IntPtr CloseUSBDevice(IntPtr hDevice);
public static extern bool WriteUSB(IntPtr hDevice, byte pBuffer, uint dwBytesToWrite, ref ulong lpNumberOfBytesWritten);
public static extern bool ReadUSB(IntPtr hDevice, byte pBuffer, uint dwBytesToRead, ref ulong lpNumberOfBytesRead);
public static extern ushort GetInputLength(IntPtr hDevice);
public static extern ushort GetOutputLength(IntPtr hDevice);
public static extern uint GetErrorMsg(ref string lpErrorMsg, uint dwErrorMsgSize);
The C# code snippet working with the functions of the class above is in the attachment
this is the interesting part where the data is sent and pulled which I
do not understand to transcode to AutoIT
Important my devices are the type2 (TEMPer1F) :
So in the end I Need: Call DLL, read all devices in array
Loop the Array until ubound(Array) and for each device in Array read the temperature value and prepare the data to
decimal 6,1 (SQL Format) and °C
So how to pull the value from the devices?
Maybe somwbody finds the important part in the C# (the code above is for different models, mine is TEMPer1F
Or maybe someone has solved this and has maybe a uDF for this
Edit: If you already read this post, I updated it to better fit the scope of what I want to do.
My goal is to be able to read the raw output from a usb type controller (or mouse or keyboard, don't want it to be controller-only) so i can see how / what changes when i hit buttons. I've gotten as far as finding HID page documentation and documentation for the device Struct, but I don't know where to go from here
How do I tell what and Useage to use for any given controller / Keyboard / Mouse? How do I get a list of all HID devices connected and their UsagePage / Usage? How do I register multiple devices / get raw input from multiple devices at once? Here is the modified example script i am using:
#include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Opt('TrayAutoPause', 0) Global $iFlagsOld = 0, $iDataOld = 0 ; Create GUI Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 212, @DesktopWidth - 179, @DesktopHeight - 283, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST) ; To obtain the values of "UsagePage" and "Usage" members of this structure read HID Usage Tables documentation ; http://www.usb.org/developers/devclass_docs/HID1_11.pdf ; Disregaurd that, official USB documention = useless. Here is a human/normal-person friendly list ; http://www.freebsddiary.org/APC/usb_hid_usages.php ; Information on the Struct (eg what Flags and hTarget do) can be found here ; https://msdn.microsoft.com/en-us/library/ms645565(v=vs.85).aspx Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x06) ; Mouse DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) ; This flag makes window hTarget accept input even when it's not active. MUST define hTarget DllStructSetData($tRID, 'hTarget', $g_hForm) ; The target window that will be sent events, used with some Flags ; Register HID input to obtain row input _WinAPI_RegisterRawInputDevices($tRID) ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') ;~ GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $g_hForm Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then Local $iFlags = DllStructGetData($tRIM, 'Flags') Local $sFlag = "", $sData = "" $iFlags = DllStructGetData($tRIM, 'ButtonFlags') If $iFlags <> $iFlagsOld Then $sFlag = $iFlags $iFlagsOld = $iFlags EndIf $iData = DllStructGetData($tRIM, 'ButtonData') If $iData <> $iDataOld Then $sData = $iData $iDataOld = $iData EndIf If $sFlag&$sData <> "" Then ConsoleWrite($sFlag&" "&$sData&@CRLF) EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT
For a model railway project only. Using multiple rfid readers. These readers have no PID or VID or serial numbers.
Only difference is the hub/port number allocated.
Using Win7 32 bit.
The only information I need to obtain from the HID devices is:
last string transmitted. (14 character string of the rfid tag number)
timestamp of the latest reading.
The tag data will be moved to excel immediately after received by usb ready for the next read. Timestamp and data would be overwritten by next set of data.
the GUI would have single line for each reader (by hub/port #) with 3 headings. Timestamp, 14 character data, and hub/port # .
Is it possible for Autoitscript to have a GUI to do this ?
Hey im looking to rebind my wasd keys to arrow keys in order to play a game using my phone and chrom remote access. I tried using controlsend to send a arrow keys when i push wasd. Problem lies in that it sends both w (for example) and the up arrow key aswell as asd etc. Any ideas how to get around this?
The scenario is thus: You have a button on a gui, and it does an action that takes some time - let's just assume it is a sleep(20000).
The user clicks the button, the script does it's thing. HOWEVER if the user gets impatient and clicks the button again before it finishes, or if they spam the button, you will get an endless looping of the function over and over.
Is there any way that if I had a function that took a while to run, and someone clicked the button to start/restart it again, that I could immediately kill/return the function instead of waiting for it to finnish? Or would there be a way to disable the gui from accepting and clicks or keystrokes until the current function finishes executing? My goal is to avoid the pressing the button twenty times impatiently making it do the same thing over and over.