Jump to content

Recommended Posts

Posted (edited)

This question has come up in various ways before, but I can't find a solution, and I'm not sure there is one.

I'm trying to use ControlSend to enter a file path in a Windows File/Save dialog box. The plain Send command works perfectly to enter the file path, but I want to hide the application window that I'm sending the file path to, and I think that only ControlSend will work in that situation - as well as being generally more reliable.

What happens is that a path like F:\path\to\myfile gets entered as something like F;\path|tO\myfiLe - with some of the characters that I want to paste replaced with the opposite-case character on the keyboard. For example, the colon becomes a semi-colon and the backslash becomes a vertical. (This is effectively the same thing that was described in an earlier post about Czech letters appearing instead of the intended characters.)

I've tried turning on the raw-characters option; that doesn't help. I've tried putting the path in the Clipboard and then, in ControlSend, using ClipGet() instead of the variable that contains the string. The clipboard method seems to improve things a bit, but I still end up with a semi-colon and not a colon after the drive letter.

Is there any reliable way to get around this problem?

I'm running Windows 10 and trying to enter text in the File/Save box in Softmaker's free TextMaker word-processor. Thanks for any help.

 

Edited by emendelson
Clarification.
Posted (edited)

I have seen that before, it seems that if you are using keyboard or mouse while script is running, ControlSend can get mixed up.

The solution that was suggested is to use my UDF, before and after the ControlSend to block all input before and re-enable input after.

and @BigDaddyO also made a secure control send...

Edited by Nine
Posted

Thank you for this - but, but unfortunately, your UDF and @BiggDaddyO's _ControlSendSecure don't seem to solve the problem. In each case, I get this:

AnLgWTU.png

 

I know I'm not using the mouse or keyboard while the script runs. I wonder if there's something else going on that's getting in the way?

Posted (edited)

I think the only characters that get converted are the colon (converted to a semi-colon) and the backslash (converted to a vertical). But as you see from the image, this only happens randomly. Sometimes the colon doesn't get converted; only one or two backslashes get converted. Might it be possible to parse the file string and replace the colon and backslashes with specific ASCII characters? (If so, I don't know the best way to do that.)

I can live with changes to the case of the ASCII characters, though of course I would prefer not to. Maybe the best thing would be to convert the whole string into a series of Chr(##) codes?

Edited by emendelson
Posted

If this is just a Save as window, you could use ControlSetText instead, right? I don't think that actually simulates typing with the keyboard

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted
4 minutes ago, seadoggie01 said:

If this is just a Save as window, you could use ControlSetText instead, right? I don't think that actually simulates typing with the keyboard

Brilliant! This is a pure case of user-ignorance on my part. That works perfectly, and I should have realized that it would work...

Posted

You still probably want to look into what is causing those random capitalizations, but at least you can move past this for now :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted
17 hours ago, emendelson said:

I figured out the answer...

Which is?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
51 minutes ago, jchd said:

Which is?

I should have said I partly figured out a solution - I've modified some of Stilgar's UDF simply by replacing the Open and SaveAs commands by equivalents from the TextMaker language, but I can't get the SaveAs to save consistently in the correct format and I can't get it actually to save the file instead of opening the File/Save dialog with the filename and (sometimes) the correct format. I'll continue to work on this and post any solution that seems to work.

Posted (edited)

I figured out the question I should ask to solve this problem, which is how to get TextMaker to save changes without prompting. I've asked the question as an issue on Stilgar's Github page.

Edited by emendelson

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...