Jump to content

Missing lights on keyboard


Recommended Posts

I am using a logitech wireless keyboard - it has no @#$##$$ lights.

OK - took this code from a thread and started modifing it, but now I am stuck :D

Global Const $VK_CAPITAL = 0x14

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

While 1
    $STAT = _GetCapsLock()
    If  $STAT = 1 then 
        MsgBox(0,"Keys", "Caps Lock: ON",1)
    EndIf
        sleep(300)
    WEnd

What I want is for the window (a popup) to only be on (up) when the caps lock are on and when they are off to close the window (popup disappears) - can someone point me in the right direction?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

BUMP - it says no one has reviewed?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Xp itself has that option under control panel/accessability options if I remember correct.

edit: It doesn't for cap locks that I could tell, but here are several very short free programs that sit in your tray and tell you if caps lock is on. Just google caps lock.

Buck

Edited by Buckw1
Link to comment
Share on other sites

  • Moderators

Global Const $VK_CAPITAL = 0x14

While 1
    If _GetCapsLock() Then _MyPopUp()
    Sleep(300)
WEnd

Func _MyPopUp()
    $MyMain = GUICreate('Caps Lock', 200, 100, Default, Default, BitOr(0x80880000, 0x00000200), 0x00000008)
    $MyLabel = GUICtrlCreateLabel('You Have "Caps Lock" On', 10, 10, 180, 20, 0x0001)
    GUISetState()
    While _GetCapsLock()
        Sleep(10)
    WEnd
    GUIDelete($MyMain)
EndFunc

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

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

tRY THIS... oops, CAPS still on from testing! :D

#include<GUIConstants.au3>
Opt("GuiOnEventMode", 1)

Global Const $VK_CAPITAL = 0x14

$hGUI = GUICreate("", 150, 40, @DesktopWidth - 175, 25)
$hLabel = GUICtrlCreateLabel("CAPS LOCK IS ON!", 10, 10, 130, 20)
GUISetOnEvent($GUI_EVENT_CLOSE, "_WinClosed", $hGUI)

While 1
    If _GetCapsLock() Then
        GUISetState(@SW_SHOW, $hGUI)
    Else
        GUISetState(@SW_HIDE, $hGUI)
    EndIf
    Sleep(500)
WEnd

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

Func _WinClosed()
    Exit
EndFunc ;==>_WinClosed

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

@Smoke_N - that worked

@PsaltyDS - that worked too

great stuff - thanks for your help.

I have no idea why any keyboard would not have a light telling you the state.

Thanks again

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

@Smoke_N - that worked

@PsaltyDS - that worked too

great stuff - thanks for your help.

I have no idea why any keyboard would not have a light telling you the state.

Thanks again

Even though you already have a couple solutions I thought I would throw mine in.

Global Const $VK_CAPITAL = 0x14

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

$State = _GetCapsLock()
If $State = 1 then 
    ToolTip("Caps Lock: ON")        
    sleep(300)
    ToolTip("")
    $i = 1
Else
    ToolTip("Caps Lock: OFF")
    sleep(300)
    ToolTip("")
    $i = 0
EndIf


While 1
    $State = _GetCapsLock()
    If $State = 1 then 
        While 2
            $State = _GetCapsLock()
            If $State = 1 then 
                If $i = 0 Then
                    ToolTip("Caps Lock: ON")        
                    sleep(300)
                    ToolTip("")
                    $i = 1
                EndIf
            EndIf
            ExitLoop 
        WEnd
    Else
        While 3
            $State = _GetCapsLock()
            If $State = 0 then 
                If $i = 1 Then
                    ToolTip("Caps Lock: OFF")
                    sleep(300)
                    ToolTip("")
                    $i = 0
                EndIf
            EndIf
            ExitLoop 
        WEnd
    EndIf
    Sleep(25)       
WEnd
INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
Link to comment
Share on other sites

Micha wrote this awhile ago:

#include <GUIConstants.au3>
#include <Constants.au3>
Opt("TrayIconHide", 1)
Global Const $VK_NUMLOCK = 0x90
Global Const $VK_SCROLL = 0x91
Global Const $VK_CAPITAL = 0x14
dim $x,$y
$Apps="Keylocks"
$Off=0x999999
$On=0x00ff00
_getWindowPos()
$mainGui=GUICreate($Apps,100,48,$x,$y,BitOR($WS_OVERLAPPED,$WS_SYSMENU),BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
$label1=GUICtrlCreateLabel("Num",3,10)
$labelNum=GUICtrlCreateLabel(" ",5,0,15,8,$SS_SUNKEN)
$labelCaps=GUICtrlCreateLabel(" ",35,0,15,8,$SS_SUNKEN)
$label2=GUICtrlCreateLabel("Caps",33,10)
$labelScroll=GUICtrlCreateLabel(" ",65,0,15,8,$SS_SUNKEN)
$label3=GUICtrlCreateLabel("Scroll",63,10)

_main()

Func _main()
GUISetState(@SW_SHOW)
;GUICtrlSetState($Apps,$GUI_disable)
While 1
    $msg = GUIGetMsg()
        Select
            case $msg=$GUI_EVENT_CLOSE
            _saveWindowPos()    
        ExitLoop
    EndSelect
_toggleKeys()
sleep(10)
WEnd
exit
EndFunc

Func _toggleKeys()
    
if _getNumLock() =0 then
GUICtrlSetBkColor($labelNum,$Off)
Else
GUICtrlSetBkColor($labelNum,$on)
EndIf
if _GetScrollLock() =0 Then
GUICtrlSetBkColor($labelScroll,$Off)
Else
GUICtrlSetBkColor($labelScroll,$on)
EndIf
if _GetCapsLock() =0 Then
GUICtrlSetBkColor($labelCaps,$Off)
Else
GUICtrlSetBkColor($labelCaps,$on)
EndIf

EndFunc

;Code from gafrost ==> http://www.autoitscript.com/forum/index.php?showtopic=12056
Func _GetNumLock()
    Local $ret
    $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK)
    Return $ret[0]
EndFunc

Func _GetScrollLock()
    Local $ret
    $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_SCROLL)
    Return $ret[0]
EndFunc

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

func _saveWindowPos()
$pos=WinGetPos ( $Apps )
if not @error Then
    IniWrite(@ScriptDir&"\Keylocks.ini","Position","x",$pos[0])
    IniWrite(@ScriptDir&"\Keylocks.ini","Position","y",$pos[1])
EndIf
EndFunc
Func _getWindowPos()
    $x=IniRead(@ScriptDir&"\Keylocks.ini","Position","x",@DesktopWidth -100)
    $y=IniRead(@ScriptDir&"\Keylocks.ini","Position","y",@DesktopHeight-80)
EndFunc

Based off of Gafrosts code, nice little gui.

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

@Simucal I like this one the best - thanks @Micha ( I looked through the forum and did not find this).

@gafrost - I did find the code that he wrote on the link - that is where I started.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...