LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect Modifier keypress

Hello,
 
I would like to detect if a modifier key (shift, ctrl) is pressed when I click on a control. Given that the EVENT_KEYPRESS is only fired when I press a normal key on the keyboard, how can I do it?
 
Thank you for you help
Bertrand
0 Kudos
Message 1 of 8
(4,326 Views)
Hello Bertrand.

Have a look at the GetGlobalMouseState() function (from the User Interface Library). Here is the prototype:

int GetGlobalMouseState (int *panelHandle, int *xCoordinate, int *yCoordinate, int *leftButtonDown, int *rightButtonDown, int *keyModifiers);

Within your control callback, examine the value of keyModifiers. From the control help in the function panel:
"State of the keyboard modifiers, in other words, the <Ctrl> and <Shift> keys.
If no keys are down, the value is 0. Otherwise, the value is the bitwise OR of the appropriate key masks: VAL_MENUKEY_MODIFIER and VAL_SHIFT_MODIFIER.
You can pass NULL."
Regards,
Colin.

Message 2 of 8
(4,321 Views)

Thank you. I would never have had the idea to look at the mouse state to get the modifier key.

 

Bertrand

0 Kudos
Message 3 of 8
(4,288 Views)

Please Help me out this.

in my application i did two button UP and DOWN.

if i press UP button my object will move up direction same if i press DOWN my object will move down.

here i want i will press continues UP button my object will move contuesly,i tired  alot is it possible in cvi 5.5.

0 Kudos
Message 4 of 8
(3,687 Views)

Hello,

 

Maybe something like that should work.

 

int CVICALLBACK ButtonUp (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{int LeftBtDown;
 
 switch (event)
     {
     case EVENT_LEFT_CLICK:
        LeftBtDown = 1;
        while (LeftBtDown==1)
            {
            /*==== Move Object ===*/
            // Code for moving object
            
            GetRelativeMouseState (panelHandle, 0, 0, 0, &LeftBtDown, NULL, NULL);
        
            
            }
        break;
    }
 return 0;
}

0 Kudos
Message 5 of 8
(3,680 Views)

okay thank you i will try this

0 Kudos
Message 6 of 8
(3,676 Views)

thak you sir its working

0 Kudos
Message 7 of 8
(3,655 Views)

Hello Sir,

 

this code working fine with my machine,now machine will go up down w.r.t my up/down key press, but my while loop causing prob if im using up or down button my othr funtion not updating,in my code  evry .001 sec my one function running....if im using up/down button my other function not executing parrally.....

how to solve this ...shall i use timer intsted of while?.

 

 

Thank you in Advance 

 

sudhir

0 Kudos
Message 8 of 8
(3,607 Views)