473,565 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insert key state

Me

Trying to get the current status of the insert key. Found
my.computer.key board.capslock, but no such item for insert key. Anyone
have some code to help. Can't figure out getkeystate. compiler chokes on
rslt = getkeystate(key s.insert)


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sep 21 '06 #1
3 5825
Me,

There are more ways in this which leads to Rome, and even an easier one than
I tell you.

But just using the keyup event gives you the possibility to set the keyboard
statuses in your program.

Cor

"Me" <ge******@lisco .comschreef in bericht
news:11******** *****@sp6iad.su perfeed.net...
>
Trying to get the current status of the insert key. Found
my.computer.key board.capslock, but no such item for insert key. Anyone
have some code to help. Can't figure out getkeystate. compiler chokes
on
rslt = getkeystate(key s.insert)


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----

Sep 22 '06 #2
Try cutting and pasting the following class:

Public Class Keyboard
Private Declare Function GetKeyboardStat e Lib "user32" (ByRef pbKeyState As
Byte) As Integer
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal
bScan As Byte, ByVal dwflags As Integer, ByVal dwExtraInfo As Integer)

Private Declare Function SendInput Lib "user32.dll " (ByVal nInputs As
Integer, ByRef pInputs As GENERALINPUT, ByVal cbSize As Integer) As Integer
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMem ory" (ByRef
pDst As Byte, ByRef pSrc As KEYBDINPUT, ByVal ByteLen As Integer)
<StructLayout(L ayoutKind.Seque ntial)Friend Structure KEYBDINPUT
Dim wVK As Short
Dim wScan As Short
Dim dwFlags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure
<StructLayout(L ayoutKind.Seque ntial)Friend Structure GENERALINPUT
Dim dwType As Integer
Dim wVK As Short
Dim wScan As Short
Dim dwFlags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
'Dim xi() As Byte 'dim 0 to 23
End Structure
' Constant declarations:
Const VK_NUMLOCK As Byte = &H90, vk_Scroll As Byte = &H91, vk_Capital As
Byte = &H14, vk_Ins As Byte = &H2D, vk_Shift As Byte = &H10
Const KEYEVENTF_EXTEN DEDKEY As Byte = &H1, KEYEVENTF_KEYUP As Byte = &H2,
INPUT_KEYBOARD As Byte = 1
Private Shared keys(255) As Byte

Public Shared Property CapsLockOn() As Boolean
Get
Return GetKeyState(vk_ Capital)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Capital, Value)
End Set
End Property
Public Shared Property NumLockOn() As Boolean
Get
Return GetKeyState(VK_ NUMLOCK)
End Get
Set(ByVal Value As Boolean)
SetKeyState(VK_ NUMLOCK, Value)
End Set
End Property
Public Shared Property ScrollLockOn() As Boolean
Get
Return GetKeyState(vk_ Scroll)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Scroll, Value)
End Set
End Property
Public Shared Property InsertModeOn() As Boolean
Get
Return GetKeyState(vk_ Ins)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Ins, Value)
End Set
End Property

Private Shared Function GetKeyState(ByV al keycode As Short) As Boolean
GetKeyboardStat e(keys(0))
Return (keys(keycode) And 1) 0
End Function
Private Shared Sub SetKeyState(ByV al Keycode As Byte, ByVal Value As Boolean)
GetKeyboardStat e(keys(0))
If Value <((keys(Keycode ) And 1) 0) Then
'Key Press
keybd_event(Key code, &H45, KEYEVENTF_EXTEN DEDKEY Or 0, 0)
'Key Release
keybd_event(Key code, &H45, KEYEVENTF_EXTEN DEDKEY Or KEYEVENTF_KEYUP , 0)
End If
End Sub
End Class
--
Dennis in Houston
"Me" wrote:
>
Trying to get the current status of the insert key. Found
my.computer.key board.capslock, but no such item for insert key. Anyone
have some code to help. Can't figure out getkeystate. compiler chokes on
rslt = getkeystate(key s.insert)


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sep 22 '06 #3
Me
Thanks Dennis. Appreciate the good help. Kinda answered some other
questions such as howto also.
thanks again...Smitty
"Dennis" <De****@discuss ions.microsoft. comwrote in message
news:86******** *************** ***********@mic rosoft.com...
Try cutting and pasting the following class:

Public Class Keyboard
Private Declare Function GetKeyboardStat e Lib "user32" (ByRef pbKeyState
As
Byte) As Integer
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal
bScan As Byte, ByVal dwflags As Integer, ByVal dwExtraInfo As Integer)

Private Declare Function SendInput Lib "user32.dll " (ByVal nInputs As
Integer, ByRef pInputs As GENERALINPUT, ByVal cbSize As Integer) As
Integer
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMem ory" (ByRef
pDst As Byte, ByRef pSrc As KEYBDINPUT, ByVal ByteLen As Integer)
<StructLayout(L ayoutKind.Seque ntial)Friend Structure KEYBDINPUT
Dim wVK As Short
Dim wScan As Short
Dim dwFlags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
End Structure
<StructLayout(L ayoutKind.Seque ntial)Friend Structure GENERALINPUT
Dim dwType As Integer
Dim wVK As Short
Dim wScan As Short
Dim dwFlags As Integer
Dim time As Integer
Dim dwExtraInfo As Integer
'Dim xi() As Byte 'dim 0 to 23
End Structure
' Constant declarations:
Const VK_NUMLOCK As Byte = &H90, vk_Scroll As Byte = &H91, vk_Capital As
Byte = &H14, vk_Ins As Byte = &H2D, vk_Shift As Byte = &H10
Const KEYEVENTF_EXTEN DEDKEY As Byte = &H1, KEYEVENTF_KEYUP As Byte = &H2,
INPUT_KEYBOARD As Byte = 1
Private Shared keys(255) As Byte

Public Shared Property CapsLockOn() As Boolean
Get
Return GetKeyState(vk_ Capital)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Capital, Value)
End Set
End Property
Public Shared Property NumLockOn() As Boolean
Get
Return GetKeyState(VK_ NUMLOCK)
End Get
Set(ByVal Value As Boolean)
SetKeyState(VK_ NUMLOCK, Value)
End Set
End Property
Public Shared Property ScrollLockOn() As Boolean
Get
Return GetKeyState(vk_ Scroll)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Scroll, Value)
End Set
End Property
Public Shared Property InsertModeOn() As Boolean
Get
Return GetKeyState(vk_ Ins)
End Get
Set(ByVal Value As Boolean)
SetKeyState(vk_ Ins, Value)
End Set
End Property

Private Shared Function GetKeyState(ByV al keycode As Short) As Boolean
GetKeyboardStat e(keys(0))
Return (keys(keycode) And 1) 0
End Function
Private Shared Sub SetKeyState(ByV al Keycode As Byte, ByVal Value As
Boolean)
GetKeyboardStat e(keys(0))
If Value <((keys(Keycode ) And 1) 0) Then
'Key Press
keybd_event(Key code, &H45, KEYEVENTF_EXTEN DEDKEY Or 0, 0)
'Key Release
keybd_event(Key code, &H45, KEYEVENTF_EXTEN DEDKEY Or KEYEVENTF_KEYUP , 0)
End If
End Sub
End Class
--
Dennis in Houston
"Me" wrote:
>>
Trying to get the current status of the insert key. Found
my.computer.ke yboard.capslock , but no such item for insert key. Anyone
have some code to help. Can't figure out getkeystate. compiler chokes
on
rslt = getkeystate(key s.insert)


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sep 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2479
by: Rajesh Kapur | last post by:
I have a master slave configuration on linux machines running MySQL 4.0.21. Once every hour, a process deletes about 9000 rows and re-inserts fresh data on the master. The master process completes processing under a minute. The updates arrive on the slave within seconds. However, the slave takes about 15-20 minutes to post the same updates....
1
2915
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
1
5393
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. And the line it shows in red is cmd.ExecuteNonQuery()
2
3179
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request : INSERT INTO temp_tab VALUES (1,2,3)
9
4034
by: cavassinif | last post by:
I need to dynamic select a column in which insert a vale based on a parameter value, I have this code, but it throws an incorrect syntax error. How do I dinamically select a column to insert based on a parameter? Create PROCEDURE dbo.UpdateDetalleOT ( @eotId int, )
11
28308
by: Ted | last post by:
OK, I tried this: USE Alert_db; BULK INSERT funds FROM 'C:\\data\\myData.dat' WITH (FIELDTERMINATOR='\t', KEEPNULLS, ROWTERMINATOR='\r\n');
3
5148
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using sqldatasource control, there is no need of opening and closing a connection. Also there is no need to write connection string. When i am selecting...
6
3445
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns,...
4
3117
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I can speed up the processing substantially? as it currently takes about 10 minutes and thats just way too long because there is many of these imports...
0
2276
by: magnolia | last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time which means i hav 2 record for every insert operation. any help appreciated. thank u herez teh code i tried. ALTER TRIGGER...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.