#121320 - 2004-06-16 05:46 AM
Case-Sensitive Sendkeys() or Keystate()
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
I would like to see either an updated sendkeys function that sends the keys as they are actually typed in the script, not being effected by Capslock or Numlock, or as another suggestion, maybe a function like keystate(), which allows you to not only set the state of capslock and numlock, but also allow you to check it.
I'm aware the AutoIT has this functionality to some degree and I would consider this suggestion pretty low priority. However, it's something I have run across, and have seen other people asking about as well: Check for CAPSLOCK What is NumLock key status?
I have absolutely no idea how hard this would be to add, but I've found a few articles discussing how this is done in vb:
HOWTO Find Keystate of Numlock, Capslock etc., in VB HOWTO: Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys
|
Top
|
|
|
|
#121322 - 2004-06-22 04:00 AM
Re: Case-Sensitive Sendkeys() or Keystate()
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
I just found some code that supposedly set and checks the states of the numlock, capslock and scroll lock. The name of the file is keystate.bat and it looks very similiar to a batch file but its not... anyone have any ideas what might run this code?
Code:
@echo off ::~~~1 Set, unset, or display the state of keys NUMLOCK, CAPSLOCK or SCROLL keys.
SEDOS %0.bat %1 %2 %3 %4 GOTO SE_EXIT
#define NUMLOCK_BIT 0x20 #define CAPSLOCK_BIT 0x40 #define INSERT_BIT 0x80 #define KEYS_SEGMENT 0x0040 #define KEYS_OFFSET 0x0017 KeysAddress = Address(KEYS_SEGMENT,KEYS_OFFSET)
main(argc,argv) { // check that the input is valid if ( argc != 3 || ( argv[1][1] != 0 || !strchr("+?-",argv[1][0]) ) || ( strnicmp("CAP",argv[2],3) && strnicmp("NUM",argv[2],3) && strnicmp("INS",argv[2],3) ) ) { Instructions() } else { // determine whether to apply to CapsLock or NumLock if ( !strnicmp("CAP",argv[2],3) ) { KeyName = "CapsLock", KeyBit = CAPSLOCK_BIT } else if ( !strnicmp("NUM",argv[2],3) ) { KeyName = "NumLock", KeyBit = NUMLOCK_BIT } else { KeyName = "Insert", KeyBit = INSERT_BIT } // perform action on the selected key CurrentState = peek(KeysAddress) switch( argv[1][0] ) { case '+': // Set Key ON poke(KeysAddress,CurrentState | KeyBit) break case '-': // Turn KEY OFF poke(KeysAddress,CurrentState & ~KeyBit) break case '?': // display and return state of key printf("%s is currently set %s.\n",KeyName,CurrentState & KeyBit ? "ON" : "OFF") return( CurrentState & KeyBit ? 1 : 0 ) } } }
Instructions() { printf("\a\n") printf("KeyState - Set, Clear, or Show the keyboard state of NumLock or CapsLock\n"); printf("\n"); printf("SYNTAX: KeyState < + | - | ? > < CAP | NUM | INS >\n"); printf("\n"); printf("Where: + Set KeyState ON\n"); printf(" - Set KeySTate OFF\n"); printf(" ? Display current Key State, and return ERRORLEVEL 1 if set\n"); printf(" and ERRORLEVEL 0 if clear\n"); printf(" NUM Apply command < + | - | ? > to the NumLock key\n"); printf(" CAP Apply command < + | - | ? > to the CapsLock key\n"); printf(" INS Apply command < + | - | ? > to the Insert key\n"); printf("\n"); printf("Examples: KeyState + Num Turn on the Numlock key\n"); printf(" KeyState - Cap Turn of the CapsLock key\n"); printf(" KeyState ? Num Show state of NumLock, return ERRORLEVEL if set\n"); printf("\n") }
:SE_EXIT
|
Top
|
|
|
|
#121323 - 2004-06-22 05:04 AM
Re: Case-Sensitive Sendkeys() or Keystate()
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Curious stuff ...
ScriptEase
-Shawn
|
Top
|
|
|
|
#121324 - 2004-06-22 07:43 AM
Re: Case-Sensitive Sendkeys() or Keystate()
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Looks very similar to C..
But, Shawn may have nailed it.
Kent
|
Top
|
|
|
|
#121325 - 2004-06-22 04:54 PM
Re: Case-Sensitive Sendkeys() or Keystate()
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
Thanks guys... looks like a whole other scripting language ... first I've heard of ScriptEase. Oh well, I'll just hope Ruud might take this one on sometime.
|
Top
|
|
|
|
#121326 - 2004-06-23 03:59 PM
Re: Case-Sensitive Sendkeys() or Keystate()
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
It looks like all "meta" keyboard keys will affect the result.
Run this script, and play with control, shift, caps lock and the "alt gr" keys (hit "q" to exit).
Code:
$=SetOption("WrapAtEOL","ON") $=SetOption("CaseSensitivity","ON") while Not($k="q" OR $k="Q") while KBHIT() Get $k $k loop $=SendKeys("++x") Loop while KBHIT() Get $k Loop
As you cannot toggle things like the shift key a SendKeys() which can send the data unmodified is a better option.
A KeyState() while not solving the problem would be a useful addition too.
|
Top
|
|
|
|
#190023 - 2008-10-05 06:15 AM
Re: Case-Sensitive Sendkeys() or Keystate()
[Re: Richard H.]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 370 anonymous users online.
|
|
|