0

I'm trying to do a virtual click and in order to do that you need to give the keybd_event() a byte value in order to tell it what to do. So I have this function that takes in a passed string ( It's just a letter from A-Z ) and converts it to a byte. But when I run the program I get this error Conversion from type 'Byte()' to type 'Byte' is not valid

Here is the function:

Private Function getByteValue(ByVal letter As String)
    Dim byt = System.Text.Encoding.Unicode.GetBytes(letter)
    Return byt
End Function

I don't know why the error is occurring, and also I'm not sure its even returning a byte value, but rather how many bytes the letter converts to, and I need a byte bvk value?

4

2 回答 2

3

Encoding.GetBytes()返回一个字节数组,而不是单个字节。错误消息告诉您您正在尝试将字节数组转换为字节。

您将不得不遍历数组中的元素并通过keybd_event().

于 2013-07-25T14:47:12.190 回答
1

与您实施的类似的正确方法如下所示。

Private Function getByteValue(ByVal letter As String) As Byte()
    Dim byt As Byte() = {}
    byt = System.Text.Encoding.Unicode.GetBytes(letter)
    Return byt
End Function
于 2013-07-25T15:40:31.227 回答