Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retain default behaviour of win-key while using wait for.
#1
As soon as I press the Win-key it should display briefly a sequence of numbers (1, 2, 3, .., 0) above the first 10 icons on the task bar.
I cannot get this seemingly easy job to work. Please check the following code (I know it doesn't use an intelligent positioning algorithm yet):

Macro Macro2
Code:
Copy      Help
rep
,wait 0 K W
,OnScreenDisplay "1     2     3     4     5     6     7     8     9     0" 2 80 1080 "Arial" 24 0xff00 16
When I use wait for key down event the win-key is eaten as documented. So I cannot use Win+5 to start the 5th program on the task bar.
When I use wait for key up event then I also cannot use Win+5, because the win-key is carried out straight away.

Any idea how to solve this?

Thanks!
#2
Use a low-level keyboard hook. Some examples are in this forum.

I seems that there is no way to get taskbar button positions on Windows 7.
#3
LL keyboard hook is switched on. Should have mentioned that before. Anyway, writing my own LL hook is too complicated for me right now. I hardly understand the examples. But I tried the following and it seems to work:
Function Function2
Code:
Copy      Help
rep
,ifk (VK_LWIN)
,,OnScreenDisplay "1     2     3     4     5     6     7     8     9     0" 2 80 1080 "Arial" 24 0xff00 16
The only thing now is that this function creates a lot of threads (when I'm a bit slow on the Win-key). The infinitive loop is running real fast, I guess Smile . As soon as there are 200 threads QM issues a warning for each thread: "Warning: There are [n] threads. QM may fail to create more threads and stop working." n > 199
Btw, if I start writing a low level hook, you think I should take into account that the Win-key can be a modifier and a standalone hotkey (unlike e.g. SHIFT)?

As a side note: there is a VK_SHIFT, VK_LSHIFT and VK_RSHIFT, but for the Win-key I couldn't find a generic code like VK_WIN (only VK_LWIN and VK_RWIN).
#4
ifk ...
can be replaced to
if GetMod=8
It tests state of both win keys and also other modifier keys.

Show OSD only when win key state changes, not always when key pressed. Store previous state in a variable and compare. If it is difficult, just add osdid argument, any string.
And insert wait 0.01.


Forum Jump:


Users browsing this thread: 1 Guest(s)