Page 1 of 1

'Windows' key

Posted: Thu Feb 28, 2008 8:22 am
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

Re: 'Windows' key

Posted: Thu Feb 28, 2008 9:01 am
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

Posted: Thu Feb 28, 2008 9:58 am
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

Posted: Thu Feb 28, 2008 11:27 am
by Enrico Maria Giordano
Sorry, no. :-(

EMG

Posted: Thu Feb 28, 2008 12:40 pm
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

Posted: Thu Feb 28, 2008 12:50 pm
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

Posted: Thu Feb 28, 2008 3:23 pm
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

Posted: Thu Feb 28, 2008 4:11 pm
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

Posted: Thu Feb 28, 2008 5:47 pm
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

Posted: Thu Feb 28, 2008 8:52 pm
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

Posted: Thu Feb 28, 2008 9:25 pm
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