Jump to content
Sign in to follow this  
Luigi

Script pause in MsgBox

Recommended Posts

with this example the script will not stop

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('GuiOnEventMode', 1)
Global $refresh, $msgbox, $label_1, $button_1, $button_2, $button_3
Global $Hour, $Mins, $Secs, $start
$refresh = False
$msgbox = GUICreate('MsgBox - Exemple', 140, 55, -1, -1)
GUISetOnEvent($gui_event_close, '_Close')
GUISetState()
$label_1 = GUICtrlCreateLabel('00:00:00', 5, 5, 130, 20, 0x0201, $WS_EX_CLIENTEDGE)
$button_1 = GUICtrlCreateButton('Start', 5, 30, 60, 20)
GUICtrlSetOnEvent($button_1, '_Start')
$button_2 = GUICtrlCreateButton('Stop', 75, 30, 60, 20)
GUICtrlSetOnEvent($button_2, '_Stop')
;
While 1
 Sleep(1)
 If $refresh Then
  _TicksToTime(Int(TimerDiff($start)), $Hour, $Mins, $Secs)
  GUICtrlSetData($label_1, StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs))
 EndIf
WEnd
;
Func _Close()
 GUIDelete($msgbox)
 Exit 0
EndFunc   ;==>_Close
;
Func _Start()
 $refresh = True
 $start = TimerInit()
EndFunc   ;==>_Start
;
Func _Stop()
 $refresh = False
EndFunc   ;==>_Stop

Share this post


Link to post
Share on other sites

Or be cool :mellow:

#cs
Thread msgbox by Shaggi
#ce
#include <Array.au3>
#include <WinApi.au3>
#AutoIt3Wrapper_UseX64=n
ThreadedMsgBox(0,"HEY","1",0)
ThreadedMsgBox(0,"HEY","2",0)
ThreadedMsgBox(0,"HEY","3",0)
ThreadedMsgBox(0,"HEY","4",0)
ThreadedMsgBox(0,"HEY","5",0)
ThreadedMsgBox(0,"HEY","6",0)
ThreadedMsgBox(0,"HEY","7",0)
ThreadedMsgBox(0,"HEY","8",0)
MsgBox(0,"HEY","Last!")
Func ThreadedMsgBox($Flag,$Title,$Text,$Hwnd)
Static $Count = 0
If NOT IsDeclared("Memory_Management1") Then Global $Memory_Management1[1] = [0]
If NOT IsDeclared("Memory_Management2") Then Global $Memory_Management2[1] = [0]
If NOT IsDeclared("Memory_ASM") Then Global $Memory_ASM[1] = [0]
$Count += 1
_ArrayAdd($Memory_Management1,DllStructCreate("wchar[" & StringLen($Title) & "]"))
_ArrayAdd($Memory_Management2,DllStructCreate("wchar[" & StringLen($Text) & "]"))
DllStructSetData($Memory_Management1[$Count],1,$Title)
DllStructSetData($Memory_Management2[$Count],1,$Text)
$Address = DlLCall("Kernel32.dll","ptr","GetProcAddress","handle",_WinApi_GetModuleHandle("User32.dll"),"str","MessageBoxW")
$Stub = "0x" & _
   "68" & Hex(Binary($Flag),8) & _
   "68" & Hex(Binary(DllStructGetPtr($Memory_Management1[$Count]))) & _
   "68" & Hex(Binary(DllStructGetPtr($Memory_Management2[$Count]))) & _
   "68" & Hex(Binary($Hwnd)) & _
   "B8" & Hex(Binary($Address[0])) & _
   "FFD0" & _
   "C3"
_ArrayAdd($Memory_ASM,DllStructCreate("byte[" & Int(StringLen($Stub))+1 & "]"))
DllStructSetData($Memory_ASM[$Count],1,$stub)
$ret = DllCall("Kernel32.dll","handle","CreateThread","int",0,"int",0,"ptr",DllStructGetPtr($Memory_ASM[$Count]),"int",0,"int",0,"int",0)
Return $Ret[0]
EndFUnc
Func GetMsgBoxReturn($MsgBox)
$iRet = DllCall("Kernel32","int","GetExitCodeThread","handle",$MsgBox,"int*",0)
Return $iRet[2]
EndFunc

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites

I am sorry... I try two examples without sucess... I thinking build other module for my script, and left free database's module from msgbox.

If I use MsgBox, the program's looping is paused... This is not good. 8(


Visit my repository

Share this post


Link to post
Share on other sites

Isn't the purpose of the MsgBox to stop script! Why would you want to keep it running without a chance to respond. If it keeps running the loop and it keeps going to the MsgBox line (or GUICreate to look like MsgBox) you will have 1,000's of them within seconds. Unless a "If WinExisit($GUIname) then" is in the loop.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...