Jump to content

Pls help me convert this code(vb) to autoit. thanks so much!


Recommended Posts

Welcome to AutoIt and the forum,

Can't you post the VB script here? Downloading and unpacking the file is a lot of work before we notice that we can't help.

What is the VB script all about?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

water didn't say the link wasn't working, he asked if you could post the code here please. Thank you.

For example...

; Some VBScript code.
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

frmUSB.vb

Public Class frmUSB
' vendor and product IDs
Private Const VendorID As Integer = &H1234 'Replace with your device's
Private Const ProductID As Integer = &H1234 'product and vendor IDs

' read and write buffers
Private Const BufferInSize As Integer = 64 'Size of the data buffer coming IN to the PC
Private Const BufferOutSize As Integer = 64 'Size of the data buffer going OUT from the PC
Dim BufferIn(BufferInSize) As Byte 'Received data will be stored here - the first byte in the array is unused
Dim BufferOut(BufferOutSize) As Byte 'Transmitted data is stored here - the first item in the array must be 0

' ****************************************************************
' when the form loads, connect to the HID controller - pass
' the form window handle so that you can receive notification
' events...
'*****************************************************************
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' do not remove!
ConnectToHID(Me)
Label2.Text = "DISCONNECT"
Label2.ForeColor = Color.Red
GroupBox1.Hide()
GroupBox2.Hide()
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
OvalShape1.BackColor = Color.Blue
OvalShape2.BackColor = Color.Blue
OvalShape3.BackColor = Color.Blue
OvalShape4.BackColor = Color.Blue
OvalShape5.BackColor = Color.Blue
OvalShape6.BackColor = Color.Blue
OvalShape7.BackColor = Color.Blue
OvalShape8.BackColor = Color.Blue
End Sub

'*****************************************************************
' disconnect from the HID controller...
'*****************************************************************
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
DisconnectFromHID()
End Sub

'*****************************************************************
' a HID device has been plugged in...
'*****************************************************************
Public Sub OnPlugged(ByVal pHandle As Integer)
If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
' ** YOUR CODE HERE **
Label2.Text = "CONNECTED"
Label2.ForeColor = Color.Green
GroupBox1.Show()
GroupBox2.Show()
End If
End Sub

frmUSB.Designer.vb

_
Partial Class frmUSB
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
 _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
 _
Private Sub InitializeComponent()
Me.CheckBox1 = New System.Windows.Forms.CheckBox()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.CheckBox8 = New System.Windows.Forms.CheckBox()
Me.CheckBox7 = New System.Windows.Forms.CheckBox()
Me.CheckBox6 = New System.Windows.Forms.CheckBox()
Me.CheckBox5 = New System.Windows.Forms.CheckBox()
Me.CheckBox4 = New System.Windows.Forms.CheckBox()
Me.CheckBox3 = New System.Windows.Forms.CheckBox()
Me.CheckBox2 = New System.Windows.Forms.CheckBox()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.ShapeContainer2 = New Microsoft.VisualBasic.PowerPacks.ShapeContainer()
Me.OvalShape8 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape7 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape6 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape5 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape3 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape4 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape2 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.OvalShape1 = New Microsoft.VisualBasic.PowerPacks.OvalShape()
Me.Label1 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label2 = New System.Windows.Forms.Label()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
'
'CheckBox1
'
Me.CheckBox1.AutoSize = True
Me.CheckBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox1.Location = New System.Drawing.Point(18, 35)
Me.CheckBox1.Name = "CheckBox1"
Me.CheckBox1.Size = New System.Drawing.Size(60, 24)
Me.CheckBox1.TabIndex = 0
Me.CheckBox1.Text = "RB0"
Me.CheckBox1.UseVisualStyleBackColor = True
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.SystemColors.Menu
Me.GroupBox1.Controls.Add(Me.CheckBox8)
Me.GroupBox1.Controls.Add(Me.CheckBox7)
Me.GroupBox1.Controls.Add(Me.CheckBox6)
Me.GroupBox1.Controls.Add(Me.CheckBox5)
Me.GroupBox1.Controls.Add(Me.CheckBox4)
Me.GroupBox1.Controls.Add(Me.CheckBox3)
Me.GroupBox1.Controls.Add(Me.CheckBox2)
Me.GroupBox1.Controls.Add(Me.CheckBox1)
Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GroupBox1.ForeColor = System.Drawing.Color.Blue
Me.GroupBox1.Location = New System.Drawing.Point(54, 110)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(108, 289)
Me.GroupBox1.TabIndex = 1
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "CONTROL"
'
'CheckBox8
'
Me.CheckBox8.AutoSize = True
Me.CheckBox8.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox8.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox8.Location = New System.Drawing.Point(18, 245)
Me.CheckBox8.Name = "CheckBox8"
Me.CheckBox8.Size = New System.Drawing.Size(60, 24)
Me.CheckBox8.TabIndex = 7
Me.CheckBox8.Text = "RB7"
Me.CheckBox8.UseVisualStyleBackColor = True
'
'CheckBox7
'
Me.CheckBox7.AutoSize = True
Me.CheckBox7.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox7.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox7.Location = New System.Drawing.Point(18, 215)
Me.CheckBox7.Name = "CheckBox7"
Me.CheckBox7.Size = New System.Drawing.Size(60, 24)
Me.CheckBox7.TabIndex = 6
Me.CheckBox7.Text = "RB6"
Me.CheckBox7.UseVisualStyleBackColor = True
'
'CheckBox6
'
Me.CheckBox6.AutoSize = True
Me.CheckBox6.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox6.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox6.Location = New System.Drawing.Point(18, 185)
Me.CheckBox6.Name = "CheckBox6"
Me.CheckBox6.Size = New System.Drawing.Size(60, 24)
Me.CheckBox6.TabIndex = 5
Me.CheckBox6.Text = "RB5"
Me.CheckBox6.UseVisualStyleBackColor = True
'
'CheckBox5
'
Me.CheckBox5.AutoSize = True
Me.CheckBox5.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox5.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox5.Location = New System.Drawing.Point(18, 155)
Me.CheckBox5.Name = "CheckBox5"
Me.CheckBox5.Size = New System.Drawing.Size(60, 24)
Me.CheckBox5.TabIndex = 4
Me.CheckBox5.Text = "RB4"
Me.CheckBox5.UseVisualStyleBackColor = True
'
'CheckBox4
'
Me.CheckBox4.AutoSize = True
Me.CheckBox4.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox4.Location = New System.Drawing.Point(18, 125)
Me.CheckBox4.Name = "CheckBox4"
Me.CheckBox4.Size = New System.Drawing.Size(60, 24)
Me.CheckBox4.TabIndex = 3
Me.CheckBox4.Text = "RB3"
Me.CheckBox4.UseVisualStyleBackColor = True
'
'CheckBox3
'
Me.CheckBox3.AutoSize = True
Me.CheckBox3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox3.Location = New System.Drawing.Point(18, 95)
Me.CheckBox3.Name = "CheckBox3"
Me.CheckBox3.Size = New System.Drawing.Size(60, 24)
Me.CheckBox3.TabIndex = 2
Me.CheckBox3.Text = "RB2"
Me.CheckBox3.UseVisualStyleBackColor = True
'
'CheckBox2
'
Me.CheckBox2.AutoSize = True
Me.CheckBox2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CheckBox2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.CheckBox2.Location = New System.Drawing.Point(18, 65)
Me.CheckBox2.Name = "CheckBox2"
Me.CheckBox2.Size = New System.Drawing.Size(60, 24)
Me.CheckBox2.TabIndex = 1
Me.CheckBox2.Text = "RB1"
Me.CheckBox2.UseVisualStyleBackColor = True
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.ShapeContainer2)
Me.GroupBox2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GroupBox2.ForeColor = System.Drawing.Color.Blue
Me.GroupBox2.Location = New System.Drawing.Point(168, 110)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(93, 289)
Me.GroupBox2.TabIndex = 2
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "STATUS"
'
'ShapeContainer2
'
Me.ShapeContainer2.Location = New System.Drawing.Point(3, 22)
Me.ShapeContainer2.Margin = New System.Windows.Forms.Padding(0)
Me.ShapeContainer2.Name = "ShapeContainer2"
Me.ShapeContainer2.Shapes.AddRange(New Microsoft.VisualBasic.PowerPacks.Shape() {Me.OvalShape8, Me.OvalShape7, Me.OvalShape6, Me.OvalShape5, Me.OvalShape3, Me.OvalShape4, Me.OvalShape2, Me.OvalShape1})
Me.ShapeContainer2.Size = New System.Drawing.Size(87, 264)
Me.ShapeContainer2.TabIndex = 0
Me.ShapeContainer2.TabStop = False
'
'OvalShape8
'
Me.OvalShape8.BackColor = System.Drawing.Color.Blue
Me.OvalShape8.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape8.Location = New System.Drawing.Point(34, 223)
Me.OvalShape8.Name = "OvalShape8"
Me.OvalShape8.Size = New System.Drawing.Size(18, 18)
'
'OvalShape7
'
Me.OvalShape7.BackColor = System.Drawing.Color.Blue
Me.OvalShape7.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape7.Location = New System.Drawing.Point(34, 192)
Me.OvalShape7.Name = "OvalShape7"
Me.OvalShape7.Size = New System.Drawing.Size(18, 18)
'
'OvalShape6
'
Me.OvalShape6.BackColor = System.Drawing.Color.Blue
Me.OvalShape6.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape6.Location = New System.Drawing.Point(34, 162)
Me.OvalShape6.Name = "OvalShape6"
Me.OvalShape6.Size = New System.Drawing.Size(18, 18)
'
'OvalShape5
'
Me.OvalShape5.BackColor = System.Drawing.Color.Blue
Me.OvalShape5.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape5.Location = New System.Drawing.Point(34, 134)
Me.OvalShape5.Name = "OvalShape5"
Me.OvalShape5.Size = New System.Drawing.Size(18, 18)
'
'OvalShape3
'
Me.OvalShape3.BackColor = System.Drawing.Color.Blue
Me.OvalShape3.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape3.Location = New System.Drawing.Point(34, 74)
Me.OvalShape3.Name = "OvalShape3"
Me.OvalShape3.Size = New System.Drawing.Size(18, 18)
'
'OvalShape4
'
Me.OvalShape4.BackColor = System.Drawing.Color.Blue
Me.OvalShape4.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape4.Location = New System.Drawing.Point(34, 106)
Me.OvalShape4.Name = "OvalShape4"
Me.OvalShape4.Size = New System.Drawing.Size(18, 18)
'
'OvalShape2
'
Me.OvalShape2.BackColor = System.Drawing.Color.Blue
Me.OvalShape2.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape2.Location = New System.Drawing.Point(34, 45)
Me.OvalShape2.Name = "OvalShape2"
Me.OvalShape2.Size = New System.Drawing.Size(18, 18)
'
'OvalShape1
'
Me.OvalShape1.BackColor = System.Drawing.Color.Blue
Me.OvalShape1.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque
Me.OvalShape1.Location = New System.Drawing.Point(34, 16)
Me.OvalShape1.Name = "OvalShape1"
Me.OvalShape1.Size = New System.Drawing.Size(18, 18)
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer), CType(CType(0, Byte), Integer))
Me.Label1.Location = New System.Drawing.Point(17, 27)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(308, 24)
Me.Label1.TabIndex = 3
Me.Label1.Text = "PIC-USB I/O CONTROL (DEMO)"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(128, 420)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 62)
Me.Button1.TabIndex = 4
Me.Button1.Text = "&EXIT"
Me.Button1.UseVisualStyleBackColor = True
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Red
Me.Label2.Location = New System.Drawing.Point(118, 67)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(106, 16)
Me.Label2.TabIndex = 5
Me.Label2.Text = "DISCONNECT"
'
'frmUSB
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(333, 496)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "frmUSB"
Me.Text = "USB IO CONTROL - QueDuong "
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents CheckBox8 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox7 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox6 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox5 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox4 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox
Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents ShapeContainer2 As Microsoft.VisualBasic.PowerPacks.ShapeContainer
Friend WithEvents OvalShape8 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape7 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape6 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape5 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape3 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape4 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape2 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents OvalShape1 As Microsoft.VisualBasic.PowerPacks.OvalShape
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label

End Class

mcHIDInterface.vb

Imports System
Imports System.Threading
Imports System.Runtime.InteropServices


Module HIDDLLInterface
' this is the interface to the HID controller DLL - you should not
' normally need to change anything in this file.
'
' WinProc() calls your main form 'event' procedures - these are currently
' set to..
'
' MainForm.OnPlugged(ByVal pHandle as long)
' MainForm.OnUnplugged(ByVal pHandle as long)
' MainForm.onchanged()
' MainForm.OnRead(ByVal pHandle as long)


' HID interface API declarations...
Declare Function hidConnect Lib "mcHID.dll" Alias "Connect" (ByVal pHostWin As Integer) As Boolean
Declare Function hidDisconnect Lib "mcHID.dll" Alias "Disconnect" () As Boolean
Declare Function hidGetItem Lib "mcHID.dll" Alias "GetItem" (ByVal pIndex As Integer) As Integer
Declare Function hidGetItemCount Lib "mcHID.dll" Alias "GetItemCount" () As Integer
Declare Function hidRead Lib "mcHID.dll" Alias "Read" (ByVal pHandle As Integer, ByRef pData As Byte) As Boolean
Declare Function hidWrite Lib "mcHID.dll" Alias "Write" (ByVal pHandle As Integer, ByRef pData As Byte) As Boolean
Declare Function hidReadEx Lib "mcHID.dll" Alias "ReadEx" (ByVal pVendorID As Integer, ByVal pProductID As Integer, ByRef pData As Byte) As Boolean
Declare Function hidWriteEx Lib "mcHID.dll" Alias "WriteEx" (ByVal pVendorID As Integer, ByVal pProductID As Integer, ByRef pData As Byte) As Boolean
Declare Function hidGetHandle Lib "mcHID.dll" Alias "GetHandle" (ByVal pVendoID As Integer, ByVal pProductID As Integer) As Integer
Declare Function hidGetVendorID Lib "mcHID.dll" Alias "GetVendorID" (ByVal pHandle As Integer) As Integer
Declare Function hidGetProductID Lib "mcHID.dll" Alias "GetProductID" (ByVal pHandle As Integer) As Integer
Declare Function hidGetVersion Lib "mcHID.dll" Alias "GetVersion" (ByVal pHandle As Integer) As Integer
Declare Function hidGetVendorName Lib "mcHID.dll" Alias "GetVendorName" (ByVal pHandle As Integer, ByVal pText As String, ByVal pLen As Integer) As Integer
Declare Function hidGetProductName Lib "mcHID.dll" Alias "GetProductName" (ByVal pHandle As Integer, ByVal pText As String, ByVal pLen As Integer) As Integer
Declare Function hidGetSerialNumber Lib "mcHID.dll" Alias "GetSerialNumber" (ByVal pHandle As Integer, ByVal pText As String, ByVal pLen As Integer) As Integer
Declare Function hidGetInputReportLength Lib "mcHID.dll" Alias "GetInputReportLength" (ByVal pHandle As Integer) As Integer
Declare Function hidGetOutputReportLength Lib "mcHID.dll" Alias "GetOutputReportLength" (ByVal pHandle As Integer) As Integer
Declare Sub hidSetReadNotify Lib "mcHID.dll" Alias "SetReadNotify" (ByVal pHandle As Integer, ByVal pValue As Boolean)
Declare Function hidIsReadNotifyEnabled Lib "mcHID.dll" Alias "IsReadNotifyEnabled" (ByVal pHandle As Integer) As Boolean
Declare Function hidIsAvailable Lib "mcHID.dll" Alias "IsAvailable" (ByVal pVendorID As Integer, ByVal pProductID As Integer) As Boolean

' windows API declarations - used to set up messaging...

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Integer, ByVal hwnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer

Delegate Function SubClassProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public Declare Function DelegateSetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" _
(ByVal hwnd As Integer, ByVal attr As Integer, ByVal lval As SubClassProcDelegate) As Integer


' windows API Constants
Public Const WM_APP As Integer = 32768
Public Const GWL_WNDPROC As Short = -4

' HID message constants
Private Const WM_HID_EVENT As Decimal = WM_APP + 200
Private Const NOTIFY_PLUGGED As Short = 1
Private Const NOTIFY_UNPLUGGED As Short = 2
Private Const NOTIFY_CHANGED As Short = 3
Private Const NOTIFY_READ As Short = 4

' local variables
Private FPrevWinProc As Integer ' Handle to previous window procedure
Private FWinHandle As Integer ' Handle to message window
Private Ref_WinProc As New SubClassProcDelegate(AddressOf WinProc)
Private HostForm As Object

' Set up a windows hook to receive notification
' messages from the HID controller DLL - then connect
' to the controller
Public Function ConnectToHID(ByRef targetForm As Form) As Boolean
Dim pHostWin As Integer = targetForm.Handle.ToInt32
FWinHandle = pHostWin
pHostWin = hidConnect(FWinHandle)
FPrevWinProc = DelegateSetWindowLong(FWinHandle, GWL_WNDPROC, Ref_WinProc)
HostForm = targetForm
End Function

' Unhook from the HID controller and disconnect...
Public Function DisconnectFromHID() As Boolean
DisconnectFromHID = hidDisconnect
SetWindowLong(FWinHandle, GWL_WNDPROC, FPrevWinProc)
End Function


' This is the procedure that intercepts the HID controller messages...

Private Function WinProc(ByVal pHWnd As Integer, ByVal pMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
If pMsg = WM_HID_EVENT Then
Select Case wParam

' HID device has been plugged message...
Case Is = NOTIFY_PLUGGED
HostForm.OnPlugged(lParam)

' HID device has been unplugged
Case Is = NOTIFY_UNPLUGGED
HostForm.OnUnplugged(lParam)

' controller has changed...
Case Is = NOTIFY_CHANGED
HostForm.onchanged()

' read event...
Case Is = NOTIFY_READ
HostForm.OnRead(lParam)
End Select

End If

' next...
WinProc = CallWindowProc(FPrevWinProc, pHWnd, pMsg, wParam, lParam)

End Function
End Module

thanks!

Link to comment
Share on other sites

  • Moderators

luong, this forum is dedicated to helping those who want to learn AutoIt, it is not a place where we do free code translation. If you would like to learn AutoIt, I suggest starting with the help file, and then post when you have come up with something yourself. If you're looking to just have this code translated for you, I would suggest the site below:

http://www.vworker.com/

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi JLogan3o13,

At first, i'm a newbie and i love autoit !

I want to send and recieve data between a usb hid device and PC using "mcHID.dll". But i don't know about the functions in "mcHID.dll". That VB code can help me so muck but i don't know anything about VB. If that code is translated to autoit, i will learn esily.

Thank you very much!

Edited by luong
Link to comment
Share on other sites

  • Moderators

Again, we operate on the "teach a man to fish" model. No one wants to sit there and convert this all for you, when you don't seem to be putting forth any effort. You say you love AutoIt - great! Why don't you start with running the VB code, and then trying to generate the GUI in AutoIt? You can look at GUICreate, GUICtrlCreateCheckBox, GUICtrlCreateLable and GUICtrlCreateButton in the help file. Then, once you have done something on your own, post your code and we will be happy to assist :)

Edit: To paraphrase Melba23 - We all know you want to start coding right now. But you're not doing yourself any favors asking someone to just do it for you. Learn to do the basics first, then move on to more complex applications.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Or start with something simpler. The VB code doesn't look like it is a good project to start learning another language.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...