Modify

Opened 16 years ago

Closed 16 years ago

#112 closed Bug (Wont Fix)

Send() does not check key release

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: 3.2.10.0 Severity:
Keywords: Cc:

Description

That's good. If I release the Ctrl key while send is sending a string then it always results in the Ctrl being down.
I think the reason is that when Send starts it has to check if the Ctrl key is pressed, and other keys. So it can send the correct characters it has to first send CTRLUP. When it's finished it sends CTRLDOWN if it was originally down, but what it should do is check if it's still pressed.
This mod to your example works everytime I've tried it wheras before the bug showed every time, but there is a delay while it waits for the Ctrl key to be released.

Demo code :
#include <GUIConstants.au3>
#include <misc.au3>

Const $SCREEN_WAIT = 150

Func WriteMessage($message)

While _IsPressed(11)

WEnd

Send($message)

EndFunc

Func WriteStuff()

WriteMessage("`test1 test1")
Sleep(1000)

EndFunc

Func ExitTool()

Exit

EndFunc

Func ConfigureHotKeys()

HotKeySet("h", "WriteStuff")
HotKeySet("{F11}", "ExitTool")

EndFunc

Func Main()

Opt("GUIOnEventMode", 1)
Opt("SendKeyDelay", 100)
Opt("MouseClickDelay", 0)
AutoItSetOption("WinTitleMatchMode", 2)
AutoItSetOption("PixelCoordMode", 2)
ConfigureHotKeys()
While 1

Sleep(1000)

WEnd

EndFunc

Main()

Attachments (0)

Change History (4)

comment:1 Changed 16 years ago by Valik

What are you actually posting? Okay, so you have a work-around to the "using Send() in a HotKeySet() callback" but why are you posting it here? You mention something about an example but I don't see any example in the documentation (at least not in the obvious places) that even remotely resembles your code or even the concept being described.

So what is it you want from us?

comment:2 follow-up: Changed 16 years ago by Jpm

  • Resolution set to nobug
  • Status changed from new to closed

Only the capslock key is managed whend Send() is used so if a Ctrl or Alt key is down the pointed window will received the combined keystroke.
Jon will confirm that due to compatibility in game script he will not extend this behavior ;)

comment:3 in reply to: ↑ 2 Changed 16 years ago by martin

  • Resolution nobug deleted
  • Status changed from closed to reopened

Replying to Jpm:

Only the capslock key is managed whend Send() is used so if a Ctrl or Alt key is down the pointed window will received the combined keystroke.
Jon will confirm that due to compatibility in game script he will not extend this behavior ;)

If the Ctrl key is pressed then it may be expected that the combination will result but that is not what happens and it is not the 'bug' being reported. The script is not a work around but a demonstration of how to add a delay waiting for Ctrl to be released so that the 'bug' is avoided.
In my experience if Send operates when someone is holding down the Ctrl key then the result is as if the Ctrl key were not held down. The bug is that Send sometimes incorrectly adjust for the Ctrl key being down resulting in the key being latched down when it should not be.

The report is actually a copy of a replay I gave to someone having this problem and includes my guess as to why it happens. I did not make the report but to me it seems like a bug, or at the very least, very undesirable behavior.

How to see the problem
1) Comment out the 2 lines in the function WriteMessage
While _IsPressed(11)

WEnd

2) run the script.
3) Open Notepad
4) type anything and then press Ctrl and H but keep the Ctrl key pressed down until you see charcaters being typed by Send then immediately release Ctrl
5) end the script by pressing F11
6) in notepad press the letter g
When I try this it behaves as Ctrl G and my in my view it's a bug.

comment:4 Changed 16 years ago by Valik

  • Resolution set to wontfix
  • Status changed from reopened to closed

It is not unexpected that if you use two sources of input asynchronously, you will confuse the internal keyboard state. When you choose to use Send(), you open yourself up to that possibility. I'm closing this as wont fix.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.