List of Global Hotkey IDs?

  • Thread starter Thread starter kimiraikkonen
  • Start date Start date
K

kimiraikkonen

Hi,
Here is 2 questions:
1) I declared some global hotkeys located inside Windows API follows
as:

Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8

But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource includes
all.

How can i get all IDs?


2) RegisterGlobalHotkey function is needed to use for these keys and
as sampled here:
RegisterGlobalHotKey(Keys.F6, MOD_CONTROL Or MOD_SHIFT) for pressing
F6+SHIFT+CONTROL together. "MOD_CONTROL" and "MOD_SHIFT" are
modifiers.

How can i leave modifiers blank and use RegisterGlobalHotKey function
with only one key like "F6" alone without other key combinations?

Thanks.
 
kimiraikkonen said:
1) I declared some global hotkeys located inside Windows API follows
as:

Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8

But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource includes
all.

The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key constant. You
can find them here:

Virtual-Key Codes
2) RegisterGlobalHotkey function is needed to use for these keys and
as sampled here:
RegisterGlobalHotKey(Keys.F6, MOD_CONTROL Or MOD_SHIFT) for pressing
F6+SHIFT+CONTROL together. "MOD_CONTROL" and "MOD_SHIFT" are
modifiers.

How can i leave modifiers blank and use RegisterGlobalHotKey function
with only one key like "F6" alone without other key combinations?

Simply use 0 as the parameter value.
 
The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key constant. You
can find them here:

Virtual-Key Codes



Simply use 0 as the parameter value.

Thanks for second question, but sorry for first. I tried but couldn't
get work.

How will i simulate as the same with the constants i stated in first
post?
(declaration, hexadecimal?)

eg:

Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8

Those are working, but i want to add outside them more like... TAB,
Escape, F9 etc.

How?

Thanks.
 
kimiraikkonen said:
1) I declared some global hotkeys located inside Windows API follows
as:
Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8
But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource includes
all.

The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key constant.
You
can find them here:

Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
[...]
How will i simulate as the same with the constants i stated in first
post?
(declaration, hexadecimal?)

Simply take the constant name from the following article:

Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>

Then take the value of the according row in the 'Hexadecimal value" column
and compose a constand definition:

'Private Const <Value of symbolic constant column> As Integer = &H<Value of
Hexadecimal value column>'.

Then you can pass the constant to the 'RegisterHotkey' function's 'vk'
parameter.

The function declaration should look like that:

\\\
Private Declare Function RegisterHotKey Lib "User32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal id As Int32, _
ByVal fsModifiers As Int32, _
ByVal vk As Int32 _
) As Boolean
///
Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8

Those are only the modifiers which can be passed to the 'fsModifiers'
parameter.
Those are working, but i want to add outside them more like... TAB,
Escape, F9 etc.

How?

I am not sure which keys can be specified in the 'vk' parameter, but I
suggest to try it with the keys you want to use.
 
1) I declared some global hotkeys located inside Windows API follows
as:
Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8
But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource includes
all.
The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key constant.
You
can find them here:
Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
[...]
How will i simulate as the same with the constants i stated in first
post?
(declaration, hexadecimal?)

Simply take the constant name from the following article:

Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>

Then take the value of the according row in the 'Hexadecimal value" column
and compose a constand definition:

'Private Const <Value of symbolic constant column> As Integer = &H<Value of
Hexadecimal value column>'.

Then you can pass the constant to the 'RegisterHotkey' function's 'vk'
parameter.

The function declaration should look like that:

\\\
Private Declare Function RegisterHotKey Lib "User32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal id As Int32, _
ByVal fsModifiers As Int32, _
ByVal vk As Int32 _
) As Boolean
///

Hi,
Correct declaration must have been this:
'For registration
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As
IntPtr, ByVal id As Integer, _
ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer

'For unregistration
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As
IntPtr, ByVal id As Integer) _
As Integer

as stated in:
http://www.dotnet2themax.com/ShowContent.aspx?ID=103cca7a-0323-47eb-b210-c2bb7075ba78


However function declaration is not issue now,
for key combination, i tried declaring VK_SHIFT as follows:
Private Const VK_SHIFT As Integer = &H10

from the msdn link.

Then tried to register F6+SHIFT combination with putting:
RegisterGlobalHotKey(Keys.F6, VK_SHIFT)

but this didn't work.

Only works with modifiers given above or alone with modifier value
zero.
This works:
RegisterGlobalHotKey(Keys.F6, 0)

or this works:
RegisterGlobalHotKey(Keys.F6, MOD_ALT or MOD_CONTROL) with the
declarations given above also.


Thanks.
 
kimiraikkonen said:
1) I declared some global hotkeys located inside Windows API follows
as:
Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8
But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource
includes
all.
The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key
constant.
You
can find them here:
Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
[...]
How will i simulate as the same with the constants i stated in first
post?
(declaration, hexadecimal?)

Simply take the constant name from the following article:

Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>

Then take the value of the according row in the 'Hexadecimal value"
column
and compose a constand definition:

'Private Const <Value of symbolic constant column> As Integer = &H<Value
of
Hexadecimal value column>'.

Then you can pass the constant to the 'RegisterHotkey' function's 'vk'
parameter.

The function declaration should look like that:

\\\
Private Declare Function RegisterHotKey Lib "User32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal id As Int32, _
ByVal fsModifiers As Int32, _
ByVal vk As Int32 _
) As Boolean
///

Hi,
Correct declaration must have been this:
'For registration
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As
IntPtr, ByVal id As Integer, _
ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer

The return value is a 'Boolean', although 'Integer' will work too.
However function declaration is not issue now,
for key combination, i tried declaring VK_SHIFT as follows:
Private Const VK_SHIFT As Integer = &H10

You cannot use the 'VK_*' constants as modifiers. You can only use the
'MOD_*' constants or the value 0 as modifiers.
 
1) I declared some global hotkeys located inside Windows API follows
as:
Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8
But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource
includes
all.
The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key
constant.
You
can find them here:
Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
[...]
How will i simulate as the same with the constants i stated in first
post?
(declaration, hexadecimal?)
Simply take the constant name from the following article:
Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
Then take the value of the according row in the 'Hexadecimal value"
column
and compose a constand definition:
'Private Const <Value of symbolic constant column> As Integer = &H<Value
of
Hexadecimal value column>'.
Then you can pass the constant to the 'RegisterHotkey' function's 'vk'
parameter.
The function declaration should look like that:
\\\
Private Declare Function RegisterHotKey Lib "User32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal id As Int32, _
ByVal fsModifiers As Int32, _
ByVal vk As Int32 _
) As Boolean
///
Hi,
Correct declaration must have been this:
'For registration
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As
IntPtr, ByVal id As Integer, _
ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer

The return value is a 'Boolean', although 'Integer' will work too.
However function declaration is not issue now,
for key combination, i tried declaring VK_SHIFT as follows:
Private Const VK_SHIFT As Integer = &H10

You cannot use the 'VK_*' constants as modifiers. You can only use the
'MOD_*' constants or the value 0 as modifiers.

I'm not meaning using modifiers as the aim of this topic. To clarify
better:

I want to use more keys with combinations with F6 such as F6 + TAB or
else which are not declared as modfiers, defined as hotkeys. However
we can sample with modifiers if they'll do the same job;

Also that doesn't work:
'Declaration part
Private Const MOD_TAB As Integer = &H9

'Register hotkey
RegisterGlobalHotKey(Keys.F6, MOD_TAB)

for F6+TAB combination

which doesn't work.

How to do this?

Thanks.
 
1) I declared some global hotkeys located inside Windows API follows
as:
Private Const MOD_ALT As Integer = 1
Private Const MOD_CONTROL As Integer = 2
Private Const MOD_SHIFT As Integer = 4
Private Const MOD_WIN As Integer = 8
But i need other key's IDs and declarations such as F5, F6 or
Backspace etc. but i couldn't find a all-in-one web resource
includes
all.
The 'vk' parameter of 'RegisterHotkey' accepts any 'VK_*' key
constant.
You
can find them here:
Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
[...]
How will i simulate as the same with the constants i stated in first
post?
(declaration, hexadecimal?)
Simply take the constant name from the following article:
Virtual-Key Codes
<URL:http://msdn2.microsoft.com/en-us/library/ms927178.aspx>
Then take the value of the according row in the 'Hexadecimal value"
column
and compose a constand definition:
'Private Const <Value of symbolic constant column> As Integer = &H<Value
of
Hexadecimal value column>'.
Then you can pass the constant to the 'RegisterHotkey' function's 'vk'
parameter.
The function declaration should look like that:
\\\
Private Declare Function RegisterHotKey Lib "User32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal id As Int32, _
ByVal fsModifiers As Int32, _
ByVal vk As Int32 _
) As Boolean
///
Hi,
Correct declaration must have been this:
'For registration
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As
IntPtr, ByVal id As Integer, _
ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer

The return value is a 'Boolean', although 'Integer' will work too.
However function declaration is not issue now,
for key combination, i tried declaring VK_SHIFT as follows:
Private Const VK_SHIFT As Integer = &H10

You cannot use the 'VK_*' constants as modifiers. You can only use the
'MOD_*' constants or the value 0 as modifiers.

Maybe the keys such as TAB or others except shift, ctrl, alt is not
available for some instances such as capturing screen or others? There
are some programs only uses shift, alt or ctrl + a "F" key or letter
key for combination.
 
kimiraikkonen said:
I'm not meaning using modifiers as the aim of this topic. To clarify
better:

I want to use more keys with combinations with F6 such as F6 + TAB
or else which are not declared as modfiers, defined as hotkeys.
However we can sample with modifiers if they'll do the same job;

Also that doesn't work:
'Declaration part
Private Const MOD_TAB As Integer = &H9

'Register hotkey
RegisterGlobalHotKey(Keys.F6, MOD_TAB)

for F6+TAB combination

which doesn't work.

How to do this?


You can not do this. You can specify exactly /one/ virtual key (Tab, F6,
....) AND optionally modifiers like Shift or Control. Pressing F6+Tab is
not supported, only Shift+Tab, Shift+F6, Ctrl+Tab, Ctrl+F6, and so on.


Armin
 
Back
Top