GLBasic forum

Main forum => GLBasic - en => Topic started by: Crivens on 2012-Jul-18

Title: Detecting CAPS LOCK
Post by: Crivens on 2012-Jul-18
Ok so KEY(58) can detect when CAPS LOCK is pressed, but is there a command for detecting what the current status of CAPS LOCK is?

Cheers
Title: Re: Detecting CAPS LOCK
Post by: Kitty Hello on 2012-Jul-18
not really. Or is it reporting "pressed" when it's down? I don't think SDL offers a way to tell. There might be platform specific APIs to do so, if it's needed.
Title: Re: Detecting CAPS LOCK
Post by: Ruidesco on 2012-Jul-19
According to http://www.libsdl.org/docs/html/guideinputkeyboard.html the CapsLock and NumLock are retrieved in an enabled/disabled fashion rather than pressed/released if you look up the mod parameter rather than the key one.

PS. I guess that ScrollLock works that way too, though that key appears less and less in modern keybs.
Title: Re: Detecting CAPS LOCK
Post by: Kitty Hello on 2012-Jul-19
yeah, who want's a locked scrolling anyway? We want all smooth graphics. </silly_answer>
Title: Re: Detecting CAPS LOCK
Post by: Moru on 2012-Jul-19
Scroll lock is often used for KVM switches to activate the switch of computers. Very handy button since it's almost never used for anything else :-)
Title: Re: Detecting CAPS LOCK
Post by: erico on 2012-Jul-19
Quote from: Kitty Hello on 2012-Jul-19
yeah, who want's a locked scrolling anyway? We want all smooth graphics. </silly_answer>

Unlock your scroll everyonel! :D
Title: Re: Detecting CAPS LOCK
Post by: Crivens on 2012-Jul-19
Ah, it's not the end of the world as it doesn't matter for my mobile devices, and the PC works anyway. I just wanted an onscreen marker to show the caps lock status. I suppose I could look into Windows API calls or somesuch but it's not that big a deal. I just thought there might be a GLB command I missed.

Cheers
Title: Re: Detecting CAPS LOCK
Post by: MrTAToad on 2012-Jul-19
You would use GetKeyState for Windows...
Title: Re: Detecting CAPS LOCK
Post by: Crivens on 2012-Jul-19
Yeah probably would be best. I used it in VB6 and AutoIT years ago so should be easy enough to convert. And stuff Macs/Linux :) To be honest though there is little to no chance this app will be available on PCs so it's only a nicety for me testing the thing.

Cheers
Title: Re: Detecting CAPS LOCK
Post by: matchy on 2012-Jul-20
Like in VB, is there a way to send a key press in run-time back to itself?
Title: Re: Detecting CAPS LOCK
Post by: MrTAToad on 2012-Jul-20
Yes, but its not reliable...  You use the SendKey function in Windows
Title: Re: Detecting CAPS LOCK
Post by: Crivens on 2012-Jul-20
Yeah I used a load of AutoIT scripts years ago to automate logging into our Unix systems (I normally have at least 12 terminal sessions open at one time for my job). Pretty sure I used a lot of SendKey stuff. AutoIT turned out to be a bit friendlier for doing exactly what I wanted(and getting a simple program out to a lot of sites). I think I grabbed the Terminal window handler IDs, switched to them when I wanted to send some key data, and then did SendKey (or whatever it was I used as I'm sure I used SendKey and something else - would check but I can't be bothered getting my Cryptokey from upstairs...).

Works fine apart from you do anything else at the same time as the script and it can be just the right moment between selecting the window with the handler ID and sending the keys. For the life of me couldn't get it to correctly send to a given Terminal's text section, or even read from it. Then again we do use our own in-house written telnet terminal software, and also an SSH program (SNetterm) that seems good at also hiding things from external programs.

Cheers