Jump to content

Send()


Recommended Posts

Whenever I run to following script it adds an extract line break, why? How do I fix it?

Opt("SendKeyDelay", 25)

WinWaitActive("Untitled - Notepad")
Sleep(500)

$hFile = FileOpen(@ScriptDir & "\a_4.txt")
$Contents = FileRead($hFile)
FileClose($hFile)

Send($Contents)

a_4.txt

#include <windows.h>
#include <string>
#include <direct.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;
Link to comment
Share on other sites

There is an extra breakline at the end of the file? I count 7 lines, six that have text.

Try FileReadLine().

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

I'll try line by line, but what I run this in notepad it's.

#include <windows.h>

#include <string>

#include <direct.h>

Etc...

That is strange. Not sure why that is.

This should work though.

#include <file.au3>
Opt("SendKeyDelay", 25)

WinWaitActive("Untitled - Notepad")
Sleep(500)

$hFile = FileOpen(@ScriptDir & "\a_4.txt", 0)
$lines = _FileCountLines(@ScriptDir & "\a_4.txt")

For $i = 1 To $lines
$Contents = FileReadLine($hFile, $i)
Send($Contents & @CR)
Next
FileClose($hFile)
Link to comment
Share on other sites

I'll try line by line, but what I run this in notepad it's.

#include <windows.h>

#include <string>

#include <direct.h>

Etc...

I see ..... Interesting

Just about to try with FileReadLine....

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

That is strange. Not sure why that is.

This should work though.

#include <file.au3>
Opt("SendKeyDelay", 25)

WinWaitActive("Untitled - Notepad")
Sleep(500)

$hFile = FileOpen(@ScriptDir & "\a_4.txt", 0)
$lines = _FileCountLines(@ScriptDir & "\a_4.txt")

For $i = 1 To $lines
$Contents = FileReadLine($hFile, $i)
Send($Contents & @CR)
Next
FileClose($hFile)

I would gess the line break would be @CRLF (Chr(13) & Chr(10)) so two line breaks are used. As FileReadLine strips them both you have to manually add them.

Change line 12 to Send($Contents & @CRLF) and you get the same result.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

I would gess the line break would be @CRLF (Chr(13) & Chr(10)) so two line breaks are used. As FileReadLine strips them both you have to manually add them.

Change line 12 to Send($Contents & @CRLF) and you get the same result.

*raises eyebrow*

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