Jump to content

Exchange data in real time


Recommended Posts

hi guys  i have a program A  this progrogram write  datat over one file frequently(many time  much fast and is a csv ),   i  try to read with autoit  and  work but  ofeten tell me  is not possible  read (because is locked for write to program A), is  possible have concurrent  read and write ?

thankz

Link to post
Share on other sites

IIRC this has been discussed on the forum.
One suggestion was to create a lock file and check this before reading/writing.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites
39 minutes ago, water said:

IIRC this has been discussed on the forum.
One suggestion was to create a lock file and check this before reading/writing.

not  wanna block a file  because the program A stream over  this file many data at milliseconds  in some period of the day

Link to post
Share on other sites

You could use IPC (inter process communication) to send data from program A to program B.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

The wiki / User Defined Functions / Inter Process Communications is full of different implementations. Select the one that suits your needs. Most of the time they come with examples too.
NB: MailSlot by trancexx seems to be an easy and reliabl implementation.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

Take a look at my sig.  I made a very simple IPC that I believe would nicely work with your requirements. 

Link to post
Share on other sites

I see. Then IPC is not a solution for you.  Not sure if that would work, but look into _WinAPI_CreateFile to open a file in share read mode ? 

Link to post
Share on other sites

I know that, you already told us.  You didn't answer my question ^^  Have you tried it, to open file csv file in program B with the WinAPI I suggested ?

Link to post
Share on other sites

Will add to the wiki :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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
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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites
2 hours ago, Nine said:

I see. Then IPC is not a solution for you.  Not sure if that would work, but look into _WinAPI_CreateFile to open a file in share read mode ? 

i create  somthing like this  but retun blank message

    Local $nBytes, $tBuffer

    $hFile = _WinAPI_CreateFile($sLFileCsvPath, 2, 2, 2)
    _WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
    _WinAPI_CloseHandle($hFile)
    $sText = BinaryToString(DllStructGetData($tBuffer, 1))
MsgBox(0,'',$sText)

 

Link to post
Share on other sites

i try to this mode

Local $aLFile = FileReadToArray($sLFileCsvPath)
    Local $aug = UBound($aLFile) - 1

    Local $aLFile2 = FileReadToArray($sLFileCsvPath)
    For $i = 0 To UBound($aLFile2) - 1

        $aLba = StringSplit($aLFile2[$i], ";")
        ;_ArrayDisplay($aLba)
        GUICtrlCreateListViewItem($aLFile2[2] & "|" & $aLFile2[4] & "|" & $aLFile2[5], $List1)
        If $aLFile2[3] = "well" Then
            GUICtrlSetColor(-1, 0x4AA02C)
        ElseIf $aLFile2[3] = "mee" Then
            GUICtrlSetColor(-1, 0xFF0000)
        EndIf

    Next

but  in this mode the program continusly update the row , but  not colored nothing and  is like blocked

Link to post
Share on other sites

Try this :

#include <WinAPIFiles.au3>
#include <WinAPIHObj.au3>

Local $sTempFile = "Temp1.au3", $nBytes
Local $tBuffer = DllStructCreate("char[20]")
Local $hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
Local $iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_ReadFile($hFile, $tBuffer, 20, $nBytes)
_WinAPI_CloseHandle($hFile)
Local $sText = DllStructGetData($tBuffer, 1)
ConsoleWrite("File size = " & $iSize & " / " & "Read = " & $nBytes & "/" &  $sText & @CRLF)

 

Link to post
Share on other sites

I know that.  But the real question is : does the file gets block or not using this approach.  If it doesn't get block, you now have a solution. 

Link to post
Share on other sites

i finded a udf  APITailRW.zip   

i tryed  to read

but  not  work 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         myName

 Script Function:
    Template AutoIt script.

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

; Script Start - Add your code below here


#include <File.au3>
#include "APITailRW.au3"


Local $sTempFile = "C:\Users\pc\AppData\Data.csv"



local $aArray=_FileReadLineAPI($sTempFile)

_ArrayDisplay($aArray)

 

 

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

    No registered users viewing this page.

×
×
  • Create New...