Jump to content

Trying to fileread a textfile where "exclamation mark" is to fill in the blank lines, but when using send() lines are empty


craydox
 Share

Recommended Posts

Textfile looks like this:
---------------------------------------------------------------------
blah blah blah
blah blah blah
!
!
blah blah blah
blah blah blah
!
!
blah blah blah
blah blah blah
----------------------------------------------------------------------

I read all above from the textfile to a variable
when i use the send command
it looks like this:

-----------------------------------------------------------------------
blah blah blah
blah blah blah


blah blah blah
blah blah blah


blah blah blah
blah blah blah
------------------------------------------------------------------------------

I guess the send command thinks this is starting of a keycombo like: 

HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d  

but no letter follows the ! and therefor just sends a blank line..
does anyone know how I can make it send exclamation marks instead of blanks

 


 

Edited by craydox
pushed wrong button
Link to comment
Share on other sites

Please have a look at the help file for the Send statement. You will see how to send the exclamation mark.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

OK. found out: send($filen,1) <----last flag is for sendraw so now I se the exclamation marks being sent.
but Im getting some kind of hidden LF, (I get an extra blank line of everyline it sends

I guess I have to check notepad textfile if it puts somekind of extra Linefeed sign in the background wich Fileread picks up.

------------------------------------------------
Switch blah blah blah
!
!
Switch blah blah blah
!
!
Switch blah blah blah
--------------------------------------------------
Becomes this below (with extra linefeed I guess
the textfile is made in notepad should be pure ASCI?!?

------------------------------------------------
Switch blah blah blah

!

!

Switch blah blah blah

!

!

Switch blah blah blah
--------------------------------------------------

Anyone encountered the same problem?

Link to comment
Share on other sites

Instead of using Send() function, you could directly set the text into Notepad with ControlSetText().

Please provide a runable example of what you are doing for us to understand your issue (See how to post code).

Link to comment
Share on other sites

Im trying to find where to add my my code in this thread.
Cant use ControlSetText() thats too fast I think.. I have to make it send with 7-20ms delay between character
ok Added the code as attached files and pasted directly in this reply:

 

#cs ###################################################################################

;.txt file is the source to be sent

goal is to press ALT+1 then it's supposed to send the exact text from the textfile
but it keeps doing extra blank lines for every line


#ce ####################################################################################


hotkeyset("^1", "copy1")
hotkeyset("^2", "copy2")
hotkeyset("^3", "copy3")
hotkeyset("^4", "copy4")
hotkeyset("^5", "copy5")
hotkeyset("^6", "copy6")
hotkeyset("^7", "copy7")
hotkeyset("^8", "copy8")
hotkeyset("^9", "copy9")
hotkeyset("^0", "copy0")

HotKeySet("!1", "paste1")
HotKeySet("!2", "paste2")
HotKeySet("!3", "paste3")
HotKeySet("!4", "paste4")
HotKeySet("!5", "paste5")
HotKeySet("!6", "paste6")
HotKeySet("!7", "paste7")
HotKeySet("!8", "paste8")
HotKeySet("!9", "paste9")
HotKeySet("!0", "paste0")

HotKeySet("!{esc}", "terminate" )    ;ALT+ESC QUITTAR!!!


Global $lagg = 1000

$laggsend = 17

Opt('SendKeyDelay', $laggsend); default 5. higher number = slower

;Global $t[10]
$filen = "apan"

$hFileOpen = FileOpen(@WorkingDir & "\" & "switchconfig_01.txt", 0)
$filen = FileRead($hFileOpen)
FileClose($hFileOpen)


MsgBox(0,"titel","test: " & $filen)


;---------------------COPY SEKTIONEN--------------------------------------------------------------

;(Not in use just for testing)
func copy1()
   Send("^c")    ;KOPPAR markerad text till clipboard
   sleep(500)    ;för att skiten skall hinna in i clipboard
   $filen = ClipGet ()
  
EndFunc


;----------PASTE sektionen--------------------------------------------------------------------------------


func paste1()
   ClipPut ($filen)
   sleep($lagg)
   ;Send("^v")
   send($filen,1)  ;<---sista flaggen är 1 då är det send RAW vilket get ! rätt men verkar gömma sig en LF som ger extra line-blanks istället
EndFunc

While 1

wend


func terminate()
    Exit 0        ;stänger ner allt
EndFunc

 

switchconfig_01.txt Test_sending_slow_33.au3

Edited by craydox
put the code in the right place
Link to comment
Share on other sites

First thing read carefully how to post code correctly.

Your problem is that your $filen contains @CRLF which Notepad interprets as 2 {Enter}.  You would need to replace all @CRLF with simple @CR (see StringReplace in help file)

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