Jump to content
Draygoes

Turning off capslock... {Solved}

Recommended Posts

Draygoes

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.

 

 

Share this post


Link to post
Share on other sites
TheDcoder

@badcoder123 I suggest using $VK_CAPITAL:

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

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

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
Draygoes

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.

 

 

Share this post


Link to post
Share on other sites
PACaleala
$WshShell = ObjCreate("WScript.Shell")
$WshShell.SendKeys("{CAPSLOCK}")

"Let AutoIt shine !"

  • Like 2

Share this post


Link to post
Share on other sites
Draygoes

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.

 

 

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

×