Jump to content

_GUICtrlEdit_AppendText freezes gui


Recommended Posts

Moderator note: See later posts - the OP found that the problem was not sound related

###############################################################

Having issues using soundplay('wavfile.wav', 0)

the sound is supposed to play while there is stuff written to an edit control.
sometimes it works, sometimes the GUI just freezes and I have to ctrl-alt-del...

the sound file is 10 seconds long and uses 0 as the soundplay parameter to play it async.
sometimes sleep is used for 50 milliseconds while the sound is still playing.

any others having issues with this? 🤔

debug code:

!>22:50:40 AutoIt3.exe ended.rc:-805306369

Edited by Melba23
Amended title to reflect actual problem
Link to comment
Share on other sites

  • Moderators

@TheAutomator a little difficult to assist with no code posted. What error handling do you have in place?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

11 hours ago, JLogan3o13 said:

@TheAutomator a little difficult to assist with no code posted. What error handling do you have in place?

i'm sorry..
i tried narrowing it down and i couldn't recreate the crash that way
the code is kinda huge 😅

can you tell me what you mean exactly with "what kinda error handling"?
i'm using the autoit editor and the crash appears to happen wile appending some text after a short pause with sleep()
it freezes and when i end the task the error code above in the debug console is all i have..

 

edit: it's also random, maybe it's my pc or a driver problem
i'll post some code from the moment i can replicate the error

Edited by TheAutomator
Link to comment
Share on other sites

  • 3 weeks later...

this is driving me nuts!
i now have the problem reappearing every exact same time...

it appears that the issue comes from a specific string it has to write to the edit control at a certain moment..
then autoit freezes.

this was also the case a few other times with this script, but on different places... whyyy

when i alter that string with only one single character or a different timing it works fine, else not...
its just a bunch of random characters and a newline character (exactly there it stops).
if i type something before or after the 'crlf' character (that's in the middle of the string) it suddenly just works fine...

even more strange, if i press CTRL + BREAK to stop the frozen script with the editor the mouse arrow starts moving to the right bottom corner of my screen? what the..?

Edited by TheAutomator
Link to comment
Share on other sites

  • Moderators

Again, how can anyone help you without seeing code???

If the code is "kinda huge" then try a reproducer that demonstrates the problem. Otherwise, you're asking us to first guess at what you're doing and then help you troubleshoot.

On 12/30/2019 at 6:13 PM, TheAutomator said:

can you tell me what you mean exactly with "what kinda error handling"?

Take a look at the FAQ in the Wiki; very first section is "How can I debug my script?". This is where you should start when trying to track down a bug in the code.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

#include <guiconstantsex.au3>
#include <buttonconstants.au3>
#include <windowsconstants.au3>
#include <guiedit.au3>

;--------------------------------------------------------------------------------------------------

const $form = guicreate('TypingError', 600, 400, default, default, bitor($gui_ss_default_gui,$ws_maximizebox,$ws_sizebox,$ws_thickframe,$ws_tabstop))
    guisetbkcolor(0x400000)
    const $console = guictrlcreateedit('loading...', 10, 10, 581, 341, bitor($es_autovscroll,$es_readonly,$es_wantreturn,$ws_vscroll), 0)
        guictrlsetfont(default, 12, 800, 0, 'consolas')
        guictrlsetcolor(default, 0xffffff)
        guictrlsetbkcolor(default, 0x000000)
        guictrlsetresizing(default, bitor($gui_dockleft,$gui_dockright,$gui_docktop,$gui_dockbottom))
        guictrlsetcursor (default, 3)
    const $user = guictrlcreateinput('', 10, 360, 521, 30, default, 0)
        guictrlsetfont(default, 14, 800, 0, 'consolas')
        guictrlsetcolor(default, 0xffffff)
        guictrlsetbkcolor(default, 0x000000)
        guictrlsetresizing(default, bitor($gui_dockleft,$gui_dockright,$gui_dockbottom,$gui_dockwidth,$gui_dockheight))
    const $send = guictrlcreatebutton('send', 540, 360, 51, 31, bitor($es_uppercase,$bs_defpushbutton,$ws_disabled))
        guictrlsetresizing(default, bitor($gui_dockright,$gui_dockbottom,$gui_dockwidth,$gui_dockheight))
        guictrlsetcursor (default, 0)
guisetstate(@sw_show)

;--------------------------------------------------------------------------------------------------

Global $clear = False
func WRITE($message)
    if $clear then
        $clear = False
    else
        _guictrledit_appendtext($console, @crlf)
    endif
    ADD($message)
endfunc

Func ADD($message)
    for $i = 1 to stringlen($message)
        sleep(50)
        _guictrledit_appendtext($console, stringmid($message, $i, 1))
    next
EndFunc

func READ()
    guictrlsetstate($send, $gui_enable)
    while 1
        switch guigetmsg()
            case $gui_event_close
                exit
            case $send
                guictrlsetstate($send, $gui_disable)
                local $answer = guictrlread($user)
                guictrlsetdata($user, '')
                return $answer
        endswitch
    wend
endfunc

HotKeySet('{esc}','quit')
func QUIT()
    write("goodbye...")
    exit
endfunc

;--------------------------------------------------------------------------------------------------

write('this a test of a string with the ' & @CRLF & 'character in it...')
read()
Sleep(1000)
$clear = True
GUICtrlSetData($console, '')
write('this a test of qdfgdqfgqdfga string with the ' & @CRLF & 'character in it...');PROBLEM!
read()
write('this a test oqdgff a string with the ' & @CRLF & 'character in it...')
read()
write('this a t... cbgfshf...e?' & @CRLF & 'character in it...')
read()
write('done')

I finally managed to narrow it down to this, and i can replicate the bug.
I'm sorry for the inconvienience but the code for this one was huge, lots of nesting and arrays with strings readed from files and stuff..
but it seems that this example shows where the gui freezes.

Link to comment
Share on other sites

just press enter after every sentence, there is one crashing my script every time:

write('this a test of qdfgdqfgqdfga string with the ' & @CRLF & 'character in it...');PROBLEM!

if i alter the sentence or i remove or change a few of the other strings.... it works?
if i press CTRL+BREAK when the script freezes, the mousepointer moves to the screencorner also?

Aantekening 2020-01-16 133439.jpg

Edited by TheAutomator
image
Link to comment
Share on other sites

1 minute ago, Nine said:

Works without issue on Win7 !

windows 10 user here, maybe it's related to that? i'm not sure.. compatibility bug?

question, did you also test it on a w10 system afterwards?
i tested this on my home pc (w10) and the one at work (w10) with the same results, a crash.

Link to comment
Share on other sites

3 minutes ago, Nine said:

Yes I got the same problem on win 10

so weird, even a single character can change if it works or not..
guess i was extremely lucky with finding the right sentences to replicate this bug. hah

asking the mods to change the title of this post because sound is actually not the problem..

Edited by TheAutomator
Link to comment
Share on other sites

  • Moderators

TheAutomator,

There is no automatic alert for bugs, but we check Trac regularly. And I have amended the thread title as you requested.

I can certainly reproduce the problem and I am trying to see if I can find a pattern to what actually triggers the freezing - at the moment the script seems to be waiting at the Sleep(50) line but I cannot understand why this should occur. There also appears to be little pattern to the makeup of the string preceding the @CRLF as I can get the same symptoms using other character combinations - so the particular string you used does not appear to be "magic" in any particular way. I did wonder if the actual location of the @CRLF within the string was critical, but again it does not seem to be the case from my tests so far.

I will keep plugging away and see if I can come up with something.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba23,

Thanks for letting me know! (and for changing the topic title). [edit: not nesesairly _GUICtrlEdit_AppendText, guictrlsetdata(..., ..., 1) does the same here]

I modified that pseudo-magic string by one or two characters and that sometimes makes it work again or makes it stop working again..
I think it also freezes without the sleep(50) in some cases.

At the start i didn't even know how to reproduce this crash because it was so vague where it came from,
lucky i found out it had nothing to do with sound or the size of my script.

I'm glad you saw this post, and hopefully you guys don't have to much trouble figuring out what the reason for this bug is..
if something comes up and it gets fixed i'll read it here? or do i check regularly for a new autoit version?

regards

Edited by TheAutomator
about the topic title
Link to comment
Share on other sites

  • Moderators

TheAutomator,

I have narrowed the problem down to the early lines of your WRITE function - appending @CRLF to the empty edit seems to be the culprit in my testing so far, but I have no idea why this is the case. Good job I have a free afternoon to continue my detective work!

You will read about any fix in Trac where we follow-up reports. And I doubt we will need a new AutoIt version to solve this, so no need to check.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

The problem in your script is the func write. I don't understand why but after testing with little modification it runs:

#include <guiconstantsex.au3>
#include <buttonconstants.au3>
#include <windowsconstants.au3>
#include <guiedit.au3>

;--------------------------------------------------------------------------------------------------

const $form = guicreate('TypingError', 600, 400, default, default, bitor($gui_ss_default_gui,$ws_maximizebox,$ws_sizebox,$ws_thickframe,$ws_tabstop))
    guisetbkcolor(0x400000)
    const $console = guictrlcreateedit('loading...', 10, 10, 581, 341, bitor($es_autovscroll,$es_readonly,$es_wantreturn,$ws_vscroll), 0)
        guictrlsetfont(default, 12, 800, 0, 'consolas')
        guictrlsetcolor(default, 0xffffff)
        guictrlsetbkcolor(default, 0x000000)
        guictrlsetresizing(default, bitor($gui_dockleft,$gui_dockright,$gui_docktop,$gui_dockbottom))
        guictrlsetcursor (default, 3)
    const $user = guictrlcreateinput('', 10, 360, 521, 30, default, 0)
        guictrlsetfont(default, 14, 800, 0, 'consolas')
        guictrlsetcolor(default, 0xffffff)
        guictrlsetbkcolor(default, 0x000000)
        guictrlsetresizing(default, bitor($gui_dockleft,$gui_dockright,$gui_dockbottom,$gui_dockwidth,$gui_dockheight))
    const $send = guictrlcreatebutton('send', 540, 360, 51, 31, bitor($es_uppercase,$bs_defpushbutton,$ws_disabled))
        guictrlsetresizing(default, bitor($gui_dockright,$gui_dockbottom,$gui_dockwidth,$gui_dockheight))
        guictrlsetcursor (default, 0)
guisetstate(@sw_show)

;--------------------------------------------------------------------------------------------------

Global $clear = False
func WRITE($message)
    if $clear then
        $clear = False
        ADD($message & @CRLF)
    else
        _guictrledit_appendtext($console, $message & @crlf)
        $clear = True   ;can be deleted if no need for
    endif
endfunc

Func ADD($message)
    for $i = 1 to stringlen($message)
        sleep(50)
        _guictrledit_appendtext($console, stringmid($message, $i, 1))
    next
EndFunc

func READ()
    guictrlsetstate($send, $gui_enable)
    while 1
        switch guigetmsg()
            case $gui_event_close
                exit
            case $send
                guictrlsetstate($send, $gui_disable)
                local $answer = guictrlread($user)
                guictrlsetdata($user, '')
                return $answer
        endswitch
    wend
endfunc

HotKeySet('{esc}','quit')
func QUIT()
    write("goodbye...")
    exit
endfunc

;--------------------------------------------------------------------------------------------------

write('this a test of a string with the ' & @CRLF & 'character in it...')
read()
Sleep(1000)
GUICtrlSetData($console, '')
$clear = True
write('this a test of qdfgdqfgqdfga string with the ' & @CRLF & 'character in it...');PROBLEM!
$answer = read()
write('this a test oqdgff a string with the ' & @CRLF & 'answer in it: ' & $answer)
read()
write('this a t... cbgfshf...e?' & @CRLF & 'character in it...')
read()
write('done')

 

Link to comment
Share on other sites

  • 3 weeks later...
On 1/17/2020 at 12:20 PM, Melba23 said:

TheAutomator,

I have narrowed the problem down to the early lines of your WRITE function - appending @CRLF to the empty edit seems to be the culprit in my testing so far, but I have no idea why this is the case. Good job I have a free afternoon to continue my detective work!

You will read about any fix in Trac where we follow-up reports. And I doubt we will need a new AutoIt version to solve this, so no need to check.

M23

Any updates on this? I'm sorry for looking impatient 😅
I regularly check the bug tracker for a while now, nothing changes and not being able to add text to an edit control is quite inconvenient 😕

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...