Jump to content

Recommended Posts

Posted

is it possible to create a script that writes in a text file exactly the text from another text file

it has to point at the source text file address

the cursor focus has to be on an empty text file window

press a key to start writing letter by letter with the same formatting exactly

also it could have a writing speed value

both source and target text file should be 100% identical when finished

Posted (edited)

You could do that copying the file itself or copying the strings inside the file. Both are possible without any problem. 

 

You may check these function in the helpfile

FileCopy

DirCopy

FileRead

MouseMove

Mouseclick

WinActive

WinActivate

Send

ClipPut

ClipGet

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted (edited)
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Give it a try comon ;), then after we will help you. 

 

Type any of the function I gave you then you hit the F1 key when you have the cursor on it. And watch what happen. 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted

You truly need to make your "wantings" clearer.  Maybe it seems to you that it is obvious, but it is not for us.  If you want some help (and you will get I assure you), provide an example of the input and the expected output.

Posted (edited)
5 hours ago, vinnyMS said:

I want the script to type everything from the source text file to a new file window

What do you mean by "new file window"? That's not a thing. It sounds like you may be automating a game or something, where the keystrokes are defined in the input file and the chars are injected into the game one at a time. Is that what you are doing?

Or do you want the text from the source file to be typed into perhaps a Notepad window, to make it look as though someone was typing it out slowly?

Edited by pseakins
typo

Phil Seakins

Posted

i want the text from the source file to be typed into a notepad window

 

i want to record the screen while the autoit program types on a notepad window

Posted
5 hours ago, vinnyMS said:

i want the text from the source file to be typed into a notepad window

We are not supposed to write scripts for you, you are supposed to figure it out for yourself and then we help when you get stuck. But this will help you get started, It is taken in part from the Notepad automation tutorial in the Scite help.

Copy this example into your Scite editor and then save it, giving it a suitable name. Then just press F5. This example uses itself as the source file and copies it character by character into a Notepad window. Whether you save the file and/or run screen capture is up to you.

$iDelay = 10 ; number of milliseconds to pause between characters
MsgBox(0, "", "Click ok when ready")
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Sleep(5000) ; allow operator time to start the capturing process
$hFile = FileOpen(@ScriptDir & "\" & @ScriptName)
$x = FileReadLine($hFile)
While Not @error
  For $i = 1 To StringLen($x)
    Send(StringMid($x, $i, 1))
    Sleep($iDelay)
  Next
  Send(@CR)
  $x = FileReadLine($hFile)
WEnd
FileClose($hFile)
WinClose("Untitled - Notepad")

 

Phil Seakins

Posted
50 minutes ago, pseakins said:

Copy this example into your Scite editor and then save it, giving it a suitable name.

Nice work.!

Actually kinda cool to watch.

One thing for the OP to be careful of since he says:

On 11/5/2020 at 8:28 AM, vinnyMS said:

both source and target text file should be 100% identical when finished

is the encoding of the file when saving in notepad.  Source files, as one example, saved in Scite may be encoded UTF-8 with BOM.

Which is not the default in Notepad.

6D314588-1179-453F-A2FD-1DCDDAEF427C.thumb.jpeg.3744091b14b622367dc6853a2f99772e.jpeg

Code hard, but don’t hard code...

Posted
1 hour ago, vinnyMS said:

for some reason the "+" sign cannot be typed

My bad. Try again with this.

$iDelay = 10 ; number of milliseconds to pause between characters
$iLineDelay = 100 ; number of milliseconds to pause between lines
MsgBox(0, "", "Click ok when ready")
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Sleep(5000) ; allow operator time to start the capturing process
$hFile = FileOpen(@ScriptDir & "\" & @ScriptName)
$x = FileReadLine($hFile)
While Not @error
  For $i = 1 To StringLen($x)
    Send(StringMid($x, $i, 1), 1)
    Sleep($iDelay)
  Next
  Send(@CR)
  Sleep($iLineDelay)
  $x = FileReadLine($hFile)
WEnd
FileClose($hFile)
WinClose("Untitled - Notepad")

 

Phil Seakins

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...