Jump to content
Sign in to follow this  
mmavipc

script not working

Recommended Posts

mmavipc

i created 2 scriptsa that sync with eachother...

but one of the scripts gui's(papertape) dosent respond

Scripts:

papertape:

#include <GUIConstants.au3>
global $et
GUICreate("papertape", 262, 339, 624, 128, -1)
$edit = GUICtrlCreateEdit("",0,0,262,339)
guisetstate()
if $cmdline[0] <> 1 Then
    Exit
EndIf
while 1
    $data = ""
    $data = consoleread()
    if $data = "hide" Then
        guisetstate(@sw_hide)
    ElseIf $data = "show" Then
        guisetstate(@SW_SHOW)
    elseif $data = "clear" Then
        $et = ""
    ElseIf stringleft($data,2) = "st" Then
        $st = stringsplit($data," ")
        if $st[0] = 2 Then
            if $et = "" Then
                $et = $st[2]
            Else
                $et = @lf & $st[2]
            EndIf
        EndIf
    elseif $data = "exit" then
        Exit
    EndIf
    $guimsg = guigetmsg()
    Switch $guimsg
        case $GUI_EVENT_CLOSE
            if consoleread() = "exit" Then
                exit
            EndIf
    EndSwitch
    GUICtrlSetData($edit,$et)
WEnd

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites
PsaltyDS

Your ConsoleRead() is hanging because there is no input. From the help file:

If at any time when this function is called (except for "peeking" as described below) there are no characters to be read from the stream, the ConsoleRead function will block (pause) and not return until there are characters to be read from the stream. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the parent process writes something to AutoIt's STDIN stream.

Use "peek" to check for available input before reading:

While 1
    $data = ""
    If ConsoleRead(0, 1) Then $data = ConsoleRead()

    ; ...

WEnd

Running that in a tight loop is likely to get you occasional partial messages. If you send "The quick brown fox", the console read might only get "The qui" and then get "ck brown fox" on the next loop. You might need a test for whatever end of line character is used.

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×