dnsi Posted October 9, 2006 Posted October 9, 2006 Ive been trying to do that but no luck... My Programs:Flip-Flop File Encryption SysyemMULTIPLAYER-SOCKETSERVERHide An Archive In A Picture
joseLB Posted October 10, 2006 Posted October 10, 2006 (edited) I think I got a solution (that's in mikroe - PIC). the link: http://www.mikroe.com/forum/viewtopic.php?t=7296It's a program that generates code in VB, Delphi or C++ and have a dll to handle most of the job. Someone would need to translate the code from PASCAL to AutoIt ... (mostly the DLL calls and events), I'm not the right person... Where to get the generator program: http://www.mecanique.co.uk/software/EasyHID.zip . I also attached a zip with all the generated Delphi Pascal and the dll help file.Now, the generated dll declarations expandcollapse popupunit cUSBInterface; interface uses Windows,Messages; const // the plugin manager DLL name... DLL_NAME = 'mcHID.dll'; // DLL interface functions... function Connect(pHostWin:HWND):BOOL;stdcall;external DLL_NAME name 'Connect'; function Disconnect:BOOL;stdcall;external DLL_NAME name 'Disconnect'; function GetItem(pIndex:UINT):UINT;stdcall;external DLL_NAME name 'GetItem'; function GetItemCount:UINT;stdcall;external DLL_NAME name 'GetItemCount'; function Read(pHandle:UINT;pData:pointer):BOOL;stdcall;external DLL_NAME name 'Read'; function Write(pHandle:UINT;pData:pointer):BOOL;stdcall;external DLL_NAME name 'Write'; function ReadEx(pVendorID,pProductID:UINT;pData:pointer):BOOL;stdcall;external DLL_NAME name 'ReadEx'; function WriteEx(pVendorID,pProductID:UINT;pData:pointer):BOOL;stdcall;external DLL_NAME name 'WriteEx'; function GetHandle(pVendorID,pProductID:UINT):UINT;stdcall;external DLL_NAME name 'GetHandle'; function GetVendorID(pHandle:UINT):UINT;stdcall;external DLL_NAME name 'GetVendorID'; function GetProductID(pHandle:UINT):UINT;stdcall;external DLL_NAME name 'GetProductID'; function GetVersion(pHandle:UINT):UINT;stdcall;external DLL_NAME name 'GetVersion'; function GetVendorName(pHandle:UINT;pText:LPSTR;pLen:UINT):UINT;stdcall;external DLL_NAME name 'GetVendorName'; function GetProductName(pHandle:UINT;pText:LPSTR;pLen:UINT):UINT;stdcall;external DLL_NAME name 'GetProductName'; function GetSerialNumber(pHandle:UINT;pText:LPSTR;pLen:UINT):UINT;stdcall;external DLL_NAME name 'GetSerialNumber'; function GetInputReportLength(pHandle:UINT):UINT;stdcall;external DLL_NAME name 'GetInputReportLength'; function GetOutputReportLength(pHandle:UINT):UINT;stdcall;external DLL_NAME name 'GetOutputReportLength'; procedure SetReadNotify(pHandle:UINT;pValue:BOOL);stdcall;external DLL_NAME name 'SetReadNotify'; function IsReadNotifyEnabled(pHandle:UINT):BOOL;stdcall;external DLL_NAME name 'IsReadNotifyEnabled'; function IsAvailable(pVendorID,pProductID:UINT):BOOL;stdcall;external DLL_NAME name 'IsAvailable'; implementation end. ---------------------------------------------- unit cUSBInterfaceTypes; interface uses Windows, Classes, Messages; const WM_HID_EVENT = WM_APP + 200; NOTIFY_PLUGGED = $0001; NOTIFY_UNPLUGGED = $0002; NOTIFY_CHANGED = $0003; NOTIFY_READ = $0004; implementation end. Now, the main program (see that funcTForm1.USBEvent is a dll event activated procedure) expandcollapse popupunit FormMain; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; const // input and out buffer size constants... BufferInSize = 8; BufferOutSize = 8; type // input and output buffers... TBufferIn = array[0..BufferInSize] of byte; TBufferOut = array[0..BufferOutSize] of byte; // main form TForm1 = class(TForm) Memo1: TMemo; Edit1: TEdit; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Edit1Change(Sender: TObject); private FBufferIn:TBufferIn; FBufferOut:TBufferOut; function USBEvent(var Msg: TMessage): Boolean; public end; var Form1: TForm1; implementation uses cUSBInterface, cUSBInterfaceTypes; const // vendor and product ID constants... VENDOR_ID = $1234; PRODUCT_ID = 0001; {$R *.DFM} { **************************************************************************** * Name : Create * * Purpose : Create the main form * **************************************************************************** } procedure TForm1.FormCreate(Sender: TObject); begin Application.HookMainWindow(USBEvent); Connect(Application.Handle); end; { **************************************************************************** * Name : Destroy * * Purpose : Free the main form * **************************************************************************** } procedure TForm1.FormDestroy(Sender: TObject); begin Application.UnHookMainWindow(USBEvent); end; { **************************************************************************** * Name : USBEvent * * Purpose : DLL message handler hook * **************************************************************************** } function TForm1.USBEvent(var Msg: TMessage): Boolean; var DevHandle:cardinal; // TextBuffer:array[0..255] of char; begin result := False; if Msg.Msg = WM_HID_EVENT then begin case Msg.WParam of // a HID device has been plugged in... NOTIFY_PLUGGED : begin // is it our HID device... DevHandle := Msg.LParam; // handle of HID device in this message if (GetVendorID(DevHandle) = VENDOR_ID) and (GetProductID(DevHandle) = PRODUCT_ID) then begin Caption := 'Cool'; // add your code here, for example... // GetProductName(DevHandle, TextBuffer, 256); // ALabel.Caption := string(TextBuffer); end; result := true; end; // a HID device has been device removed... NOTIFY_UNPLUGGED : begin // is it our HID device... DevHandle := Msg.LParam; // handle of HID device in this message if (GetVendorID(DevHandle) = VENDOR_ID) and (GetProductID(DevHandle) = PRODUCT_ID) then begin Caption := 'Oops'; // add you code here end; result := true; end; // a HID device has been attached or removed. This event is fired after // either NotifyPlugged or NotifyUnplugged. NOTIFY_CHANGED : begin // get the handle of the device we are interested in // and set it's read notification flag to true... DevHandle := GetHandle(VENDOR_ID,PRODUCT_ID); SetReadNotify(DevHandle,true); result := true; end; // a HID device has sent some data.. NOTIFY_READ : begin DevHandle := Msg.LParam; // handle of HID device in this message if (GetVendorID(DevHandle) = VENDOR_ID) and (GetProductID(DevHandle) = PRODUCT_ID) then begin // read the data - remember that first byte is report ID... Read(DevHandle,@FBufferIn); Memo1.Lines.Text := Memo1.lines.Text + chr(fbufferin[1]); // process data here... end; result := true; end; end; end; end; (* if you want to write some data to the USB device, then try using something like this... // first element is report ID, set to 0... FBufferOut[0] := $0; // fill the buffer with some data... for index := 1 to BufferOutSize do FBufferOut[index] := index; DevHandle := GetHandle(VendorID, ProductID); Write(DevHandle,@FBufferOut); *) procedure TForm1.Edit1Change(Sender: TObject); var s: string; begin s := Edit1.Text; if s = '' then Exit; fbufferout[0] := 0; fbufferout[1] := ord(s[Length(s)]); Write(GetHandle(Vendor_ID, Product_ID), @fbufferout); end; end.mcHID.zipUSB_easyhid_Pascal.zipJose and drdelphi Edited October 10, 2006 by joseLB
dnsi Posted October 14, 2006 Posted October 14, 2006 How do you write to The USB like a wireless commuator? My Programs:Flip-Flop File Encryption SysyemMULTIPLAYER-SOCKETSERVERHide An Archive In A Picture
dnsi Posted October 14, 2006 Posted October 14, 2006 And I dont Get what you just said My Programs:Flip-Flop File Encryption SysyemMULTIPLAYER-SOCKETSERVERHide An Archive In A Picture
Confuzzled Posted October 15, 2006 Posted October 15, 2006 How do you write to The USB like a wireless commuator? What is this?Just to get this clear - the low level USB drivers make the USB device pretend it is a generic serial port, so any serial port software should technically work as long as you match up the port numbers and speeds - am I correct?
Somerset Posted October 15, 2006 Posted October 15, 2006 What is this?Just to get this clear - the low level USB drivers make the USB device pretend it is a generic serial port, so any serial port software should technically work as long as you match up the port numbers and speeds - am I correct?Sounds like it should,but you are talking about drivers and that is hinky unto itself.
myspacee Posted June 9, 2008 Posted June 9, 2008 interesting read... anyone know if is possible to intercept HID value from usb pheripericals ? [like wiimote] miss source for all best programs to detect wiimote over PC (glovepie and WiinRemote) maybe is possible to have our wiimote utility (maybe a boost for autoit site) Sorry for bad english, m.
seesoe Posted June 15, 2008 Posted June 15, 2008 this is old i guess but just wanted to say my 2 cents. looks to me like your programing a pic via serial port, now you changed that to usb with a bluetooth usb dongle. i have the same setup with gps, its a serial gps unit that has bluetooth, so i got my bluetooth dongle and used blue solairs to make a virtual serial com port. then i used autoit's com port udf to read and if you want write raw data to the port, just like a terminal connection. check the forums for AUtoogle tracker, cheers!
weasel5i2 Posted April 21, 2014 Posted April 21, 2014 I believe that what you need to do is set up a SPP serial port between the device and the Bluetooth host (the computer) and then, using the COM: port which should be created, follow the isntructions found >here. Sorry for the ancient thread resurrection, but this should answer the OP question.
Moderators Melba23 Posted April 21, 2014 Moderators Posted April 21, 2014 weasel5i2,But after nearly 8 years do you really think the OP is still interested? Please do not necro-post this far back again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts