[Gambas-user] Caps Lock - Num Lock state howto

Stefano Palmeri rospolosco at ...152...
Thu Apr 3 19:25:09 CEST 2008


Hi.

Sometime ago, we talked about Caps Lock and Num Lock keys
state. I think it was a request by MaxVK. 
I suggested a dirty solution using the Desktop.SendKey function.

On gambas-it.org, the italian Gambas community site, I found a more clean
way to get the state of those keys. Thanks to user "fsurfing" I found 
xset.

Here is an example (ehi Max, this is more clean :-) )

PUBLIC SUB Main()
  
  DIM sShellOutput AS String
  DIM iKeyLocks AS Integer
  
  SHELL "xset q | grep 'LED mask:'" TO sShellOutput
  
  sShellOutput = Replace$(sShellOutput, " ", "")
  
  iKeyLocks = Val(Split(sShellOutput, ":")[3])
  
  SELECT iKeyLocks
   
    CASE 1
      PRINT "Caps Lock is ON"
    CASE 2
      PRINT "Num Lock is ON"
    CASE 3
      PRINT "Caps Lock is ON"
      PRINT "Num Lock is ON"
  
  END SELECT         
      
END

Regards,

Stefano


     




More information about the User mailing list