Hello,
Can anyone help me out? I'd like to know how to control the keyboard LEDs from a PB program. I found some things on the Microsoft site about API functions that do this, but can't figure out how to use them.
Thanks!
Paul
Changing the keyboard indicator LEDs
don't know if this will help but take a look at this
http://www.powerbasic.com/support/forum ... 01365.html
would be cool if someone could translate it to PB
http://www.powerbasic.com/support/forum ... 01365.html
would be cool if someone could translate it to PB
Re: Changing the keyboard indicator LEDs
Hi Paul, you can allway try this.paulr wrote:Hello,
Can anyone help me out? I'd like to know how to control the keyboard LEDs from a PB program. I found some things on the Microsoft site about API functions that do this, but can't figure out how to use them.
Thanks!
Paul
Code: Select all
Procedure SetLEDKey(key$,newstate)
Select LCase(key$)
Case "c" : keycode=#VK_CAPITAL : oldstate=GetKeyState_(keycode)
Case "n" : keycode=#VK_NUMLOCK : oldstate=GetKeyState_(keycode)
Case "s" : keycode=#VK_SCROLL : oldstate=GetKeyState_(keycode)
EndSelect
If oldstate<>newstate
keybd_event_(keycode,1,0,0)
keybd_event_(keycode,1,#KEYEVENTF_KEYUP,0)
EndIf
EndProcedure
Procedure.l GetLEDKey(key$)
Protected oldstate
Select LCase(key$)
Case "c" : keycode=#VK_CAPITAL : oldstate=GetKeyState_(keycode)
Case "n" : keycode=#VK_NUMLOCK : oldstate=GetKeyState_(keycode)
Case "s" : keycode=#VK_SCROLL : oldstate=GetKeyState_(keycode)
EndSelect
ProcedureReturn oldstate
EndProcedure
Re: Changing the keyboard indicator LEDs
I get this when try to compile your code:
keybd_event_( is not a function, etc, etc
keybd_event_( is not a function, etc, etc
ARGENTINA WORLD CHAMPION
Simple answer:
Look in the Platfrom SDK:
edit
GPI
Look in the Platfrom SDK:
Code: Select all
Windows NT/2000/XP:This function has been superseded. Use SendInput insteadCode: Select all
The SendInput function synthesizes keystrokes, mouse motions, and button clicks.
Syntax
UINT SendInput( UINT nInputs,
LPINPUT pInputs,
int cbSize
);
Parameters
nInputs
[in] Specifies the number of structures in the pInputs array.
pInputs
[in] Pointer to an array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.
cbSize
[in] Specifies the size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function will fail.
Return Value
The function returns the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread.
To get extended error information, call GetLastError.
Remarks
The SendInput function inserts the events in the INPUT structures serially into the keyboard or mouse input stream. These events aren't interspersed with other keyboard or mouse input events inserted either by the user (with the keyboard or mouse) or by calls to keybd_event, mouse_event, or other calls to SendInput.
This function does not reset the keyboard's current state. Any keys that are already pressed when the function is called might interfere with the events that this function generates. To avoid this problem, check the keyboard's state with the GetAsyncKeyState function and correct as necessary.
Function Information
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 98, Windows NT 4.0 Service Pack 3 Code: Select all
The INPUT structure is used by SendInput to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks.
Syntax
typedef struct tagINPUT {
DWORD type;
union {MOUSEINPUT mi;
KEYBOARDINPUT ki;
HARDWAREINPUT hi;
};
}INPUT, *PINPUT;
Members
type
Specifies the type of the input event. This member can be one of the following values.
INPUT_MOUSE
The event is a mouse event. Use the mi structure of the union.
INPUT_KEYBOARD
The event is a keyboard event. Use the ki structure of the union.
INPUT_HARDWARE
Windows 95/98/Me: The event is from input hardware other than a keyboard or mouse. Use the hi structure of the union.
mi
A MOUSEINPUT structure that contains information about a simulated mouse event.
ki
A KEYBDINPUT structure that contains information about a simulated keyboard event.
hi
Windows 95/98/Me: A HARDWAREINPUT structure that contains information about a simulated event from input hardware other than a keyboard or mouse.
Remarks
This structure contains information identical to that used in the parameter list of the keybd_event or mouse_event function.
Windows 2000/XP: INPUT_KEYBOARD supports nonkeyboard input methods, such as handwriting recognition or voice recognition, as if it were text input by using the KEYEVENTF_UNICODE flag. For more information, see the remarks section of KEYBDINPUT.
Structure Information
Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows 98, Windows NT 4.0 Service Pack 3
See Also
Keyboard Input, GetMessageExtraInfo, SendInput, keybd_event, mouse_event, HARDWAREINPUT, KEYBDINPUT, MOUSEINPUTCode: Select all
The KEYBDINPUT structure contains information about a simulated keyboard event.
Syntax
typedef struct tagKEYBDINPUT {
WORD wVk;
WORD wScan;
DWORD dwFlags;
DWORD time;
ULONG_PTR dwExtraInfo;
} KEYBDINPUT, *PKEYBDINPUT;
Members
wVk
Specifies a virtual-key code. The code must be a value in the range 1 to 254. The Winuser.h header file provides macro definitions (VK_*) for each value. If the dwFlags member specifies KEYEVENTF_UNICODE, wVk must be 0.
wScan
Specifies a hardware scan code for the key. If dwFlags specifies KEYEVENTF_UNICODE, wScan specifies a Unicode character which is to be sent to the foreground application.
dwFlags
Specifies various aspects of a keystroke. This member can be certain combinations of the following values.
KEYEVENTF_EXTENDEDKEY
If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).
KEYEVENTF_KEYUP
If specified, the key is being released. If not specified, the key is being pressed.
KEYEVENTF_SCANCODE
If specified, wScan identifies the key and wVk is ignored.
KEYEVENTF_UNICODE
Windows 2000/XP: If specified, the system synthesizes a VK_PACKET keystroke. The wVk parameter must be zero. This flag can only be combined with the KEYEVENTF_KEYUP flag. For more information, see the Remarks section.
time
Time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.
dwExtraInfo
Specifies an additional value associated with the keystroke. Use the GetMessageExtraInfo function to obtain this information.
Remarks
Windows 2000/XP: INPUT_KEYBOARD supports nonkeyboard-input methods—such as handwriting recognition or voice recognition—as if it were text input by using the KEYEVENTF_UNICODE flag. If KEYEVENTF_UNICODE is specified, SendInput sends a WM_KEYDOWN or WM_KEYUP message to the foreground thread's message queue with wParam equal to VK_PACKET. Once GetMessage or PeekMessage obtains this message, passing the message to TranslateMessage posts a WM_CHAR message with the Unicode character originally specified by wScan. This Unicode character will automatically be converted to the appropriate ANSI value if it is posted to an ANSI window.
Windows 2000/XP: Set the KEYEVENTF_SCANCODE flag to define keyboard input in terms of the scan code. This is useful to simulate a physical keystroke regardless of which keyboard is currently being used. The virtual key value of a key may alter depending on the current keyboard layout or what other keys were pressed, but the scan code will always be the same.
Structure Information
Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows 98, Windows NT 4.0 Service Pack 3
See Also
Keyboard Input, GetMessageExtraInfo, INPUT, SendInputRe: Changing the keyboard indicator LEDs
viewtopic.php?t=7689ricardo wrote:I get this when try to compile your code:
keybd_event_( is not a function, etc, etc
just wait for the final release or next beta...
Timo
quidquid Latine dictum sit altum videtur



