Jump to content

script not working


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...