Jump to content

Easy string problem


jezzzzy
 Share

Recommended Posts

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)

Link to comment
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.
Link to comment
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

Link to comment
Share on other sites

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 *

Link to comment
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)?
Link to comment
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 *

Link to comment
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

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 *

Link to comment
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 *

Link to comment
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]

Link to comment
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?
Link to comment
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.

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