Jump to content

Send file path not working when there's a "#" in the var


Recommended Posts

I have a script that changes the path to a file inside a program, the program itself is a pain in the @## I have no idea what language was coded with but the autoit windows info doesn't even recognize 90% of the gui.

Anyway I need to send the new path which is inside the local app folder, I'am using a variable to hold it. but the User folder has the "#" character in the name and for some reason autoit won't send it, it just stops right before the "#" and doesn't send the rest of the path either. it doesn't return any error it just stops sending, the rest of the script is still executed.

I'm using the Send() command to send the keys.

Here's what I have:

$dbPath = @UserProfileDir & '\AppData\Local\database\db.mdb'
Run("Notepad.exe")
WinWait("Untitled - Notepad")
WinActivate("Untitled - Notepad")
Send($dbPath)

Now in my case @UserProfileDir is called Tech #1 so what I'm expecting Send() to type is 

C:\Users\Tech #1\AppData\Local\database\db.mdb

But what I'm actually getting is just

C:\Users\Tech

notice there's the space after the "h", so it is stopping exactly before the "#"

Now you might say why I need to use a var instead of just sending the actual string path, well I don't want to do a separate script for all the computers and guess what, they all have the "#" in their user names, yes Tech #2, Tech #3, Tech #4, Front #1, Front #2, Shipping #1... and so on.

BTW on a side note, I noticed the autoit macros page shows the  @LocalAppDataDir  as a viable macro but it's not working for me, it return "unknown macro", I had to use @UserProfileDir and and the \AppData\Local, because the @AppDataDir takes me to Roaming anyway. 

While I was writing that last paragraph, I said to my self, yeah why not just copy and paste the script and compile as many as I need but use plain text instead of a variable, so I went back and did just

Run("Notepad.exe")
WinWait("Untitled - Notepad")
WinActivate("Untitled - Notepad")
Send("C:\Users\Tech #1\AppData\Local\database\db.mdb")

Guess what!!!, yeah you guessed it, it did the same thing, it stopped right before the "#".

I know most will be thinking, nah he's crazy why would that happen, go ahead and try for yourself, I'll wait... (because I tried in 3 different computers).

Ok so you are back, did it work for you? can you explain why it's not working for me, or it didn't work for you as well and you are as clueless as me?

And while I was writing all this my brain was working on the background and I just had an idea to work around it, I'll be right back...

$dbPath = @UserProfileDir & '\AppData\Local\DiGital WorkShop\POS Panic\PM229.mdb'
Run("Notepad.exe")
WinWait("Untitled - Notepad")
WinActivate("Untitled - Notepad")
ClipPut($dbPath)
Send("{CTRLDOWN}v{CTRLUP}")

Ok so this actually works for me and I can finally breath, but I'm still annoyed by the fact that autoit won't Send("#1") or Send("#2"), yes I actually tried just sending that and nothing, and I just realize what is doing, (this lecture will annoy most people lol), by sending #1, #2, #3 ans so on it is activating windows in the same order they are pinned in the taskbar, I had autoit first, then chrome, the my mail app, so every time I use Send("#1") activates autoit, which I didn't noticed at all because well I was using autoit, but then when I Send("#2") and it brought chrome to the front, then Send("#3") and activated my mail app (which btw was minimized).

What in the world is happening some please explain me this behavior and please tell me how would you workaround the issue.

Thanks.

 

Link to comment
Share on other sites

try send with a 1.   send($string , 1)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

nobody ever expects the helpfile to own them nearly as many times as AutoIt's awesome helpfile will totally own you. Eventually you just F1 out of habit, even when you know whats going on.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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

×
×
  • Create New...