Reading special characters from file.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LiquidZulu
Posts: 1
Joined: 21 Jun 2018, 08:55
Contact:

Reading special characters from file.

21 Jun 2018, 12:29

Hello,

I am attempting to write a script that will be able to paste large bodies of text line by line to avoid crashes (code below):

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

^+v:: ;ctrl shift v
txt = %clipboard%

FileAppend, %txt%`n, %A_WorkingDir%\ClipboardTemp.txt

sleep 500

Loop, read, test.txt
{
	Clipboard = %A_LoopReadLine%
	GoSub, PasteInfo
}

FileDelete, %A_WorkingDir%\ClipboardTemp.txt
return

PasteInfo:
send %clipboard%`n
return
Using test file "test.txt" as shown revealed that %A_LoopReadLine% is not reading special characters. The contents of test.txt are shown along with what is actually pasted:

Code: Select all

line 1
line 2
line #

{pastes to}:

line 1
line 2
line 

If anyone knows a better way of doing this any help would be appreciated. Thank you.
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Reading special characters from file.

21 Jun 2018, 12:36

Instead of using Send, %Clipboard%, try sending the hotkey for paste Send, ^v (Ctrl + V)

AutoHotkey is likely thinking that # is a hotkey and attempting to send the hotkey instead of the copied text.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mikeyww and 310 guests