473,498 Members | 37 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to register multiple global hot-keys in C#?

scriptick
15 New Member
Hi everyone,
I want to register multiple global hotkeys. CTRL+A , SHIFT+B etc etc etc.
I want to more clear :
If i pressed : CTRL+A then a message will show (MessageBox.Show("Pavel,Tangal")
If i pressed SHIFT+B then minimize application.
If i pressed SHIFT+C maximize application.

I found a solution on internet related to it but i can not add here modifiers keys like : CTRL or SHIFT or ALT etc.

It is like : A,B,C,D

Sorry for my English.

Pls see my project sample and pls help me. (on attach)
Thanks
Attached Files
File Type: zip HookLibrary.zip (13.8 KB, 226 views)
Apr 14 '13 #1
7 4857
vijay6
158 New Member
Hey scriptick, you can use 'KeyDown' event for your form like as follows,

Expand|Select|Wrap|Line Numbers
  1. void Form1_KeyDown(object sender, KeyEventArgs e)
  2. {
  3.     if (e.Control & e.KeyCode == Keys.A)
  4.     {
  5.         MessageBox.Show("Pavel,Tangal");
  6.     }
  7.     else if (e.Shift & e.KeyCode == Keys.B)
  8.     {
  9.         this.WindowState = FormWindowState.Minimized;
  10.     }
  11.     else if(e.Shift & e.KeyCode == Keys.C)
  12.     {
  13.         this.WindowState = FormWindowState.Maximized;
  14.     }
  15. }

Note: This code ll work only if 'Form1' had focus.
Apr 15 '13 #2
scriptick
15 New Member
@vijay6
thank you very much for your nice repl.
but I want to do it from anywhere. if my app is minimize then is it work? I want something like ctrl + a in window is select all. something like that.

anyway sorry for eng.


thanks again
Apr 15 '13 #3
vijay6
158 New Member
Hey scriptick, I already told you "This code ll work only if 'Form1' had focus." Are you trying to create any malicious software?
Apr 15 '13 #4
scriptick
15 New Member
Hello vijay6, Thank you a lot for your again reply. Many many thanks.

Anyway I am not creating malicious software. I want to made game trainer with it. I already made some game trainer with this methood.
On GTA Vice City :
If Press CTRL+ALT+1 = SendKeys.Send("LeaveMeAlone");

Before i do it in LUA.But now i want to do it on C#.NET.

Nothing Else.

Thank you !!!
Apr 16 '13 #5
vijay6
158 New Member
I want to made game trainer with it.

Hey scriptick, Well! this is interesting!!! You can use the code which is in the below link for your trainer. All you have to do is replace the 'gHook_KeyDown' event by the below code.

Global KeyBoard Hook C#

Expand|Select|Wrap|Line Numbers
  1. public void gHook_KeyDown(object sender, KeyEventArgs e)
  2. {
  3.     if ((lastKey == 162 || lastKey == 163) && e.KeyValue == 65)
  4.     {
  5.         MessageBox.Show("Pavel,Tangal");
  6.     }
  7.  
  8.     else if ((lastKey == 160 || lastKey == 161) && e.KeyValue == 66)
  9.     {
  10.         this.WindowState = FormWindowState.Minimized;
  11.     }
  12.  
  13.     else if ((lastKey == 160 || lastKey == 161) && e.KeyValue == 67)
  14.     {
  15.         this.WindowState = FormWindowState.Maximized;
  16.     }
  17.  
  18.     lastKey = e.KeyValue;
  19. }

Note:

lastKey - Integer type class variable.

65 refers to A.
66 refers to B.
67 refers to C.
160 refers to Left Shift.
161 refers to Right Shift.
162 refers to Left Ctrl.
163 refers to Right Ctrl.

Before i do it in LUA.

Can you share your 'GTA Vice City' trainer with others (me)?


Hey, don't forgot to share your trainer!!!
Apr 17 '13 #6
scriptick
15 New Member
Hello vijay6 thank you verrrrrrrreey much bro for your help !!!! I am very happy to you. off course I am going to send you that when I sit on pc.

anyway thanks a lot again.
if you need me anytime pls PM me. I am ready to help you anyway.

thank you very much!!!
Apr 17 '13 #7
zmbd
5,501 Recognized Expert Moderator Expert
@OP
THe fact that you want this to happen outside of your program's focus/ownership makes this is potentially dangerous code and follows inline with a more recent thread of yours...

Asking for help to write potentially malicious code is against site policy and may result in the suspension of your account.

I respectfully ask that you clearly state the intent of this project.

-ZMBD
Nov 24 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2221
by: FaYYaZ | last post by:
Hi All I have one application folder containing all ASP code files. I want host multiple sites pointing to same code. Can I do this ? If YES then how I can assign diffrent global.asa to each...
2
2285
by: Matt Kruse | last post by:
Let's say I want to create two (or more) global functions from within a closure, so they can both share some "private" variables and methods. What is the recommended way to do this? (function(){...
0
2176
by: GizMo | last post by:
Hi, I'm trying to make ( using Remoting services ), a proxy ( which acts as a client and a server ). My problem is how can I register a channel on a particular port for the server part and at...
0
1248
by: kalva1kk | last post by:
Hi Every body, I created a schema with multiple root elements. I have an xml file which i want to validate against one of the root element in schema file. Is there any way we can specify in...
10
3475
by: subramanian100in | last post by:
Suppose I declare a global variable int g; in two different files say a.c which has main() and b.c When I compile them to build an executable under gcc in Redhat Linux with the command ...
13
2860
blyxx86
by: blyxx86 | last post by:
Hello everyone, I am interested in creating an access MDE for a front-end.. In attempting to create reports and generalized forms, I've run into a problem. There are certain fields/values that I...
0
875
by: robertFatima | last post by:
I have an HTTPHandler (C#) that I want to register to handle all requests of a given type for the whole server. I don't want to register it for each virtual directory. Additionally, I would like to...
0
1415
by: jayquest | last post by:
Any ideas? I want to create a global windows hotkey that performs an action on the selected text in any windows program (that is not read only of coarse). For example: Remove all spaces from this...
1
2746
by: Marisa | last post by:
Hi. I am new to C#, and I am having trouble getting the multiple selection of listbox to work. I have an asp.net web form, and I need two listboxes which are filled with an access table. I have...
4
2156
by: Constantine AI | last post by:
I set a global variable to equal a new password which was the wrong way of doing things, now i have tried many things to get rid of the global variable. All the text evidence has been deleted but it...
0
7124
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,...
0
6998
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...
0
7200
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...
1
6884
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...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
287
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...

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.