Sign in to follow this  
Followers 0

suggestion to use different modifiers on send() & hotkeyset()

38 posts in this topic

Posted (edited)

hi chiefs !

this is not a real bug, but this is the urgent request to modify two functions with regards to international users.

the modifier keys used for send() and hotkeyset() are badly chosen. on the German keyboard, the keys + # ^ are found on the lower case register (unshifted) of the keyboard with the consequence that + # ^ keys cannot be sent nor hotkeyed, because the function send"{+}" or send"{#}" or send"{^}" is not possible. i have not found a workaround for this.

on the us keyboard there is no problem because the modifiers are on the shift level. thus you can adress "+" like send"{+=}" (shift =). not so on other keyboards.

the following keys do not work for non-u.s. kblayouts ( i did not search all layouts that exist, just some ):

! on French layout

# on German layout

^ on French and German layouts

+ on Italian, German, Danish, Swedish, Norwegian, Polish layouts

it would be clever to find modifiers that are not situated on the primary keyboard level on any layout. the most simple solution is to use uppercase letters, since they always can be adressed by "shift" when supposed to be used in a send or hotkey function. so let it be:

S for shift => send("Ss") for shift+s instead of "+s"

A for alt => send("Aa") for alt+a instead of "!c"

C for control => send("Cc") for ctrl+c instead of "^c"

W for window key => send("Ww") for win+w instead of "#w"

by the way, these four are easy to reach and easy to keep in mind.

i would be pleased if my suggestion would be realized, you all know that autoit is used by lots of non-u.s. users, and they all want to be able to send and hotkey the modifier keys !

thank you

j.

Edited by jennico

Share this post


Link to post
Share on other sites



Posted (edited)

When you know its no Bug its kinda strange you post it here anyways ..don't you think ?

- Moved -

Edited by Jos

Share this post


Link to post
Share on other sites

Posted

hi chiefs !

this is not a real bug, but this is the urgent request to modify two functions with regards to international users.

the modifier keys used for send() and hotkeyset() are badly chosen. on the German keyboard, the keys + # ^ are found on the lower case register (unshifted) of the keyboard with the consequence that + # ^ keys cannot be sent nor hotkeyed, because the function send"{+}" or send"{#}" or send"{^}" is not possible. i have not found a workaround for this.

on the us keyboard there is no problem because the modifiers are on the shift level. thus you can adress "+" like send"{+=}" (shift =). not so on other keyboards.

the following keys do not work for non-u.s. kblayouts ( i did not search all layouts that exist, just some ):

! on French layout

# on German layout

^ on French and German layouts

+ on Italian, German, Danish, Swedish, Norwegian, Polish layouts

it would be clever to find modifiers that are not situated on the primary keyboard level on any layout. the most simple solution is to use uppercase letters, since they always can be adressed by "shift" when supposed to be used in a send or hotkey function. so let it be:

S for shift => send("Ss") for shift+s instead of "+s"

A for alt => send("Aa") for alt+a instead of "!c"

C for control => send("Cc") for ctrl+c instead of "^c"

W for window key => send("Ww") for win+w instead of "#w"

by the way, these four are easy to reach and easy to keep in mind.

i would be pleased if my suggestion would be realized, you all know that autoit is used by lots of non-u.s. users, and they all want to be able to send and hotkey the modifier keys !

thank you

j.

I see a problem with that right off the bat.

For example, let's say I'm sending names to a field on app for examp "Aaron", guess what that would send Alt+aron and not what I would want to send.

Share this post


Link to post
Share on other sites

Posted (edited)

For example, let's say I'm sending names to a field on app for examp "Aaron", guess what that would send Alt+aron and not what I would want to send.

well, really not a big problem:

- send("Saaron")

the S makes a similar job to the ampersand for underlining.

or just like it is possible now:

- send("{SHIFT}aaron")

for your problem there are many solutions, but there is no solution for the +#!^ problem on non u.s. keyboards.

the capital letters are only a suggestion. if there could be found other keys available on all keyboards, they would do it, too.

j

Edited by jennico

Share this post


Link to post
Share on other sites

Posted

meanwhile i've been looking for some chars that are available on all keyboards on shift level:

there only seem to be four of them: $ % & ? (as far as i could check the keyboards)

if you don't like my upper case letter suggestion, $ % & ? would still be better than ! ^ # +.

could this change be done ?

j.

Share this post


Link to post
Share on other sites

Posted

does anyone understand the problem at least ?

j.

Share this post


Link to post
Share on other sites

Posted (edited)

here is an example from the forum:

#include <GuiConstants.au3>

    HotKeySet("^", "HotkeysEvent")
    HotKeySet("!", "HotkeysEvent")
    HotKeySet("+", "HotkeysEvent")

Opt("GuiOnEventMode", 1)


$Gui = GuiCreate("Test")
GUISetOnEvent(-3, "Quit")

$Input = GUICtrlCreateInput("", 20, 40, 300, 20, $ES_READONLY)
GUICtrlSetBkColor(-1, 0xFFFFFF)

GUISetState()

AdlibEnable("CheckKeyPress", 150)

While 1
    Sleep(10)
WEnd

Func HotkeysEvent()
    $InputContent = GUICtrlRead($Input)
    $InputNum = StringRegExpReplace($InputContent, '(?i)(.*)\+\s', '')
    $HotkeyData = StringRegExpReplace($InputContent, '(?i)[0-9]', '')
    $NumData = StringRegExpReplace(@HotKeyPressed, '\^|!|\+', '')
    
    If $InputNum = "" Then
        GUICtrlSetData($Input, $InputContent & $NumData)
    ElseIf StringLen($InputNum) Then
        GUICtrlSetData($Input, $HotkeyData & $NumData)
    EndIf
EndFunc

Func CheckKeyPress()
    $LastKeyPress = _KeyIsPressed()
    If StringRegExp($LastKeyPress[0], "(?i)\{Ctrl\}|\{Shift\}|\{Alt\}") Then
        If $LastKeyPress[0] = "{Alt}" Then
            GUICtrlSetData($Input, "Alt + ")
            MouseClick("Left")
        Else
            GUICtrlSetData($Input, StringRegExpReplace($LastKeyPress[0], '\{|\}', '') & " + ")
        EndIf
        
        While 1
            $CheckKeyPress = _KeyIsPressed()
            If $CheckKeyPress[0] <> $LastKeyPress[0] Then ExitLoop
            Sleep(10)
        WEnd
        
        $InputContent = GUICtrlRead($Input)
        $InputNum = StringRegExpReplace($InputContent, '(?i)(.*)\+\s', '')
        
        If $CheckKeyPress[0] <> -1 And StringIsDigit($CheckKeyPress[0]) And _
            Not StringIsDigit($InputContent) And $InputNum = "" Then
            GUICtrlSetData($Input, $InputContent & $CheckKeyPress[0])
        ElseIf StringRegExpReplace($InputContent, '(?i)(.*)\+\s', '') = '' Then
            GUICtrlSetData($Input, "")
        EndIf
    EndIf
EndFunc

Func _KeyIsPressed()
    Local $RetArr[2] = [-1, 0]
    Local $KeyBoardLayoutArr = StringSplit("{LMouse}|{RMouse}|{}|(MMouse}|{}|{}|{}|{BACKSPACE}|{TAB}|{}|{}|{}|{ENTER}|{}|{}|{SHIFT}|{CTRL}|{ALT}|{PAUSE}|{CAPSLOCK}|{}|{}|{}|{}|{}|{}|{ESC}|{}|{}|{}|{]|{SPACE}|{PGUP}|{PGDN}|{END}|{HOME}|{LEFT}|{UP}|{RIGHT}|{DOWN}|{SELECT}|{PRINTSCREEN}|{}|{PRINTSCREEN}|{INSERT}|{DEL}|{}|0|1|2|3|4|5|6|7|8|9|{}|{}|{}|{}|{}|{}|{}|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|{LWIN}|{RWIN}|{APPSKEY}|{}|{SLEEP}|{numpad0}|{numpad1}|{numpad2}|{numpad3}|{numpad4}|{numpad5}|{numpad6}|{numpad7}|{numpad8}|{numpad9}|{NUMPADMULT}|{NUMPADADD}|{}|{NUMPADSUB}|{NUMPADDOT}|{NUMPADDIV}|{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}|{F13}|{F14}|{F15}|{F16}|{F17}|{F18}|{F19}|{F20}|{F21}|{F22}|{F23}|{F24}|{}|{}|{}|{}|{}|{}|{}|{}|{NUMLOCK}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{SHIFT}|{SHIFT}|{CTRL}|{CTRL}|{ALT}|{ALT}|{BROWSER_BACK}|{BROWSER_FORWARD}|{BROWSER_REFRESH}|{BROWSER_STOP}|{BROWSER_SEARCH}|{BROWSER_FAVORITES}|{BROWSER_HOME}|{VOLUME_MUTE}|{VOLUME_DOWN}|{VOLUME_UP}|{MEDIA_NEXT}|{MEDIA_PREV}|{MEDIA_STOP}|{MEDIA_PLAY_PAUSE}|{LAUNCH_MAIL}|{LAUNCH_MEDIA}|{LAUNCH_APP1}|{LAUNCH_APP2}|{}|{}|;|{+}|,|{-}|.|/|`|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|[|\|]|'", "|")
    Local $a_R
    For $i = 0 To 165
        $a_R = DllCall("user32.dll", "int", "GetAsyncKeyState", "int", '0x' & Hex($i,2))
        If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then
            $RetArr[0] = $KeyBoardLayoutArr[$i]
            $RetArr[1] = Hex($i, 2)
            ExitLoop
        EndIf
    Next
    Return $RetArr
EndFunc

Func Quit()
    Exit
EndFunc

this script does not work on a german keyboard because + ^ cannot be hotkeyed:

HotKeySet("^", "HotkeysEvent"); does not work

HotKeySet("!", "HotkeysEvent")

HotKeySet("+", "HotkeysEvent"); does not work

j.

Edited by jennico

Share this post


Link to post
Share on other sites

Posted

Why can't you just choose a different hotkey then. Easy solution if you ask me.

Share this post


Link to post
Share on other sites

Posted

Why can't you just choose a different hotkey then. Easy solution if you ask me.

Might want to re-read the the 1st post in this thread.

Share this post


Link to post
Share on other sites

Posted

Oops, sorry, never mind then.

Share this post


Link to post
Share on other sites

Posted

I still don't see the problem. The modifier + ! has no special meaning it's just a signal to Autoit to press shift or alt. How would changing the modifier "signal" affect anything?

Share this post


Link to post
Share on other sites

Posted (edited)

i don't know if you read my first postings....

i try it again: there are many non- u.s. keyboards (nearly all, see above) that have the modifiers + ! + # on the primary keyboard pane, while on the u.s. keyboard they all are reached in shift level.

try this page for the keyboard layouts.

the consequence is, that on those keyboards it is not possible to send or hotkey the modifier chars themselves. you cannot send "!" nor "+" nor "#" nor "^".

if a u.s. user wants to hotkey the + sign, he does: hotkeyset("+="). the plus is for shifting and the = is the basic key.

a german user cannot do this, because "+" is an unshifted basic key. he cannot do: hotkeyset( "+") because "+" is reserved as a modifier. the same with ! # ^. the same with send(). a german user cannot send("+") or "#" to an application because these are modifier keys.

i see that this does not matter to u.s. users, but for others it is very annoying, because there is no workaround either.

i think this is a not necessary restriction in autoit. it could ( and for internationality reasons should ) be (easily) modified by using different modifier keys.

for me, right now i have a problem with that because i have a german keyboard and there is no way to send a "+", but i have to do it to go on in my script. with autoit this simply cannot be realized. i want to attract your attention to this problem and would like to help solving it.

i make an example: just imagine, the modifier for shift would not be "+", but "-" (minus). in this case a u.s. user would never be able to hotkey or send "-" because there is no way to say: hotkey("-","_dothis") or send("-") because "-" is a modifier and cannot be used alone.

j.

Edited by jennico

Share this post


Link to post
Share on other sites

Posted

Sorry. Re-read and still don't see a problem. I could change it to do S for shift instead of + but that makes no difference to the internal workings.

I don't understand why you say you can't send a + with a german keyboard. Send("{+}") should work fine. If it doesn't then it's a bug. JP tests the keyboard sending on non-US keyboards and the code is set up to work out the correct keystrokes for all keyboards so I'm baffled as to what the problem is.

Edit: I just changed my keyboard and locale to German (Germany) and Send("{+}") seems to send the character + ok.

Share this post


Link to post
Share on other sites

Posted (edited)

I think jennico is mixing up his words (If I understand correctly). What he's saying is he can't Hotkey the +. On his keyboard, the + is a standalone character (not achieved through Shift+Equal like on our English keyboards). Because of this, he cannot set it to a hotkey. For us, we would use HotKeySet('+='), for him that won't work because he can't use Shift+Equal to send the + character, and obviously he can't use HotKeySet('+').

I think a better solution (as opposed to changing the modifier characters and breaking 10 billion scripts [i suppose we could add a new Opt() parameter :P]) is that HotKeySet('{+}') could be made to accomplish his need. I don't know if that's possible though.

*Edit: Okay, maybe he did think it was an issue with Send(), and he's wrong on that count. But the HotKeySet issue does still stand.

Edited by Saunders

Share this post


Link to post
Share on other sites

Posted

I think jennico is mixing up his words (If I understand correctly). What he's saying is he can't Hotkey the +. On his keyboard, the + is a standalone character (not achieved through Shift+Equal like on our English keyboards). Because of this, he cannot set it to a hotkey. For us, we would use HotKeySet('+='), for him that won't work because he can't use Shift+Equal to send the + character, and obviously he can't use HotKeySet('+').

I think a better solution (as opposed to changing the modifier characters and breaking 10 billion scripts [i suppose we could add a new Opt() parameter :P ]) is that HotKeySet('{+}') could be made to accomplish his need. I don't know if that's possible though.

*Edit: Okay, maybe he did think it was an issue with Send(), and he's wrong on that count. But the HotKeySet issue does still stand.

So the bug is that Send("{+}") works but HotKeySet("{+}") doesn't? That makes more sense as I'm not sure if the hotkey code checks for {} combinations.

Share this post


Link to post
Share on other sites

Posted

So the bug is that Send("{+}") works but HotKeySet("{+}") doesn't? That makes more sense as I'm not sure if the hotkey code checks for {} combinations.

It doesn't:

HotKeySet("{a}", "Function")
HotKeySet("^+!x", "Function")   ; Backup when the above doesn't work
While True
    Sleep(50)
WEnd

Func Function()
    MsgBox(4096, "", "Called: " & @HotKeyPressed)
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Posted (edited)

hi valik,

sorry, your example does not work on my german kb. nothing happens.

QUOTE (Jon @ Dec 21 2007, 09:52 AM)

So the bug is that Send("{+}") works but HotKeySet("{+}") doesn't? That makes more sense as I'm not sure if the hotkey code checks for {} combinations.

It doesn't:

CODEHotKeySet("{a}", "Function")

HotKeySet("^+!x", "Function") ; Backup when the above doesn't work

While True

Sleep(50)

WEnd

Func Function()

MsgBox(4096, "", "Called: " & @HotKeyPressed)

Exit

EndFunc

i made some tests:

Send("{+}") => works !!, sorry, this is okay

HotKeySet("{+}","_fgh") => does not work

HotKeySet("+","_fgh") => does not work

HotKeySet("{a}","_fgh") => does not work (for me the {} do not work for any char)

same results for # and ^

summary: on non-us keyboards send(" {modifier}" ) works

hotkeyset(" {modifier}","function" ) does not work

hotkeyset(" modifier","function" ) does not work

hotkeyset(" {any char}","function" ) does not work

i withdraw: for "send" no bug, but still bug for "hotkeyset".

saunders and jon are completely right and understood my problem. thanx.

maybe the problem could be solved if the {} worked for hotkeyset in the same way like they work for send.

j.

Edited by jennico

Share this post


Link to post
Share on other sites

Posted

My example wasn't supposed to work. That was the point. Well, the Ctrl+Shift+Alt+x hotkey was supposed to work. But the {a} bit wasn't.

Share this post


Link to post
Share on other sites

Posted (edited)

valik,

your example modified:

HotKeySet("{a}", "Function")
HotKeySet("^+!x", "Function")   ; Backup when the above doesn't work
HotKeySet("a", "Function")
While True
    Sleep(50)
WEnd

Func Function()
    MsgBox(4096, "", "Called: " & @HotKeyPressed)
    Exit
EndFunc

the only reaction comes on "a" pressed !

j.

edit: oky, the postings crossed !

edit2: okay, "^+!x" works, too !

Edited by jennico

Share this post


Link to post
Share on other sites

Posted

Right. My example was to show Jon that HotKeySet() did not accept {} notation. The second hotkey was there because I knew the first wouldn't work.

Share this post


Link to post
Share on other sites
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.