Jump to content

Problem with ControlSend


kaiks
 Share

Recommended Posts

Hi, I'm new to this forums

I've problem with ControlSend function, here's the code

#include <file.au3>

$window="whatever"
$path="c:\path\to\some\file.txt"
AutoItSetOption("WinTitleMatchMode", 4)
$handle = WinGetHandle($window, "")
$line=_FileCountLines($path)
$file=FileOpen($path,0)

;==============================================================================
While 1
Sleep(100)
While FileReadLine ($file,$line) = ""
Sleep(100)
WEnd
Sleep(100)
ControlSend($handle,"","",FileReadLine($file,$line),0)
;MsgBox(0,"bla",FileReadLine($file,$line)) <-- to test if problem was in fileread, it worked fine tho
Sleep(300)
ControlSend($handle,"","","{Enter}")
Sleep(100)
$line=$line+1
WEnd

That program is supposed to find a new line in some file and 'paste' it to other window...

When the line is for example 'blablablablabla' it works good...

But when the line is 'blaBLAbla!!!!bla' it sends 'blablabla1111bla'

Using Send function works good too, but that's not what I want

Any help?

Link to comment
Share on other sites

Hi,

have you tried to set the flag to 1 ?

ControlSend ( "title", "text", controlID, "string" [, flag] )

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

HI,

this works for me (Notepad.exe) Title in German Editor - Unbenannt.

#include <file.au3>

$window = "Unbenannt - Editor"
$path = "Controlsend.txt"
AutoItSetOption("WinTitleMatchMode", 4)
$handle = WinGetHandle($window, "")
$line = _FileCountLines($path)
$file = FileOpen($path, 0)

;==============================================================================
While 1
    Sleep(100)
    While FileReadLine($file, $line) = ""
        Sleep(100)
    WEnd
    Sleep(100)
    Local $text = FileReadLine($file, $line)
    ControlSend($window, "", 15, $text, 1)
    ;MsgBox(0,"bla",FileReadLine($file,$line)) ;<-- to test if problem was in fileread, it worked fine tho
    Sleep(300)
    ControlSend($window, "", 15, "{Enter}")
    Sleep(100)
    $line = $line + 1
WEnd

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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