Page 1 of 1 1
Topic Options
#121320 - 2004-06-16 05:46 AM Case-Sensitive Sendkeys() or Keystate()
Allen Administrator Online   shocked
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
#121321 - 2004-06-16 10:40 AM Re: Case-Sensitive Sendkeys() or Keystate()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Hi Alpo

I know this is not what you're looking for exactly, but here are a couple files to toggle the state.

NumOn (Enable Numlock)
http://www.kixhelp.com/Downloads/numon.exe

NumOff (Disable Numlock)
http://www.kixhelp.com/Downloads/numoff.exe

Top
#121322 - 2004-06-22 04:00 AM Re: Case-Sensitive Sendkeys() or Keystate()
Allen Administrator Online   shocked
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 Offline
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 Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Looks very similar to C..

But, Shawn may have nailed it.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#121325 - 2004-06-22 04:54 PM Re: Case-Sensitive Sendkeys() or Keystate()
Allen Administrator Online   shocked
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 Offline
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 Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
With the Dynawrapper dll, setting the keystate is now possible.

See SetKeyState - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=190022#Post190022

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 496 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.059 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org