Sign in to follow this  
Followers 0
jezzzzy

Easy string problem

21 posts in this topic

Anyone have any idea why the following produces a file name surrounded by single quotes in my dos window?

ControlSend(@systemDir & '\cmd.exe','','','put "' & $fileToPlot & '"' & '{ENTER}')

Screenshot of cmd window attached.

Share this post


Link to post
Share on other sites



Anyone have any idea why the following produces a file name surrounded by single quotes in my dos window?

ControlSend(@systemDir & '\cmd.exe','','','put "' & $fileToPlot & '"' & '{ENTER}')

Screenshot of cmd window attached.

Dows this work?:

ControlSend(@systemDir & '\cmd.exe','','','put ' & $fileToPlot & '' & '{ENTER}')

HF

Felix N. (tdlrali)

Share this post


Link to post
Share on other sites

Dows this work?:

ControlSend(@systemDir & '\cmd.exe','','','put ' & $fileToPlot & '' & '{ENTER}')

HF

Felix N. (tdlrali)

Not exactly. It works as long at the filename does not contain spaces. My problem is I need to surround the filename in double quotes. My ControlSend() is producing single quotes for some reason. I need double quotes -- singles don't work in a dos/ftp put command.

Share this post


Link to post
Share on other sites

Not exactly. It works as long at the filename does not contain spaces. My problem is I need to surround the filename in double quotes. My ControlSend() is producing single quotes for some reason. I need double quotes -- singles don't work in a dos/ftp put command.

Give this a try:
ControlSend(@systemDir & "\cmd.exe","","","put """ & $fileToPlot & """{ENTER}")

Endgame

Share this post


Link to post
Share on other sites

what is the line you actually want to see on the command line?


Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

what is the line you actually want to see on the command line?

The line highlighted in the attached image should read:

put "1 ,2.plt"

not

put '1 ,2.plt'

Share this post


Link to post
Share on other sites

Give this a try:

ControlSend(@systemDir & "\cmd.exe","","","put """ & $fileToPlot & """{ENTER}")

Endgame

Thanks. Tried the double - double quote method also. Result is attached. No dice. Still give me single quotes.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

how about

ControlSend(@systemDir & "\cmd.exe" & " put " & """" & $fileToPlot & """" & {ENTER})

Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

how about

ControlSend(@systemDir & "\cmd.exe" & " put " & """" & $fileToPlot & """" & {ENTER})

I think the {ENTER} needs to be in quotes.

Share this post


Link to post
Share on other sites

I think the {ENTER} needs to be in quotes.

ok, i was close lol


Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Anyone have any idea why the following produces a file name surrounded by single quotes in my dos window?

No idea, but this one works (tested). Important: WinActivate is necessary, otherwise the double quotes are not send! Reason: I don't know ....

$fileToPlot = "hello world.txt"
$doublequote = chr(132)
WinActivate(@systemDir & '\cmd.exe')
ControlSend(@systemDir & '\cmd.exe','','',"put {" & $doublequote & "}" &  $fileToPlot & "{" & $doublequote & "}{ENTER}")

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

No idea, but this one works (tested). Important: WinActivate is necessary, otherwise the double quotes are not send! Reason: I don't know ....

$fileToPlot = "hello world.txt"
$doublequote = chr(132)
WinActivate(@systemDir & '\cmd.exe')
ControlSend(@systemDir & '\cmd.exe','','',"put {" & $doublequote & "}" &  $fileToPlot & "{" & $doublequote & "}{ENTER}")

Cheers

Kurt

I'll try this - but isn't a double quote chr(34)?

Share this post


Link to post
Share on other sites

I'll try this - but isn't a double quote chr(34)?

Yes, it should be, but for some reason using chr(34) in ControlSend() results in put 2hello world.txt2. I still don't know why....

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Yes, it should be, but for some reason using chr(34) in ControlSend() results in put 2hello world.txt2. I still don't know why....

Cheers

Kurt

Chr(132) gives me commas.

put ,hello world.txt,

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Yes, it should be, but for some reason using chr(34) in ControlSend() results in put 2hello world.txt2. I still don't know why....

Cheers

Kurt

it's not AutoITs fault. The command windows interprets the sent characters in a different way than other controls.

This works with notepad as expected.

$fileToPlot = "hello world.txt"
$doublequote = Chr(34)
WinActivate('Untitled - Notepad')
ControlSend('Untitled - Notepad', '', 'Edit1', "put {" & $doublequote & "}" & $fileToPlot & "{" & $doublequote & "}{ENTER}")

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Chr(132) gives me commas.

put ,hello world.txt,

??? What's your system? I tested on Win2k and it works as described....

BTW: You should consider using the FTP UDFs made by w0uter: http://www.autoitscript.com/forum/index.php?showtopic=12473.

That's much better then using ControlSend().

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

ControlSend("cmd", "", "", Chr(34)) gives me a single quote on XP

Play with this code:

AutoItSetOption("WinTitleMatchMode", 2)
Run("cmd")
WinWaitActive("cmd")

For $i = 30 To 132
    WinActivate("cmd")
    WinWaitActive("cmd")
    Send("{BS 40}")
    Send("Chr " & $i & "...Send...>" & Chr($i))
    ControlSend("cmd", "", "", Chr($i))
    Send("<...ControlSend")
    
    MsgBox(0, "Chr(" & $i & ")", Chr($i), 2)
Next

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

ControlSend("cmd", "", "", Chr(34)) gives me a single quote on XP

Play with this code:

AutoItSetOption("WinTitleMatchMode", 2)
Run("cmd")
WinWaitActive("cmd")

For $i = 30 To 132
    WinActivate("cmd")
    WinWaitActive("cmd")
    Send("{BS 40}")
    Send("Chr " & $i & "...Send...>" & Chr($i))
    ControlSend("cmd", "", "", Chr($i))
    Send("<...ControlSend")
    
    MsgBox(0, "Chr(" & $i & ")", Chr($i), 2)
Next
Me also. Which is why it doesn't work. I need to find the Chr() that corresponds to a double quote in a ControlSend(). How do I find it?

Share this post


Link to post
Share on other sites

??? What's your system? I tested on Win2k and it works as described....

BTW: You should consider using the FTP UDFs made by w0uter: http://www.autoitscript.com/forum/index.php?showtopic=12473.

That's much better then using ControlSend().

Cheers

Kurt

Using W2k. Not sure why it's not working the way you have tested. Maybe it has to do with the send to the DOS window. I'll look into the FTP UDF now. I'll keep you posted.

Share this post


Link to post
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
Sign in to follow this  
Followers 0