Hi,
Is it possible to turn on\off the CAPS LOCK button using C# program? and if
so, how can i do that?
Thanks,
Gidi 4 21817
Hello Gidi,
Use
SendKeys.Send("{CAPSLOCK}");
or
PInvoke "SetKeyboardState"/"keybd_event"
[DllImport("user32.dll")]
static extern bool SetKeyboardState(byte [] lpKeyState);
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr
dwExtraInfo); http://msdn.microsoft.com/library/de...alKeyCodes.asp
G> Hi,
G>
G> Is it possible to turn on\off the CAPS LOCK button using C# program?
G> and if so, how can i do that?
G>
G> Thanks,
G> Gidi
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Thanks Michael ,
I tried the SendKeys option, and it works only while i'm debugging, but in
regular runtime it doesn't turn on\off the capslock key.
About the second option, i didn't really understand how should i use it, so
if u can, please explain or give example...
Thanks,
Gidi.
"Michael Nemtsev" wrote: Hello Gidi,
Use SendKeys.Send("{CAPSLOCK}");
or
PInvoke "SetKeyboardState"/"keybd_event"
[DllImport("user32.dll")] static extern bool SetKeyboardState(byte [] lpKeyState);
[DllImport("user32.dll")] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); http://msdn.microsoft.com/library/de...alKeyCodes.asp G> Hi, G> G> Is it possible to turn on\off the CAPS LOCK button using C# program? G> and if so, how can i do that? G> G> Thanks, G> Gidi --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche
Hello Gidi,
For second options
1) add using System.Runtime.InteropServices;
2) Put button on the form
3) add code below to the class declaraion where is button handler located
public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);
...
}
4) add code below to the button handler
private void button1_Click(object sender, EventArgs e)
{
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr) 0);
keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
(UIntPtr) 0);
}
This will turn on/off caps lock each time u press the button
0x14 is a Virtual-key code for capslock. List of codes are here http://msdn.microsoft.com/library/de...alKeyCodes.asp
G> Thanks Michael ,
G>
G> I tried the SendKeys option, and it works only while i'm debugging,
G> but in regular runtime it doesn't turn on\off the capslock key.
G>
G> About the second option, i didn't really understand how should i use
G> it, so if u can, please explain or give example...
G>
G> Thanks,
G> Gidi.
G> "Michael Nemtsev" wrote:
G> Hello Gidi,
Use SendKeys.Send("{CAPSLOCK}");
or
PInvoke "SetKeyboardState"/"keybd_event"
[DllImport("user32.dll")] static extern bool SetKeyboardState(byte [] lpKeyState); [DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr
dwExtraInfo);
http://msdn.microsoft.com/library/de...ary/en-us/winu i/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
G> Hi, G> G> Is it possible to turn on\off the CAPS LOCK button using C# program? G> and if so, how can i do that? G> G> Thanks, G> Gidi --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Thanks again Michael,
It works. I have one more question, if it's ok by you...
How can i check if the caps lock is on or off before i calling this event
handler?
Thanks,
Gidi.
"Michael Nemtsev" wrote: Hello Gidi,
For second options
1) add using System.Runtime.InteropServices; 2) Put button on the form 3) add code below to the class declaraion where is button handler located
public partial class Form1 : Form { [DllImport("user32.dll")] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); ... }
4) add code below to the button handler
private void button1_Click(object sender, EventArgs e) { const int KEYEVENTF_EXTENDEDKEY = 0x1; const int KEYEVENTF_KEYUP = 0x2; keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr) 0); keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr) 0); }
This will turn on/off caps lock each time u press the button
0x14 is a Virtual-key code for capslock. List of codes are here http://msdn.microsoft.com/library/de...alKeyCodes.asp
G> Thanks Michael , G> G> I tried the SendKeys option, and it works only while i'm debugging, G> but in regular runtime it doesn't turn on\off the capslock key. G> G> About the second option, i didn't really understand how should i use G> it, so if u can, please explain or give example... G> G> Thanks, G> Gidi. G> "Michael Nemtsev" wrote: G> Hello Gidi,
Use SendKeys.Send("{CAPSLOCK}");
or
PInvoke "SetKeyboardState"/"keybd_event"
[DllImport("user32.dll")] static extern bool SetKeyboardState(byte [] lpKeyState); [DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr
dwExtraInfo);
http://msdn.microsoft.com/library/de...ary/en-us/winu i/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
G> Hi, G> G> Is it possible to turn on\off the CAPS LOCK button using C# program? G> and if so, how can i do that? G> G> Thanks, G> Gidi --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche
--- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Johnson |
last post by:
It doesn't seem possible. But would the following also seem a
violation of the general notions behind css?
You have a DIV, say asociated with class, 'topdiv'.
Inside of that you have an anchor...
|
by: aka |
last post by:
Hi
I have a DB2 v8.1 on AIX and DB2 Connect EE on Solaris wich is connected to
OS/390 DB2 subsystems via APPC / SNA. I have cataloged the DB2 Connect
instance as tcpip node and then the Host DB...
|
by: murat oguzalp |
last post by:
i want to call base and this constructor at the same time. is is possible?
i mean:
B(int a, int b, int c):base(a):this(b)
{
// do something with c
}
at java i used to do that:
|
by: Steve Franks |
last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting
a value in the config.web file.
However, what if I wanted to determine at run time whether or not I wanted
to use...
|
by: Nick Gilbert |
last post by:
Hi
I have a number of pages where it is valid for the user to enter HTML.
On these pages, I have turned off RequestValidation ("ValidateRequest =
false" in the page directive) so that the...
|
by: Malkavian |
last post by:
hi. I have this in the header section of my web page.
<EMBED SRC="g7wap cq.mp3" WIDTH=0 HEIGHT=0 hidden="true" AUTOSTART=true
LOOP=TRUE ALIGN="CENTER" id="morsemp3" name="morsemp3"></EMBED>
...
|
by: AA Arens |
last post by:
I do have a database with customer info in it. To avoid it will be
taken out of our office, is it possible to make it not-readable after
a certain period?
then every let say seven days, I needs to...
|
by: Morgan Cheng |
last post by:
Days ago, I post a question on how to make SoapHttpClientProtocol
instance make new TCP connection for each web service request. Now, I
found how.
SoapHttpClientProtocol has a protected method...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |