Jump to content

Incorrect String Being Sent via ControlSend()


PeteS
 Share

Recommended Posts

The following code gives me inconsistent results. Sometimes the string is sent correctly, but sometimes it is sent with minor variations. The latest one was supposed to send the following string:

"C:\_Work1\Dispense_Before.txt", but it sent this instead:

"C:|_Work1\Dispense_Before.txt". Close, but not quite, although, the same string is displayed in a msgbox at the end, and it was displayed correctly. In this case, it is sending the string to an Edit box in a Save As dialog, but I got the same results when sending strings to TMemo controls, too.

$saveAsName = $workLoc & $arTables[$tableIndx] & $suffix

$doesItExist = FileExists($saveAsName)

ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", $saveAsName)

ControlClick("Save As", "", "[CLASS:Button; INSTANCE:2]")

;if the file had already existed, then we will need to Confirm its replacement

if $doesItExist Then

ControlClick("Save As", "", "[CLASS:Button; INSTANCE:1]")

EndIf

Sleep(3000)

MsgBox(0, "File Saved", "File Saved as: " & $saveAsName)

Maybe I should mention that before this, the script is copying very large amounts of text to and from the clipboard. I have put what seems to be sufficient sleep() delays to allow the copy and pasting to complete. I have tested with extremely long delays, with the same inconsistent results.

Thanks,

Pete S

Link to comment
Share on other sites

  • Developers

This is mentioned in the helpfile and many times on the forum: Do you have CapsLock on?

As mention in the Send help the keyboard that send different chars when in CAPS LOCK and using the Shift Key cannot be simulated. An example is the Czech Keyboard. A good workaround is to use the ControlSetText.

Try using ControlSetText() for the control you want to update.

Jos :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

ive also had somthing close to this where it would capitalize random leters that wherent spose to be caped but not all where caped and not all where lower case... and delay didnt help either, but i used it on 2 or 3 different computers and 1 worked fine the other gave me this problem and the 3rd i dont remebere

Link to comment
Share on other sites

Using ControlSetText() worked beautifully for me. I do not have the CAPS lock on, am not using Shift, and I am not Czech or using a Czech keyboard, this is strange behavior.

Bam,

I have also seen the random capitalization in some of the strings on a couple executions of this script. All seems well with the ControlSetText() function.

Thanks, Jos!

Pete S

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