Jump to content

Send randomly stops working when SendKeyDelay is low


Recommended Posts

I have a program that sends keystrokes to a window like so:

Opt("SendKeyDelay", 10)

WinActivate("MyWindow")

WinWaitActive("MyWindow")

for $x = 1 to 5
  for $y = 1 to 99
    Send(StringFormat("%d ", $x))
    ; Send(_StringRepeat(StringFormat("%d ", $x), 99) shows similar behavior
  Next
Next

I want to send out "1 1 1 1 1 " and "2 2 2 2 2 ", etc.

Now I can see that it starts okay, but often it will stop, and when one send command bombs, nothing further happens. For instance, if it stops at x=3, then "4 4 4 4 ..." and "5 5 5 5 ..." are not sent.

I've also tried using StringRepeat(..., 99) but am still seeing the same behavior.

Now I have another command about hitting an F11 key, and when that happens, the cache seems to reset.

Is there any way I can flush the cache after each Send?

And if not, are there any metrics on SendKeyDelay vs. probability of failure? I'm willing to accept some failures in return for getting enough data I need quickly.

I've tried replacing Send() with ControlSend() and also putting in a buffer such as sleep(100) but the hangup still seems to happen at the same rate. Any suggestions?

Thanks!

Edited by AndrewSchultz
added example that stop at x=3 stops x=4/5, ControlSend/Sleep tries
Link to comment
Share on other sites

  • Moderators

AndrewSchultz,

Welcome to the AutoIt forums.

I cannot get the code to fail when using a simple editor - what sort of window is it that you are using when "Send"ing?

And I doubt SendKeyDelay is causing you any problems as you are using double the default value!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

you are only sending 1 digit at a time, so the SendKeyDelay isn't actually being used at all.  If you were to build a string of numbers and send them all at once, THEN SendKeyDelay would be used between characters.

So, in your example, you would just need to add a sleep(10) after each Send() and not use SendKeyDelay.

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