Sign in to follow this  
Followers 0
Paulie

Caps Toggle

6 posts in this topic

#1 ·  Posted (edited)

Well, I've been fiddling around with this for a long time now, and i can't get a result that works consistently.

Basically, I'm trying to make my capslock key function like a shift key (without mapping it to shift). What i want to happen, as long as the Caps key is held down, capslock will be on, but as soon as you release caps, it turns capslock off.

I'm doing this because I want to make capslock my Push-to-Talk hotkey for Ventrilo, but i don't want to have to push it twice to avoid typing in all caps all the time.

I made a script that sort of worked, but if i clicked the mouse when capslock was being held and then released capslock, it would turn the indicator light off, as though caps wasn't on but it would still type in all caps. I dunno... it was weird.

I've tried a billion things, but here is the closest I could get:

#include <Misc.au3>
Opt("sendcapslockmode", 0)
While 1
    If GETCAPSLOCK() = 1 And Not _ISPRESSED("14") Then
        ControlSend("", "", "", "{CAPSLOCK off}")
    EndIf
    Sleep(100)
WEnd

Func GETCAPSLOCK()
    Local $RET
    $RET = DllCall("user32.dll", "long", "GetKeyState", "long", "0x14")
    Return $RET[0]
EndFunc
Edited by Paulie

Share this post


Link to post
Share on other sites



if i clicked the mouse when capslock was being held and then released capslock, it would turn the indicator light off, as though caps wasn't on but it would still type in all caps.

I can not confirm that, the example works fine for me :D ...

Perhaps it's happening on some specific window? Or everywhere?


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Well, I've been fiddling around with this for a long time now, and i can't get a result that works consistently.

Basically, I'm trying to make my capslock key function like a shift key (without mapping it to shift). What i want to happen, as long as the Caps key is held down, capslock will be on, but as soon as you release caps, it turns capslock off.

I'm doing this because I want to make capslock my Push-to-Talk hotkey for Ventrilo, but i don't want to have to push it twice to avoid typing in all caps all the time.

I made a script that sort of worked, but if i clicked the mouse when capslock was being held and then released capslock, it would turn the indicator light off, as though caps wasn't on but it would still type in all caps. I dunno... it was weird.

I've tried a billion things, but here is the closest I could get:

#include <Misc.au3>
Opt("sendcapslockmode", 0)
While 1
    If GETCAPSLOCK() = 1 And Not _ISPRESSED("14") Then
        ControlSend("", "", "", "{CAPSLOCK off}")
    EndIf
    Sleep(100)
WEnd

Func GETCAPSLOCK()
    Local $RET
    $RET = DllCall("user32.dll", "long", "GetKeyState", "long", "0x14")
    Return $RET[0]
EndFunc

You could cheat and just edit the registry like this.

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout", "Scancode Map", "REG_BINARY", "0000000000000000020000002a003a0000000000")

Then reboot, and the Caps Lock will behave like a shift key but is still considered the Caps Lock.

To disable it just remove the key. Or run this.

RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout", "Scancode Map")

As always please make a backup copy of your registry before you edit it. ;p

Share this post


Link to post
Share on other sites

This is what I use to make Capslock act like Shift without re-mapping the key.

#include <Misc.au3>
Opt("SendCapslockMode", 0)

Local $hUserDLL = DllOpen("user32.dll")
  Send("{CAPSLOCK off}")
HotKeySet("{CAPSLOCK}", "_HoldCAP")

While 1
    Sleep(100)
WEnd

Func _HoldCAP()
    HotKeySet("{CAPSLOCK}")
    Send("{CAPSLOCK on}")
    Do
        Sleep(100)
    Until Not _IsPressed("14", $hUserDLL)
    ControlSend("", "", "", "{CAPSLOCK off}")
    HotKeySet("{CAPSLOCK}", "_HoldCAP")
EndFunc   ;==>_HoldCAP

One unintended but welcome side effect is that Shift-Capslock will toggle Capslock normally, for those rare times when you actually want to type in caps.

Please let me know if it works for you. I don't have Ventrilo installed here, so I'll have to test it later tonight.

p.s. Thank you for your contributions to the community.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

try also this:

#include <Misc.au3>
Opt("sendcapslockmode", 0)
$Toggle = False
While 1
    If _IsPressed("14") And $Toggle = False Then
        $Toggle = True
    EndIf
    If Not _IsPressed("14") And $Toggle = True Then
        ControlSend("", "", "", "{CAPSLOCK off}")
    EndIf
    Sleep(100)
WEnd

Share this post


Link to post
Share on other sites

wELL.... HERE'S A STAB AT IT

HotKeySet("{CAPSLOCK}", "_GETCAPSLOCK")

While 1
    Sleep(100)
WEnd

Func _GETCAPSLOCK()
    $Begin = TimerInit()
    While __ISPRESSED("14")
        Sleep(100)
    WEnd
    $Diff = Int(TimerDiff($Begin) / 1000)
    ToolTip($Diff, 20, 20)
    If $Diff <= 1 Then Return MsgBox(4096, "CAPS", "CAPLOCK SENT   ", 1)
    Return 0
EndFunc   ;==>GETCAPSLOCK

Func __IsPressed($sHexKey, $vDLL = 'user32.dll')
    Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc   ;==>__IsPressed

8)


NEWHeader1.png

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  
Followers 0