Jump to content
Sign in to follow this  
myspacee

Small led (on/off) in my Gui

Recommended Posts

myspacee

Hello to all,

Try to script little screen on desktop keyboard, and search a nice effect to put

a 'led' on my gui that alert user that caps lock is on or off.

Anyone want to suggest me a nice way to do this without use external graphics ? (jpg, gif, etc.)

thank you,

m.

Share this post


Link to post
Share on other sites
Negative1

This should get you started on your way.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

GUICreate("Keyboard",100,100)
Opt("GUICoordMode",2)
Opt("GUIOnEventMode", 1)
$Capslock= guictrlcreatelabel("CAPSLOCK",1,-1,100,50,bitor($SS_CENTERIMAGE, $SS_CENTER))
$Numlock= guictrlcreatelabel("Numlock",-1,1,100,50,bitor($SS_CENTERIMAGE, $SS_CENTER))
GUICtrlSetBkColor($Capslock,0xFF0000);set red

GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUICtrlSetOnEvent($Capslock,"Capslock")
GUICtrlSetOnEvent($Numlock,"Numlock")
GUISetState()

while 1
    sleep(50)
WEnd

Func Close()
    Exit
EndFunc

Func Capslock()
    GUICtrlSetBkColor($Capslock,0x00FF00)
EndFunc

Func Numlock()
    GUICtrlSetBkColor($Numlock,0x00FF00)
EndFunc

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites
muncherw

Almost anyone could do this better than me but it looked like a fun exercise and this is what I came up with.

</P><P>#include <GUIConstantsEx.au3>
Global Const $VK_CAPITAL = 0x14
Global $ret
Global $circle
Local $msg

Func _GetCaps()
 $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_CAPITAL)
 Return $ret[0]
EndFunc  ;==>_GetCaps

$ret = _GetCaps()
$dll = DllOpen("user32.dll")

GUICreate("Caps Lock Status", 150, 75, 100, 100)
GUICtrlCreateLabel("Caps Lock", 8, 30, 60, 15)
$circle = GUICtrlCreateGraphic(60, 20, 10, 10)
GUISetState()


While $msg <> $GUI_EVENT_CLOSE
 Sleep(50)
 $ret = _GetCaps()
 If $ret = 0 Then; CAPS are OFF
    GUICtrlDelete($circle)
    $circle = GUICtrlCreateGraphic(60, 20, 10, 10)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFF0000)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 8, 8, 20, 20)
    GUICtrlSetGraphic($circle, $GUI_GR_REFRESH)

 ElseIf $ret = 1 Then; CAPS are ON
    GUICtrlDelete($circle)
    $circle = GUICtrlCreateGraphic(60, 20, 10, 10)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x00FF00)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 8, 8, 20, 20)
    GUICtrlSetGraphic($circle, $GUI_GR_REFRESH)
 EndIf
 
 $msg = GUIGetMsg()
WEnd
DllClose($dll)

Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×