Page 1 of 1

KeyState

PostPosted: Tue Feb 20, 2007 4:33 pm
by Gilbert
Hi,

Is there a way to test the state of ALT Key just like CONTROL and SHIFT key.

In VKEY.CH I can find VK_CONTROL, VK_SHIFT but not VK_ALT

Regards

Re: KeyState

PostPosted: Tue Feb 20, 2007 5:29 pm
by wmormar
Gilbert wrote:Hi,

Is there a way to test the state of ALT Key just like CONTROL and SHIFT key.

In VKEY.CH I can find VK_CONTROL, VK_SHIFT but not VK_ALT

Regards


is: VK_MENU

regards

PostPosted: Tue Feb 20, 2007 5:31 pm
by James Bott
Glibert,

Try VK_MENU

James

PostPosted: Tue Feb 20, 2007 5:54 pm
by Gilbert
Hi,

Thanks for the hint it partly solved my problem.

But there`s something that I don`t understand.

If VK_MENU test the ALT key, Why VK_CONTROL test the CTRL and ALT keys.

I wrote this small piece of code for testing:

if GetKeyState(VK_MENU)
MsgInfo(`ALT key has been pressed`)
endif

if GetKeyState(VK_CONTROL)
MsgInfo(`CTRL key has been pressed`)
endif

If I press CTRL + 2 Message displayed is `CTRL key has been pressed`
If I press ALT + 2 Message displayed is `ALT key has been pressed` followed by `CTRL key has been pressed`

Why is VK_CONTROL also test the ALT key ?
Sould`nt it be testing the CTRL key only ?

Regards

Gilbert

PostPosted: Tue Feb 20, 2007 6:05 pm
by James Bott
Gilbert,

As I remember there are some strange things going on with the Alt key, probably since it is a Windows reserved key to trigger hotkeys.

Perhaps if you tell us exactly what you are trying to accomplish someone can come up with a solution.

James

PostPosted: Tue Feb 20, 2007 7:01 pm
by Gilbert
Hi James,

I`m implementing new picture clause in the TGet. So far it works ok exept for one situation.

One picture clause I create allows the user to use FastLogin by using CTLR-G or whatever. (All 26 alpha key are available). Of course this FastLogin key has been configured in a User managament module where the user can create new users and define a FastLogin key.

So far, so good it works nicely. The only problem that this is causing me is whenever I have to capture an E-Mail address in a get field I cannot capture the @. TGet crashes. I figured out that it was because whenever the ALT Key is used it goes through the same routine that I added to the TGET that captures the FastLogin.

The strange thing about this is that the FastLogin should only work with CTRL Key. But I found out that using GetKeyState(VK_CONTROL) wich test the CTRL key also test the ALT Key. Because of this TGet crashes.

Finaly, I was able to work around the problem by doing the following:

do case
case GetKeyState(VK_MENU)
// Do Nothing
case GetKeyState(VK_CONTROL)
...
...
...
endcase

By testing VK_MENU (ALT key) first I eliminate the fact that using the ALT key GetKeyState(VK_CONTROL) processes the ALT + whaterver key may be used. This work around is quite weird but it works.

Regard,

Gilbert

PostPosted: Tue Feb 20, 2007 8:16 pm
by James Bott
Gilbert,

>This work around is quite weird but it works.

Glad to hear you got it working. As I mentioned the Alt key is special. It probably doesn't get trapped because it has to be available to call up the menu or a hotkey at any time.

James