Jump to content

Recommended Posts

Posted

Hi there,

Made 2 very simple processes (Parent / Child).  It is working fine except that once every while, the child doesn't receive the parent message.  Yes it is intended that the child finishes after the reception of the message.

Here's the parent :

;********  ConsoleWrite  **********  

#include <constants.au3>

HotKeySet("{END}", "Terminate")
HotKeySet("{F1}", "SendIt")

Global $pid = run ("ConsoleRead.exe", "", "", $STDOUT_CHILD + $STDIN_CHILD)
Global $count = 0

While True
  Sleep (50)
Wend

Func Terminate ()
  exit
EndFunc

Func SendIt ()
  $count += 1
  StdinWrite ($pid, $count)
  $pid = run ("ConsoleRead.exe", "", "", $STDOUT_CHILD + $STDIN_CHILD)
EndFunc

Here's the child :

;********  ConsoleRead  **********  

#NoTrayIcon

Global $text

While True
  Sleep (50)
  $text = ConsoleRead ()
  if @error then ExitLoop
  if $text = "" then ContinueLoop
  FileWriteLine ("Test.log", $text)
  Beep (500,25)
  ExitLoop
Wend

Any help would be greatly appreciated.

Thanks for reading.

 

Posted (edited)

Hi, 

 

Seem like this line make you wait sometime. 

if $text = "" then ContinueLoop

You should control the return value anyway before playing with it. 

 

Because what is happenning if $text = what ever any different string than "" ?

 

Oh btw the number of views does not determine how someone wil be able to help you :/.

 

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
Posted

Yeah this is what i was mentionning. But by the oposite way/

 

whenever there is NOT nothing to ConsoleRead, it will NOT return a "". 

So it will NOT continu loop.

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

Exactly this is the intention. In order words, whenever child receive a char, it must be exited.  I know it sounds weird but it is just a test.  The problem is not there. The problem is that sometimes consoleread says it has nothing to read but the fact is that parent has sent something.  Happens every 50-60 writes...

Posted (edited)
35 minutes ago, Nine said:

The problem is that sometimes consoleread says it has nothing to read but the fact is that parent has sent something.

Ok, then do you see the message in the second scite console output ?

I dont want to be unpleasant. But this should be in your first post so we dont have to try to figure out what is going on before trying to help. This is maybe the main reason why no one unswer.

 

 

When i read you ... i understand there is no problem and this is a normal script reaction... 

 

You got a script that will stop looping when you got a message and you asking help on why your script isn't working when you got a message, each 50 60 run. 

 

Or i miss somthing ?

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

Sorry if I am not clear, English is not my first language.  Let me try to clarify.  If you run parent "ControlWrite" and you press F1 50-60 times quite rapidly, you will see that child "ConsoleRead" will not capture ONE of the message sent by parent.  It will skip one message.  It is clear in the log file that one message has not been captured but all the other messages has been well received.  Since all the messages are incremental numbers, it is very easy to notice one message has not been read.

Hope it is more clear now.

Posted (edited)

Ok found something, it is not ConsoleRead the problem, it is stdinwrite.  For some reason, stdinwrite will write 0 char to the channel from time to time. It is not giving an @error but the return value of stdinwrite equals 0.  A small loop that execute stdinwrite repeatedly until the returned value > 0 solve the problem.

But I still don't understand WHY stdinwrite would send a 0 byte message.  I do believe tho it is a bug.

Edited by Nine

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
×
×
  • Create New...