Jump to content

Recommended Posts

Posted

HotKeySet only works with lowercase letters, why not work to use a capital letter?

Posted (edited)

Set HotKey for both the keys

#include-once
#include <WinAPIEx.au3> ;http://www.autoitscript.com/forum/topic/98712-winapiex-udf/
#include <Misc.au3>

;Check the following

HotKeySet("A", "a")
HotKeySet("a", "a")

While Sleep(10)
WEnd

Func a()
    ConsoleWrite(GetCaps() & @CRLF)
EndFunc   ;==>a



;In the case you need the function.
;Returns True when either CAPS LOCK or SHIFT key is pressed, otherwise False
Func GetCaps()
    Local $fCaps = _Winapi_GetKeyState(0x14)
    Local $fShift = _IsPressed("10")
    Return $fCaps <> $fShift
EndFunc   ;==>GetCaps



;Environment(Language:0409  Keyboard:000B0409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64) 

I guess this case appears in x64, in x32 it  worked with both uppercase and lower case

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

Did not express myself well, why not work if set upper or lower case without using capsloock?

Posted

Using only HotKeySet not work.

HotKeySet("a", "a")
HotKeySet("B", "b")

While 1
    Sleep(10)
WEnd

Func a()
    ConsoleWrite("'a' key pressed" & @CRLF)
EndFunc   ;==>a

Func b()
    ConsoleWrite("'B' key pressed" & @CRLF)
EndFunc   ;==>b
Posted

It would be nice if it were accepted uppercase using the function HotKeySet native Autoit

Posted

This should clear any persisting doubts

#include-once
#include <WinAPIEx.au3> ;http://www.autoitscript.com/forum/topic/98712-winapiex-udf/
#include <Misc.au3>


;Check the following
Func HotKeySet_Uppercase_Lowercase($s_Key, $s_Func = "")

    HotKeySet(StringLower($s_Key), $s_Func)
    If StringIsAlpha($s_Key) Then HotKeySet(StringUpper($s_Key), $s_Func)

EndFunc

HotKeySet_Uppercase_Lowercase("A", "Func_A")
HotKeySet_Uppercase_Lowercase("b", "Func_B")

While Sleep(10)
WEnd

Func Func_A()

    If GetCaps() Then ConsoleWrite("Capital ")
    ConsoleWrite("A Pressed" & @CRLF)

EndFunc   ;==>a

Func Func_B()

    If GetCaps() Then ConsoleWrite("Capital ")
    ConsoleWrite("B Pressed" & @CRLF)

EndFunc


;In the case you need the function.
;Returns True when either CAPS LOCK or SHIFT key is pressed, otherwise False
Func GetCaps()
    Local $fCaps = _Winapi_GetKeyState(0x14)
    Local $fShift = _IsPressed("10")
    Return $fCaps <> $fShift
EndFunc   ;==>GetCaps



;Environment(Language:0409  Keyboard:000B0409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)

 
Thanks to Yashied for WinAPIEx
Regards :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

This way I can do well, my question is why using only HotkeySet not work with capital letters? It would be nice if it were already native Autoit accept maiúculas to create Hotkeys.

HotKeySet("a", "Func_a")

$key = StringLower("B")
HotKeySet('{' & $key & '}', "Func_b")

While Sleep(10)
WEnd

Func Func_a()
    ConsoleWrite(' "a" Pressed' & @CRLF)
EndFunc   ;==>Func_a

Func Func_b()
    ConsoleWrite(' "B" Pressed' & @CRLF)
EndFunc   ;==>
Posted (edited)

So, "WHY" is the question I figured out till now :P

Now its a native function, what I can guess is the HotKeySet uses the function RegisterHotkey over the hidden Autoit Window {to retrieve its handle use WinGetHandle(AutoItWinGetTitle ( ))}

And RegisterHotkey differentiates keystrokes when they are pressed w/Shift or w/o Shift using modifiers. Therefore it might be programmed in AutoIT to use the SHIFT modifier whenever an uppercase char is passed in the function HotKeySet.

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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
×
×
  • Create New...