Link to home
Start Free TrialLog in
Avatar of hank2011
hank2011

asked on

I need help with this VB program

I have a keypad that i use on my keyboard for music I need help with the vb script to make it work right I would like to instead of just tapping each button once on the xkeys keypad, can the programming be altered to take in 'double button' inputs.  I would like to alter some of the buttons to accept double digit inputs.  To try to describe it, you would tap '00' , '01' , '02' , .. and so on all the way to '99'.
What this would allow me to do, would be to have 100 commands contained within those 10 buttons.  That's the way I have a keypad set up now that I'm using..but that keypad is so old already and the software has stability issues as os's keep evolving.  It's called 'AutoKEY' and it dates back to the win95 days (see attached image).
. if any one can help with this i would be so much greatful. the code is here
'=?=?=?= MW3 Header Start =?=?=?=?=?=?=?=?=?=?=?=?=[MWTAG1]
' Script Type: MacroWorks 3 Device Script
' Device Name: X-keys Desktop
' Device Description: 20 Button HID Controller
' Script Name:
' Script Description: Macros for X-keys Desktop
' PID: 641
' Firmware: SE
' MW3 Version: 15
' Script Language: Visual Basic
' Script Template: Beta 1.0 
' Format: Unicode 8
' P.I. Engineering, Inc. 
' "The No Slogan Company"
' Williamston, Michigan, USA
' www.xkeys.com
' Start Date:  12-15-09, 6:43: 34 AM
' Last Update: 12-15-09, 6:43: 34 AM
'=?=?=?= MW3 Header End    =?=?=?=?=?=?=?=?=?=?=?=?=[/MWTAG1]

'=?=?=?= Notes Start =?=?=?=?=?=?=?=?=?=?=?=?=?=?=?=[MWTAG2]
'  User comment notes can go here. 
'=?=?=?= Notes End   =?=?=?=?=?=?=?=?=?=?=?=?=?=?=?=[MWTAG2]

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic

Public Class Script 
Implements Interfaces.IScript '[MWTAG12]
	
'=?=?=?= Initialize Variables Start =?=?=?=?=?=?=?=?=[MWTAG3]
	Dim MW3 As Interfaces.MW3
	Dim MyDevice As Integer() = {641, -1, 1} 'Device Descriptor [MWTAG8]
	Dim AppName As String = "" 'Active application name
	Dim AppTitle As String = "" 'Active application title
	Dim Layer_Red As Integer = 0 'Red,3
'=?=?=?= Initialize Varibles End  =?=?=?=?=?=?=?=?=?=[/MWTAG3]

	Public Sub Initialize(MW3 As Interfaces.MW3) Implements Interfaces.IScript.Initialize
		Me.MW3 = MW3
	End Sub
	
	Public Sub ScriptLoad() Implements Interfaces.IScript.ScriptLoad
		LEDset()	
	End Sub
	
	Public Function ScriptUnload() As Boolean Implements Interfaces.IScript.ScriptUnload
	End Function
	
	Public Sub SysPowerChange(PowerState As Byte) Implements Interfaces.IScript.SysPowerChange
	End Sub

	Public Sub ActiveAppChange(ActiveAppTitle As String, ActiveAppName As String) Implements Interfaces.IScript.ActiveAppChange
		AppName= ActiveAppName
		AppTitle= ActiveAppTitle
	End Sub
	
	Public Sub DeviceChange(DevInfo As Integer(), plugged As Boolean) Implements Interfaces.IScript.DeviceChange
		
	End Sub

'=?=?=?= Digital State Change Event Start =?=?=?=?=?=?=?=[MWTAG4]
	Public Sub XKEvent(CID As Integer, State As Boolean, Repeat As Integer, TimeStamp as Long, MessageData As Integer) Implements Interfaces.IScript.XKEvent
		Select Case CID 'Button Check Start [MWTAG9]
		Case 1001 'Button 001
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1002 'Button 002
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1003 'Button 003
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1004 'Button 004
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1005 'Button 005
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1006 'Button 006
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1007 'Button 007
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1008 'Button 008
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1009 'Button 009
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1010 'Button 010
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1011 'Button 011
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1012 'Button 012
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1013 'Button 013
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1014 'Button 014
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1015 'Button 015
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1016 'Button 016
			If State 'Pressed          [MWTAG10]
			Else 'Released             [MWTAG11]
			End If 'Press-Release      [/MWTAG10/MWTAG11]
		Case 1017 'Button 017
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1018 'Button 018
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1019 'Button 019
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1020 'Button 020
			If State 'Pressed [MWTAG10]
			Else 'Released [MWTAG11]
			End If 'Press-Release [/MWTAG10/MWTAG11]
		Case 1021 'ProgSwitch  -restricted-
			If State 'Pressed [MWTAG10]
				'<Open GUI>
				MW3.SetGUI(MyDevice,0,true)
				'</Open GUI>
			Else 'Released [MWTAG11]
				'<Close GUI>
				MW3.SetGUI(MyDevice,0,false)
				'</Close GUI>
			End If 'Press-Release [/MWTAG10/MWTAG11]
		End Select 'Button Check End [/MWTAG9]

		If Repeat = 0 
			LEDset() ' Set the Indicator LEDs
		End If
	End Sub	
'=?=?=?= Digital State Change Event End ?=?=?=?=?=?=?=?=?=[/MWTAG4]

'=?=?=?=Indicator LEDs Start =?=?=?=?=?=?=?=?=?=?=?=?=?=?=[MWTAG5]
	Public Sub LEDset() 
		If Layer_Red = 1
			MW3.SetLED(MyDevice,3001,0)
			MW3.SetLED(MyDevice,3002,1) 'Turn on the Red Indicator LED
		Else
			MW3.SetLED(MyDevice,3002,0)'Turn off the Red Indicator LED
			MW3.SetLED(MyDevice,3001,1)
		End if
	End Sub 
'=?=?=?= Indicator LEDs End ?=?=?=?=?=?=?=?=?=?=?=?=?=?=?=[/MWTAG5]
	
'=?=?=?=String Data Received Event Start =?=?=?=?=?=?=?=?=[MWTAG6]
	Public Sub XKStringEvent(CID As Integer, StringData As String, Repeat As Integer, TimeStamp as Long, MessageData As Integer) Implements Interfaces.IScript.XKStringEvent
		'String data is sent to this routine, XK-24 does not send string data but this is required for MW3 compatibility. 
	End Sub
'=?=?=?= String Data Received Event End ?=?=?=?=?=?=?=?=?=[/MWTAG6]

'=?=?=?= Analog Data Received Event Start =?=?=?=?=?=?=?=?[MWTAG7]
	Public Sub XKAnalogEvent(CID As Integer, AnalogValue As Integer(), Repeat As Integer, TimeStamp as Long, MessageData As Integer) Implements Interfaces.IScript.XKAnalogEvent
		'Analog data is sent to this routine, XK-24 does not send analog data but this is required for MW3 compatibility. 
	End Sub
'=?=?=?= Analog Data Received Event End ?=?=?=?=?=?=?=?=?=[/MWTAG7]

End Class '[/MWTAG12]

Open in new window

x-keys.jpg
Avatar of aikimark
aikimark
Flag of United States of America image

@Hank

This keyboard interface seems to respond to keydown/keyup events.  The way I would approach your stated result is that I would add two variables at the module level to track the last key up number and the time of that last key up.  Add code that will compare the prior key up number to the current key up number, if it is the same number, then subtract the prior timestamp value from the current timestamp.  You will need to set a time threshhold,  below which a double-tap of a key will result in some different action, rather than two of those digits.

In the special case (double-click), you will need to cancel the second character from getting to the program.  When I've done something like this for VB textbox controls, I set the Keycode=0.
Avatar of hank2011
hank2011

ASKER

Aikimark,

can you show me example of this.
>>can you show me example of this

Not with your special keyboard interface code.

What experience do you have with VB programming?
I know a little in vb like how to do calulations event handles stuff like that. I program more in c#.
do you understand how to define variables?
do you know where general declarations is located?
do you know how to assign values to variables?
do you know how to compare variable values?
yes i do understand all you wrote i just was needed sometype of example on the code to change so i can get this to work right thats all
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial