- Joined
- Mar 12, 2022
- Messages
- 1
- Reaction score
- 0
I am working on a project that includes changing certain keys on the keyboard.
It is supposed to have two different sets of keys within the same keyboard. By klicking a key combination (a Macro) the settings should change between these keyboards. So normally the key "A" gives an "A", but when the keyboard change is activated it is supposed to print for example a "B" when the "A" key is pressed. Let the use of such a problem be my thing...
So what i have sofar:
I create a variable like the following
If a certain macro is activated (key combination pressed) this boolean variable gets set to true, meaning that the alternative keyboard is not active
In the part on top you can see that I am struggeling to find a way to change the keys....
The probably most stupid idea was that i would create macros for each key that i want to change and dependent on whether blnA is true or false it would print the certain key.
However, that mean that i would have to hold down "Strg" as Word Macros only take key combinations instead of single keys.
And here comes the stupid part of that idea: So i would need to figure out a way, so that when the keyboard is changed a "Strg" is constantly pressed. (It would be fine, if i couldn't use any other key anymore)
But I didn't figure out how to hold a key pressed.
I tried to use Sendkeys like that:
But in that case Sendkeys isn't fast enough and it only reacts to some of my "A" presses, when they by coincidence get hit at the same time.
So does anyone have an idea how to do that, an idea how to activate macros by just one key like "A" or a way to rewrite what keys give out?
Thank you in advance!
Best,
Lion
It is supposed to have two different sets of keys within the same keyboard. By klicking a key combination (a Macro) the settings should change between these keyboards. So normally the key "A" gives an "A", but when the keyboard change is activated it is supposed to print for example a "B" when the "A" key is pressed. Let the use of such a problem be my thing...
So what i have sofar:
I create a variable like the following
Code:
Option Explicit
Dim blnA As Boolean
If a certain macro is activated (key combination pressed) this boolean variable gets set to true, meaning that the alternative keyboard is not active
Code:
Public Sub FormelOeffnen()
'
If blnA = True Then
blnA = False
Else
blnA = True
End If
End Sub
In the part on top you can see that I am struggeling to find a way to change the keys....
The probably most stupid idea was that i would create macros for each key that i want to change and dependent on whether blnA is true or false it would print the certain key.
However, that mean that i would have to hold down "Strg" as Word Macros only take key combinations instead of single keys.
And here comes the stupid part of that idea: So i would need to figure out a way, so that when the keyboard is changed a "Strg" is constantly pressed. (It would be fine, if i couldn't use any other key anymore)
But I didn't figure out how to hold a key pressed.
I tried to use Sendkeys like that:
Code:
Sub Makro2()
'
' Makro2 Makro
'
'
Do While blnA = True
SendKeys "M" + ??
DoEvents
Loop
End Sub
But in that case Sendkeys isn't fast enough and it only reacts to some of my "A" presses, when they by coincidence get hit at the same time.
So does anyone have an idea how to do that, an idea how to activate macros by just one key like "A" or a way to rewrite what keys give out?
Thank you in advance!
Best,
Lion