Jump to content

[Solved]Kill gui even with a sleep


Recommended Posts

Hi,

When I launch this script I can't close the gui because of the high value of the sleep.

I just want the message box appear every 4sec and be able to kill the gui when I want.

Anybody has an idea? thx by advance for your help.

Gui()

Func Gui()
Local $msg

GUICreate("My GUI")
GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

$count = 2

while $count > 0

msg("toto","titi")
sleep(4000)

WEnd

WEnd
GUIDelete()
EndFunc

Func msg($x,$y)
msgbox("","",$x & $y)
end func

Processor

Edited by Processor
Link to comment
Share on other sites

  • Moderators

Processor,

I would do it like this: ;)

#include <GUIConstantsEx.au3>

Gui()

Func Gui()

    GUICreate("My GUI")
    GUISetState(@SW_SHOW)

    $count = 2

    While $count > 0

        msg("toto", "titi")
        $count -= 1

        $iBegin = TimerInit()
        Do
            If GUIGetMsg() = $GUI_EVENT_CLOSE Then
                ExitLoop
            EndIf
        Until TimerDiff($iBegin) > 4000

    WEnd

    GUIDelete()

EndFunc   ;==>Gui

Func msg($x, $y)
    MsgBox("", "", $x & $y)
EndFunc   ;==>msg

Please ask if you have any questions. :)

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

I know that is the while loop that is blocking me, but without the sleep or with a very short one I can exit the loop.

Melba you idea is good but in fact my while is not while $count > 0

but while 1

so I have to exit 2 loops, is there any way to kill 2 loops in 1 time?

Link to comment
Share on other sites

I answer myself exitloop(2) save me.

Thanks you all

Melba23 once again you saved me.

If you want to keep your first script, add the the $msg in the while $count loop.

Didn't tested it but that should work.

P.s your code is bad written.

It's a resume of what I'm really doing, the real code is worst, you should see!!

Edited by Processor
Link to comment
Share on other sites

  • Moderators

Processor,

the real code is worst, you should see!!

If your code is really that bad, you are not going to get much help here as most people will not bother to struggle to understand large chunks of complicated code unless it is structured and has at least some comments. So I would start trying to do both those things, if I were you. ;)

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

Hi Melba23,

It was a joke, of course the complete code is structured and I put all comments I can in it.

Whatever I won't put the whole code here. I try before to understand what's blocking and sum it

in a short code like in this post.

It's more efficiant because, as you said people don't have time to struggle with chunks of complicated code even commented it could be a pain.

(even if how I use autoi is quite simple).

At least, I repeat thx all for your help!

Edited by Processor
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...