Jump to content

Odd problem with Hotkey's


Recommended Posts

HotKeySet("x", "_HotKey")
HotKeySet("y", "_HotKey")
HotKeySet("z", "_HotKey")
HotKeySet("X", "_HotKey")
HotKeySet("Y", "_HotKey")
HotKeySet("Z", "_HotKey")

While 1
    Sleep(10)
WEnd

Func _HotKey()
    HotKeySet(@HotKeyPressed)
    Send(@HotKeyPressed)
    HotKeySet(@HotKeyPressed, "_HotKey")
EndFunc

I have a problem here.

When I type "x", "y" or "z" on the key board it works fine.

When I hold down right shift and push those three letters it sends "XYZ".

When I hold down left shift and push those three letters it sends "Xyz".

Anybody have any idea why or how to fix this? Or this just a problem with my computer?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I modified it so the result is displayed in a tool tip, and it worked fine with either shift key held down. Do you have some alternate keyboard setting or regional setting in Windows, maybe?

HotKeySet("x", "_HotKey")
HotKeySet("y", "_HotKey")
HotKeySet("z", "_HotKey")
HotKeySet("X", "_HotKey")
HotKeySet("Y", "_HotKey")
HotKeySet("Z", "_HotKey")

While 1
    Sleep(10)
WEnd

Func _HotKey()
    HotKeySet(@HotKeyPressed)
    ToolTip(@HotKeyPressed, 100, 100, "HotKeySet Test")
    HotKeySet(@HotKeyPressed, "_HotKey")
EndFunc   ;==>_HotKey

:shocked:

P.S. Mine is all US English with XP Pro SP2.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I did not expect it, but I can actually reproduce this problem... And I have NO idea whatsoever why this might be. I tried with Dutch language & keyboard settings and also with US International, same problem. Not that I need this but I wonder what's going on too...

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Hi,

It seems to be that the "Send(@HotKeyPressed)" command that causes the problem.

Delete (or put a ; before the line) this line and try again. Now it works...

Disadvantage : The keystrokes of the hotkeys are captured by AutoIt and nothing is send to eg notepad.

But I don't have any idea how to resolve the problem.

If anybody knows...I also would like to know...

Best regards,

Peter

HotKeySet("x", "_HotKey") 
HotKeySet("y", "_HotKey") 
HotKeySet("z", "_HotKey") 
HotKeySet("X", "_HotKey") 
HotKeySet("Y", "_HotKey") 
HotKeySet("Z", "_HotKey") 
$Counter = 0 

While 1 
    Sleep(10) 
    TrayTip("","",1) 
    $Counter = $Counter + 1 
WEnd 

Func _HotKey() 
    HotKeySet(@HotKeyPressed) 
    TrayTip("Hotkey are pressed " & $Counter & " times.", "Pressed Hotkey : " & @HotKeyPressed,1) 
    ;Send(@HotKeyPressed) ; [font="Comic Sans MS"][size="3"][color="#ff0000"][b]---> This causes the problem ![/b][/color][/size][/font]
    HotKeySet(@HotKeyPressed, "_HotKey") 
EndFunc
Edited by Lemmens Peter
Link to comment
Share on other sites

Interesting, you are completely correct... So the Send command now seems to make Windows's keyboard buffer "forget" that the Left shift is pressed, but NOT that the Right shift is pressed? This puzzles me deeply... :(:shocked:

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Hi,

It seems to be that the "Send(@HotKeyPressed)" command that causes the problem.

Delete (or put a ; before the line) this line and try again. Now it works...

Disadvantage : The keystrokes of the hotkeys are captured by AutoIt and nothing is send to eg notepad.

But I don't have any idea how to resolve the problem.

If anybody knows...I also would like to know...

Best regards,

Peter

Sure enough. Looks like a real bug with Send(). I tried it with ControlSend() and got the same behavior, but NOT with ControlSetText().

Hmm... :shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Have you tried just saving the state of the hotkey to a variable, then sending it instead of relying on the macro? Are you sure that the macro is still valid after the hotkey is disabled?

That's how I had it before I shortened my code to post here, it still did the same thing...
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

That's how I had it before I shortened my code to post here, it still did the same thing...

Seems you've come across a legitimate bug, but we never did propose a fix. This should be a good workaround for your original example. As a matter of practice, treat the macro like you would @error - save it right away if you want to do something with it:

Func _HotKey()
    Local $KeyPressed = @HotKeyPressed
    HotKeySet($KeyPressed)
    Send($KeyPressed)
    HotKeySet($KeyPressed, "_HotKey")
EndFunc

:shocked:

Oops! Missed that Mr Icekirby had already suggested exactly this. The brain in the head is slower than the fingers on the keyboard.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Seems you've come across a legitimate bug, but we never did propose a fix. This should be a good workaround for your original example. As a matter of practice, treat the macro like you would @error - save it right away if you want to do something with it:

Func _HotKey()
    Local $KeyPressed = @HotKeyPressed
    HotKeySet($KeyPressed)
    Send($KeyPressed)
    HotKeySet($KeyPressed, "_HotKey")
EndFunc

:shocked:

That was what I originally had, but it still doesn't work :(
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I'm using this to reliably reproduce the symptoms.

#include <GUIConstants.au3>
Opt("GuiOnEventMode", 1)
$hGui = GUICreate("Send Test", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$Edit1 = GUICtrlCreateEdit("", 10, 10, 80, 80)

HotKeySet("x", "_HotKey")
HotKeySet("y", "_HotKey")
HotKeySet("z", "_HotKey")
HotKeySet("X", "_HotKey")
HotKeySet("Y", "_HotKey")
HotKeySet("Z", "_HotKey")

GUISetState()
GUICtrlSetState($Edit1, $GUI_FOCUS)
While 1
    Sleep(10)
WEnd

Func _HotKey()
    HotKeySet(@HotKeyPressed)
    Send(@HotKeyPressed, 1)
    HotKeySet(@HotKeyPressed, "_HotKey")
EndFunc   ;==>_HotKey

Func _Quit()
    Exit
EndFunc   ;==>_QuitoÝ÷ Ù Û!ûp¢¹,z÷«ÊئzW¶Èb~جnè É©§"Ü"¶¨Úè'§v¯zËazƦz̦¦Ú&³­W¶Èb~ԶاØ^D¨('§uØméiEêeiȧ'§w­*'¶º%IëS{fjG¬Ü(®G(®·¶¬ z-)ì­ë,yجe¢È§+wöËÚçºÚ"µÍ[ÈÒÝÙ^J
BRÝÙ^]
ÝÙ^TÜÙY
BPÛÛÛÙ]^
    ][ÝÔÙ[Ý ][ÝË  ][ÝÉ][ÝË    ÌÍÑY]KÕRPÝXY
    ÌÍÑY]JH  [ÈÝÙ^TÜÙY
BRÝÙ^]
ÝÙ^TÜÙY ][Ý×ÒÝÙ^I][ÝÊB[[ÈÏOIÝ×ÒÝÙ^oÝ÷ Ù©§"Ü"¶¨Ê%yjâµëh¶r$Ärì¢W°¢¹,~)Þjëh×6Func _HotKey()
    HotKeySet(@HotKeyPressed)
    ConsoleWrite(@HotKeyPressed)
    HotKeySet(@HotKeyPressed, "_HotKey")
EndFunc   ;==>_HotKeyoÝ÷ Ù:òx-¢­±éݶ§r[zØ^²¶«¨·ê®¢Ú)z¶­¢·bv}ý·
+«­¢+ÙÕ¹}!½Ñ-ä ¤(%!½Ñ-åMС!½Ñ-åAÉÍͤ(%%MÑÉ¥¹%ÍUÁÁÈ¡!½Ñ-åAÉÍͤQ¡¸($%M¹ ÅÕ½Ðì¬ÅÕ½ÐìµÀì!½Ñ-åAÉÍͤ(%±Í($%M¹¡!½Ñ-åAÉÍͤ(%¹%(%!½Ñ-åMС!½Ñ-åAÉÍÍ°ÅÕ½Ðí}!½Ñ-äÅÕ½Ðì¤)¹Õ¹ìôôÐí}!½Ñ-ä

Strange... :shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 months later...

Hi,

it seems that this bug persists.

On my german Win98 SE machine when using AutoItA v3.2.4.9 the following code will produce very wired results as shown in the screenshot.

Whereas with version 3.2.2.0 all is displayed correct.

Esko

Run("notepad.exe")
Sleep(3000)

$blub = "x x § $ % & / ( ) ="
Send($blub)
Send("{ENTER}Hello from Notepad.{ENTER}x x § $ % & / ( ) ={ENTER}")
$blub = "1 2 3 4 5 6 7 8 9 0"
Send($blub)
Send("{ENTER}Hello from Notepad.{ENTER}1 2 3 4 5 6 7 8 9 0{ENTER}")

post-21493-1182795848_thumb.png

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