Jump to content

Turning off capslock... {Solved}


Draygoes
 Share

Recommended Posts

Hi all.
Ok, so the idea is to check if the caps lock key is on and if so switch it off, run a function and exit. At least that is the idea for the final script.
Right now I just have it executing a msgbox in place. Detection of key works fine, but switching it off not so much.

Global Const $VK_CAPITAL = 0x14
    If _Key_Is_On($VK_CAPITAL) Then Send("{CAPSLOCK Toggle}")
If _Key_Is_On($VK_CAPITAL) Then
    MsgBox( 0, "", "")
EndIf
     
    Func _Key_Is_On($nVK_KEY, $vDLL = 'User32.dll')
    Local $a_Ret = DllCall($vDLL, "short", "GetKeyState", "int", $nVK_KEY)
    Return Not @error And BitAND($a_Ret[0], 0xFF) = 1
EndFunc



Any help would be wonderful.
Thanks.

Edited by Draygoes
Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

@badcoder123 I suggest using $VK_CAPITAL:

#Include <WinAPI.au3>
#include <WinAPIvkeysConstants.au3>

$_Status = _WinAPI_GetAsyncKeyState($VK_CAPITAL)
ConsoleWrite($_Status)

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Getting the status is not the problem.
Turning it off does not work.

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

Yes, this works perfectly!

Thank you PACaleala! :)

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
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...