'Windows' key

Post Reply
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

'Windows' key

Post by Detlef Hoefner »

Hi all,

i must simulate a press of the new 'windows' keys which can be found on modern keyboards.
( An other app needs 'windows' + 'a' )

Unfortunatelly i can not find any value for them in inkey.ch nor vkey.ch.
I still use a vintage keyboard without such keys and can not experiment.
I already got the hint to use
VK_LWIN (0x5B) for Left Windows key (Microsoft Natural keyboard)
and
VK_RWIN (0x5C) for Right Windows key (Natural keyboard)
But if i send this via keyboard command i got the characters '[' and '\' which is the correct ascii value.

Is there way to simulate the windows key?

Any help will be welcome,
Detlef
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: 'Windows' key

Post by Enrico Maria Giordano »

This is a working sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    @ 1, 1 BUTTON "Test";
           ACTION __KEYBOARD( CHR( 0x5B ) )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Enrico,

many thanks for your help.
It's working fine.

I forgot to tell that those keys must be triggered from a xharbour console app. :oops:

And this doesn't work.
May be you have an other idea?

Thanks and regards,
Detlef
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Enrico,

i tried to be clever and write a Windows program which i can start from my console app.

Code: Select all

#include "FiveWin.ch" 

FUNCTION MAIN()
   __KEYBOARD( CHR( 0x5B ) + 'e' )
RETURN NIL
This should normally start the Windows Explorer.
But it doesn't.
It just opens the Start menu and selects the menu point with hotkey 'e' ( in German 'Einstellungen' what means Settings ).

Are you able to start the Windows explorer via __KEYBOARD() ?

Regards,
Detlef
User avatar
Maurilio Viana
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil
Contact:

Post by Maurilio Viana »

Detlef,

You can run Explorer from a DOS prompt calling for EXPLORER, maybe you can call it by RUN command...

Regards,
Maurilio
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Maurilio,

thanks for jumping in.
But my problem is not to call Windows explorer.
This was just a suggested test for EMG.

I must trigger the key combination 'windows' + 'a' for a call center software to dial customer numbers.
Unfortunatelly this seems to be impossible from a xHarbour console app.

Anyhow, thanks for your help.
Detlef
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Try this:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    @ 1, 1 BUTTON "Test";
           ACTION __KEYBOARD( CHR( 0x5B ) + "e" + CHR( VK_RETURN ) )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Enrico,
Try this...
__KEYBOARD( CHR( 0x5B ) + "e" + CHR( VK_RETURN ) )
starts the settings dialog of a German windows XP.

It's just like clicking the Startbutton of Windows and select 'Einstellungen ( Settings )' plus Enter.
But unfortunatelly it's not the equivalent to 'windows' + 'e'.

I'll going to loose my last hair :?
Regards,
Detlef
User avatar
Maurilio Viana
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil
Contact:

Post by Maurilio Viana »

Detlef,

Now I understand what you want :)
I never did it with FiveWin, but I have a program in Delphi where I execute a program and select a option from menu. In Delphi I do:

Code: Select all

(...)
Keybd_Event(VK_MENU, 0, 0, 0); // Press ALT key
Keybd_Event(86     , 0, 0, 0); // V  from &View menu option
Keybd_Event(87     , 0, 0, 0); // W from &Wide Band menu
keybd_event(VK_MENU, MapVirtualKey(VK_MENU,0), KEYEVENTF_KEYUP, 0); // release Alt key
Maybe you can search in Goggle for this API functions and constants to adapt it to FW...

Regards,
Maurilio
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Maurilio,

many thanks for your efforts.
I just finished myself googling this problem.

After reading docs and samples i finally got it.
Here the source. You can compile it with bcc32 and it will run fine.

Code: Select all

#include <windows.h>

void main() {

   keybd_event( VK_LWIN, 0, 0, 0 );  // press left 'windows' key
   keybd_event( VkKeyScan('E'), 0, 0, 0 ); // press 'E'
   keybd_event( VkKeyScan('E'), 0, KEYEVENTF_KEYUP, 0 ); // release 'E' key
   keybd_event( VK_LWIN, 0, KEYEVENTF_KEYUP, 0 ); // release the 'windows' key
}
I found out that the sequence of pressing and releasing the keys is important.

Many thanks for all assistance from this forum.
Detlef
Post Reply