Sign in to follow this  
Followers 0
WeMartiansAreFriendly

Stdread help (single-thread work around)

3 posts in this topic

#1 ·  Posted (edited)

Long story short I'm looking to find a work around for the "single-threaded" nature of AutoIt, it's just no match (speed wise) for its higher on the food chain counterparts.

Basically one of my ideas was to do some of the work from two separate processes, one would be the back end (the brains of the mission) and another process would be used as an interface, so I could just run the GUI portion and call the second process when needed, and read it's STD output and update progress on the GUI.

Only I'm having no such luck with STDRead working as intended, it is not capturing all the input, seems to me the console is too fast on it's output, If I have StdRead with "peak" enabled it just continues in an endless loop, and still manages to freeze the GUI. >_<

Perhaps a better method is available? Any possible solutions will be appreciated.

GUI Portion (front end) - keep both scripts at the same location

#include <Constants.au3>

$hGUI = GUICreate("ListView Add Item", 400, 300)
$hListView = GUICtrlCreateListView("Output", 2, 2, 394, 268)
GUISetState()

Local $foo = Run(@ScriptDir & "\test.exe", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo, False)
    If @error Then ExitLoop
    If $line = "" Then ContinueLoop
    GUICtrlCreateListViewItem($line, $hListView)
Wend

While 1
    $line = StderrRead($foo)
    If @error Then ExitLoop
   GUICtrlCreateListViewItem("erorr " & $line, $hListView)
Wend

While GUIGetMsg() <> -3
WEndoÝ÷ Ù¶éÝ­é·«¶(¥y«-^Å殶­sb4WFôC5w&W%ô÷WFfÆRÒFW7BæWP ¥6ÆVW·&VGV6RÆöB÷fW&V@ ¤f÷"b33c¶ÒFò 6öç6öÆUw&FR7G&ætf÷&ÖBgV÷C¶VÆÆòv÷&ÆBÂf÷"FRVBFÖRgV÷C²Âb33c¶¤æW@ ¤W

Ugh, such blasphemy when I editing my posts it mangles the script output. :)

Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites



Long story short I'm looking to find a work around for the "single-threaded" nature of AutoIt, it's just no match (speed wise) for its higher on the food chain counterparts.

Basically one of my ideas was to do some of the work from two separate processes, one would be the back end (the brains of the mission) and another process would be used as an interface, so I could just run the GUI portion and call the second process when needed, and read it's STD output and update progress on the GUI.

Only I'm having no such luck with STDRead working as intended, it is not capturing all the input, seems to me the console is too fast on it's output, If I have StdRead with "peak" enabled it just continues in an endless loop, and still manages to freeze the GUI. >_<

Perhaps a better method is available? Any possible solutions will be appreciated.

GUI Portion (front end) - keep both scripts at the same location

#include <Constants.au3>

$hGUI = GUICreate("ListView Add Item", 400, 300)
$hListView = GUICtrlCreateListView("Output", 2, 2, 394, 268)
GUISetState()

Local $foo = Run(@ScriptDir & "\test.exe", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo, False)
    If @error Then ExitLoop
    If $line = "" Then ContinueLoop
    GUICtrlCreateListViewItem($line, $hListView)
Wend

While 1
    $line = StderrRead($foo)
    If @error Then ExitLoop
   GUICtrlCreateListViewItem("erorr " & $line, $hListView)
Wend

While GUIGetMsg() <> -3
WEndoÝ÷ Ù¶éÝ­é·«¶(¥y«-^Å殶­sb4WFôC5w&W%ô÷WFfÆRÒFW7BæWP ¥6ÆVW·&VGV6RÆöB÷fW&V@ ¤f÷"b33c¶ÒFò 6öç6öÆUw&FR7G&ætf÷&ÖBgV÷C¶VÆÆòv÷&ÆBÂf÷"FRVBFÖRgV÷C²Âb33c¶¤æW@ ¤W

Ugh, such blasphemy when I editing my posts it mangles the script output. :)

If you use AutoIt tags you will often have problems with mangled scripts; I really don't like them (see my signature)

I don't know about the StdErrRead problem but I think messages would be very much faster, more reliable, more versatile and easier. ChrisL has a good udf for interscript communications in Example Scripts. (But probably you know that.)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If you use AutoIt tags you will often have problems with mangled scripts; I really don't like them (see my signature)

I don't know about the StdErrRead problem but I think messages would be very much faster, more reliable, more versatile and easier. ChrisL has a good udf for interscript communications in Example Scripts. (But probably you know that.)

Thanks, actually I didn't know about his script :), it is exactly what I was thinking about as an alternative to stdread.

http://www.autoitscript.com/forum/index.ph...c=77979&hl=

Also, I've noticed the script code gets mangled if you use more than one AutoIt tag >_<

FrontEnd.au3

#include <Constants.au3>
#include "MessageHandler.au3"

$Local_ReceiverID_Name = "Script1sReceiverID";This is the ID that the other script will use to send data
$Remote_ReceiverID_Name = "Script2sReceiverID";This is the ID of the script we want to send data too
$hwnd = _SetAsReceiver($Local_ReceiverID_Name)
$myFunc = _SetReceiverFunction("_MyFunc2")


$hGUI = GUICreate("ListView Add Item", 400, 300)
$hListView = GUICtrlCreateListView("Output", 2, 2, 394, 268)
GUISetState()


While GUIGetMsg() <> -3
Wend


Func _MyFunc2($vText)
   ;$iSent = _SendData($vText,$Remote_ReceiverID_Name)

    GUICtrlCreateListViewItem($vText, $hListView)
    Return 1
EndFunc

BackEnd.au3

#include "MessageHandler.au3"

Sleep(1000);reduce load overhead

$Local_ReceiverID_Name = "Script2sReceiverID";This is the ID that the other script will use to send data
$Remote_ReceiverID_Name = "Script1sReceiverID";This is the ID of the script we want to send data too
$hwnd = _SetAsReceiver($Local_ReceiverID_Name)
$myFunc = _SetReceiverFunction("_MyFunc2")

For $i = 1 To 1000
    _SendData(StringFormat("hello world, for the %d time", $i),$Remote_ReceiverID_Name)
Next

Exit
Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

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  
Followers 0