Jump to content

ControlSend Inconsistent


 Share

Recommended Posts

We have a script that runs a program. There are a few spots in the program that open up a windows file save dialog which the script recognizes and does a controlsend to enter the file name and path for saving the file. This has worked great for over a 1 year. Now we are having some problems with the controlsend. At times it replaces characters in the string. For example:

the variable will contain "F:\Company Name\Date\File.ext". I will see the correct value in a console command before the controlsend. After the controlsend I will see the same value in the variable, but in the text box that the control send put the information in, I see "F;\Company\Date\File.ext". So it switches the : with a ;. Other times it switches the \ with |. The part that is driving me crazy is it only happens about 10% of the time.

I have tried setting sendkeydelay to 70. I have placed sleep's infront of the window opening but the problem keeps appearing.

WinWait("Save Form Image As", "")

If Not WinActive("Save Form Image As", "") Then WinActivate("Save Form Image As", "")

WinWaitActive("Save Form Image As", "")

AdlibDisable();

$CLVItem = ControlSend("Save Form Image As", "", "[CLASSNN:Edit1]", $fdcFileSavePath & $FileName)

sleep(1500)

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fdcFileSavePath = ' & $fdcFileSavePath & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Sleep(1000)

$ret = ControlClick("Save Form Image As", "", "&Save")

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : saveed file = ' & $fdcFileSavePath & $FileName & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

I have run out of ideas on what to try next.

Link to comment
Share on other sites

Have you tried ControlSetText?

The errors you report are as though sometimes the shift key is incorrectly operated. On a UK keyboard which I use, : is shift + ; and | is shift + \.

It might be worth checking that the shift key is released before the ControlSend is executed. It might even be worth trying to set all the characters to lower case but that's a shot in the dark and I have no experience to say that will have any effect.

If all else fails I suppose you could read what happened with ControlGetText and use ControlSetText untill it is correct.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...