Jump to content
Sign in to follow this  
kylet90

ClipGet Skips Second Line

Recommended Posts

kylet90

; filename to read
$file_to_read = "C:\testing\source.txt"
; open file to read and store the handle
$handle_read = FileOpen($file_to_read, 0)
; check the handle is valid
If $handle_read = -1 Then
    ; show warning and exit with code 1
    MsgBox(0, @ScriptName, 'failed to open handle to read the file')
    
   Exit 1
EndIf


; loop through each line of the file
While 1
    ; read each line from a file
    $line_read = FileReadLine($handle_read)
    ; exit the loop if end of file
    If @error = -1 Then
       End()
    EndIf
    ; Checks if 7007 is open and sends clipboard.   
    If WinExists("SC7007_01") Then
    ClipPut($line_read)
    WinActivate ("SC7007_01")
    WinWaitActive ("SC7007_01")
    ControlSend("SC7007_01", "", "[CLASS:Edit; INSTANCE:1]", "33")
    ControlSend("SC7007_01", "", "[CLASS:ThunderRT6TextBox; INSTANCE:3]", ClipGet() )
    Send ("{ENTER}")
    Else 
    MsgBox(0, "Error", "LPScala 7007 is not running")
    Exit 3
    EndIf
    
WEnd

Func End()
MsgBox(0, "End", "Move to next step")
Exit 4
EndFunc

; close the file handle for read
FileClose($handle_read)
; close the file handle for write
FileClose($handle_write)

Hi,

The script should read up to 4 lines from a text file, then paste the output in to an application. However, it always seems to skip line 2 with the below code. But it doesn't skip the line if use ClipGet with MsgBox instead of the application. I've no idea what I'm doing wrong? I tried adding a few sleep commands to make sure it had enough time but that didn't work..

Any help is appreciated.

 

Share this post


Link to post
Share on other sites
Kidney

why r you using clipGet and Clipput when you have a variable with the value already stored in it??

ControlSend("SC7007_01", "", "[CLASS:ThunderRT6TextBox; INSTANCE:3]", $line_read )

 

add a msgbox before you send the info to make sure you have the correct output.

it could be that the app you r using is blocking the input cuz it has characters it does not accept.

Edited by Kidney

Share this post


Link to post
Share on other sites
kylet90

I'll try that thanks, although I would still expect ClipGet to give the same answer.

Its not being rejected, its always a 12 digit number, ive re-arranged numbers in the file andnit only skips the second line.

Share this post


Link to post
Share on other sites
kylet90

Hi,

This can be closed now. I managed to get this working using ControlFocus. I also took the advice of Kidney to clean up the code. Thanks everyone.

Share this post


Link to post
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
Sign in to follow this  

×