AndrewSchultz Posted March 2, 2020 Share Posted March 2, 2020 (edited) 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 March 2, 2020 by AndrewSchultz added example that stop at x=3 stops x=4/5, ControlSend/Sleep tries Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2020 Moderators Share Posted March 2, 2020 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BigDaddyO Posted March 2, 2020 Share Posted March 2, 2020 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now