keyboard led status & LED demo

In this category you can exchange your programming questions and solutions.
Post Reply
Bob Hays
Posts: 26
Joined: Sun Oct 03, 2010 4:49 pm

keyboard led status & LED demo

Post: # 673Post Bob Hays
Fri Nov 26, 2010 3:45 pm

2 questions:
1) how can I get the status of the keybord leds? :-?
          I want to display the Num  ans Caps state on the status
          bar of my application
2)How can I get the LED demo to work with the new compiler. :-?
          I would like to use the LED routine on the status bar also

Bob Hays
Posts: 26
Joined: Sun Oct 03, 2010 4:49 pm

keyboard led status & LED demo

Post: # 674Post Bob Hays
Mon Nov 29, 2010 12:50 am

I figured out the keyboard status routine figured out - just cannot get initial status` to show up when the application is started. ????

I seams that record does not support complex variables such as:
record led as image
end record
"expecting as but got image"

or

record led
  dim led as image
end record

"expecting simple variable but got image"

record led
  dim led as integer

  sub paint()

fred
Posts: 54
Joined: Thu Apr 23, 2009 10:08 am

keyboard led status & LED demo

Post: # 675Post fred
Mon Nov 29, 2010 2:56 pm

Did not look into it yet but two remarks:
Image is a windows object, not a (real) data type as integer.
Using a record name and the same var name is not allowed?

Marco
Site Admin
Posts: 246
Joined: Sat Sep 15, 2018 8:41 pm

keyboard led status & LED demo

Post: # 676Post Marco
Mon Nov 29, 2010 4:26 pm

Hi, there is no type statement within the new fnxbasic yet.
The old example will not work.
record is only for nummeric and string types.

best regards

Bob Hays
Posts: 26
Joined: Sun Oct 03, 2010 4:49 pm

keyboard led status & LED demo

Post: # 677Post Bob Hays
Mon Nov 29, 2010 8:53 pm

:( I guess i`ll sit and twiddle my thumbs.

Marco
Site Admin
Posts: 246
Joined: Sat Sep 15, 2018 8:41 pm

keyboard led status & LED demo

Post: # 678Post Marco
Wed Dec 01, 2010 10:35 pm

part one :)


Const VK_Capital = &H14
Const VK_Numlock = &H90
Const VK_Scroll = &H91

declare ledstate as "GetKeyState" of "user32"
  vkkey as integer
  result as integer
end declare

function getstate(key as integer) as boolean
  ledstate.vkkey=key
  ledstate.execute
  result=ledstate.result
end function

if getstate(vk_capital)=true then print "capslock is activated"
if getstate(vk_numlock)=true then print "numlock is activated"
if getstate(vk_scroll)=true then print "scrollock is activated"
showmessage "check consolescreen"

i hope this will help a bit
best regards

Bob Hays
Posts: 26
Joined: Sun Oct 03, 2010 4:49 pm

keyboard led status & LED demo

Post: # 679Post Bob Hays
Thu Dec 02, 2010 12:48 am

That solution looks a bit simpler than the one i wrote. Thanks.  :)

Now if I could JUST figure out how to draw an "LED" on the status bar for those states! :-?

Marco
Site Admin
Posts: 246
Joined: Sat Sep 15, 2018 8:41 pm

keyboard led status & LED demo

Post: # 680Post Marco
Sat Dec 04, 2010 4:21 pm

here is a little program that produces leds:

`=====MAIN LED ROUTINES==============
`=COLORS: RED GREEN AND BLUE        =   
`=METHODS: LEDON(IMAGE.CANVAS,COLOR)= 
`=         LEDOFF(IMAGE.CANVAS)     =
`====================================

const blue=rgb(0,0,255)
const green=rgb(0,200,0)
const red=rgb(255,0,0)

sub led
  dim bmp as bitmap
  dim effect as integer
  dim c as integer,size as byte
  dim on as boolean
  size=8
  if on=false then effect=rgb(120,120,120)
  bmp.width=size*2
  bmp.height=size*2
  bmp.transparentcolor=&hffffff
  bmp.transparent=true
  bmp.canvas.circle(size,size,size,0)
  bmp.canvas.fill(size,size,effect,0)
  for c=size-4 to size
    bmp.canvas.line(c/2,c,c,c/2,&hffffff)
  next c
end sub

sub ledon(s as canvas,effect as integer)
  led.effect=effect
  led.on=true
  led
  s.draw(0,0,led.bmp)
end sub

sub ledoff(s as canvas)
  led.on=false
  led
  s.draw(0,0,led.bmp)
end sub


`=======Example prograM======
object myform as form
  object led1 as image
    left=10
    top=10
    transparent=true
  end object
  object led2 as image
    left=10
    top=30
    transparent=true
  end object 
end object

ledon(led1.canvas,red)
ledoff(led2.canvas)
myform.showmodal


best regards marco
















Bob Hays
Posts: 26
Joined: Sun Oct 03, 2010 4:49 pm

keyboard led status & LED demo

Post: # 681Post Bob Hays
Tue Dec 07, 2010 1:34 am

Thanks - This routine helped me understand how it works.


Post Reply