Author Topic: Detecting CAPS LOCK  (Read 3714 times)

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Detecting CAPS LOCK
« 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
Current fave quote: Cause you like musicians and I like people with boobs.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Detecting CAPS LOCK
« Reply #1 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.

Offline Ruidesco

  • Mr. Polyvector
  • ***
  • Posts: 236
    • View Profile
Re: Detecting CAPS LOCK
« Reply #2 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.
« Last Edit: 2012-Jul-19 by Ruidesco »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Detecting CAPS LOCK
« Reply #3 on: 2012-Jul-19 »
yeah, who want's a locked scrolling anyway? We want all smooth graphics. </silly_answer>

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1793
    • View Profile
    • Homepage
Re: Detecting CAPS LOCK
« Reply #4 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 :-)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4450
    • View Profile
    • FUED
Re: Detecting CAPS LOCK
« Reply #5 on: 2012-Jul-19 »
yeah, who want's a locked scrolling anyway? We want all smooth graphics. </silly_answer>

Unlock your scroll everyonel! :D

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: Detecting CAPS LOCK
« Reply #6 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
Current fave quote: Cause you like musicians and I like people with boobs.

MrTAToad

  • Guest
Re: Detecting CAPS LOCK
« Reply #7 on: 2012-Jul-19 »
You would use GetKeyState for Windows...

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: Detecting CAPS LOCK
« Reply #8 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
Current fave quote: Cause you like musicians and I like people with boobs.

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: Detecting CAPS LOCK
« Reply #9 on: 2012-Jul-20 »
Like in VB, is there a way to send a key press in run-time back to itself?

MrTAToad

  • Guest
Re: Detecting CAPS LOCK
« Reply #10 on: 2012-Jul-20 »
Yes, but its not reliable...  You use the SendKey function in Windows

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: Detecting CAPS LOCK
« Reply #11 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
Current fave quote: Cause you like musicians and I like people with boobs.