Jump to content
Sign in to follow this  
Belini

HotKeySet doubt.

Recommended Posts

Belini

Share this post


Link to post
Share on other sites
JohnOne

It does work with upper case.

EDIT:

Well it does if you use SHIFT key to get UPPERCASE.

I think you'd have to make a feature request to natively work with CAPSLOCK.

Or code it yourself.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
PhoenixXL

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.

Share this post


Link to post
Share on other sites
Belini

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

Share this post


Link to post
Share on other sites
Belini

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

Share this post


Link to post
Share on other sites
FireFox

Yes it's case sensitive.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Belini

Share this post


Link to post
Share on other sites
FireFox

Don't expect the HotKeySet function to be changed, do like this:

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
PhoenixXL

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.

Share this post


Link to post
Share on other sites
Belini

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   ;==>

Share this post


Link to post
Share on other sites
PhoenixXL

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.

Share this post


Link to post
Share on other sites
Belini

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  

×