'Windows' key

'Windows' key

Postby Detlef Hoefner » Thu Feb 28, 2008 8:22 am

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
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: 'Windows' key

Postby Enrico Maria Giordano » Thu Feb 28, 2008 9:01 am

This is a working sample:

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Detlef Hoefner » Thu Feb 28, 2008 9:58 am

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

Postby Enrico Maria Giordano » Thu Feb 28, 2008 11:27 am

Sorry, no. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Detlef Hoefner » Thu Feb 28, 2008 12:40 pm

Enrico,

i tried to be clever and write a Windows program which i can start from my console app.
Code: Select all  Expand view  RUN
#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
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Maurilio Viana » Thu Feb 28, 2008 12:50 pm

Detlef,

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

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

Postby Detlef Hoefner » Thu Feb 28, 2008 3:23 pm

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
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Enrico Maria Giordano » Thu Feb 28, 2008 4:11 pm

Try this:

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Detlef Hoefner » Thu Feb 28, 2008 5:47 pm

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
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Maurilio Viana » Thu Feb 28, 2008 8:52 pm

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  Expand view  RUN
(...)
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
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil

Postby Detlef Hoefner » Thu Feb 28, 2008 9:25 pm

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  Expand view  RUN
#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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Marc Venken and 34 guests

cron