Rambo Posted September 10, 2009 Share Posted September 10, 2009 I´m reading Autoit´s help, but i cant find anything about it. I want to do a MsgBox with Button OK and a time count. So, if not pressed, the app itself continue when the time ends. I know we can set MsgBox with timeout, but i want to put a counter in the button itself, so the user can view it. Thanks Link to comment Share on other sites More sharing options...
nfaustin Posted September 10, 2009 Share Posted September 10, 2009 (edited) Hi, I believe you make your own GUI for Msgbox for this to accomplish. Make a function then inside it, create GUI, labels, and a button and some coding to update the text on button of countdown timer. Just call it by function to show your custom MSGbox GUI. Edit1: You may used Koda for you to design the GUI easily. Edited September 10, 2009 by nfaustin [font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font] Link to comment Share on other sites More sharing options...
JohnOne Posted September 10, 2009 Share Posted September 10, 2009 how about If $button1 then function_to_end_app Else dont AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
andygo Posted September 10, 2009 Share Posted September 10, 2009 i see two ways: first one $i = 10 while $i > 0 MsgBox ( 64, "countdown to click", "click the button: " & $i, 1) $i = $i - 1 wend second is to create a mini-gui in msgbox-style (i would prefer this) Link to comment Share on other sites More sharing options...
Rambo Posted September 10, 2009 Author Share Posted September 10, 2009 (edited) i see two ways: first one $i = 10 while $i > 0 MsgBox ( 64, "countdown to click", "click the button: " & $i, 1) $i = $i - 1 wend second is to create a mini-gui in msgbox-style (i would prefer this) Yes, but how to put the counter just close by "OK"? I mean inside the button itself. The command MsgBox hasnt option to do this, right? Thanks for your replies Edited September 10, 2009 by Rambo Link to comment Share on other sites More sharing options...
colafrysen Posted September 10, 2009 Share Posted September 10, 2009 First, No the MsgBox function does not have this functionality. You could though have another script running that changes the text on the button control. But as other have said, its easier to just create your own GUI. [font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size] Link to comment Share on other sites More sharing options...
Rambo Posted September 10, 2009 Author Share Posted September 10, 2009 Thanks. I´m thinking in something like this: $button = GUICtrlCreateButton("OK (" & $counter & ")",165, 355, 130, 25 ) And a For...Next to make the counter. Link to comment Share on other sites More sharing options...
colafrysen Posted September 10, 2009 Share Posted September 10, 2009 (edited) Well, that will create a lot of buttins on top of eachother. Use GuiCtrlSetData() to change the text on the button Example: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 225, 97, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 8, 8, 209, 81, $WS_GROUP) GUISetState(@SW_SHOW) For $X=10 to 0 Step -1 GUICtrlSetData($Button1,"OK ("&$X&")") Sleep(999) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EDIT: Note that you somehow will have to check if the button is pressed as the program becomes non-responsive during sleeps, also the for next is not in the while loop so no checking for events there... Edited September 10, 2009 by colafrysen [font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size] Link to comment Share on other sites More sharing options...
andygo Posted September 10, 2009 Share Posted September 10, 2009 little example code: #include <GUIConstantsEx.au3> $i = 10 $GUI_Main = GuiCreate("Test", 400, 400) $tb = GuiCtrlCreateButton("Counter", 90, 115, 80, 30) GUICtrlSetOnEvent (-1, "cr") GUISetState(@SW_SHOW, $GUI_Main) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop if $msg = $tb Then Opt("GuiOnEventMode", 1) while $i > 0 GUICtrlSetData($tb, "Cancel (" & $i & ")") $i = $i - 1 sleep(1000) wend GUICtrlSetData($tb, "Counter") $i = 10 endif WEnd func cr() if stringinstr (guictrlread ($tb), "Cancel") then $i = 0 Opt("GuiOnEventMode", 0) endif endfunc Link to comment Share on other sites More sharing options...
nfaustin Posted September 10, 2009 Share Posted September 10, 2009 Hi Rambo, Try this. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $MessageBoxForm1,$flag_to_Exit = False ; Your main script here Call_Message() ; your custom message box called ; Your main script here Exit ; End of your script Func Call_Message() Local $countdown = 10 $MessageBoxForm1 = GUICreate("MY Custom Messages Box", 355, 135, 192, 150,$WS_SYSMENU) $Label1 = GUICtrlCreateLabel("My custom text here.... Just add your personal messages", 32, 16, 270, 17) $Button1 = GUICtrlCreateButton("Button1", 88, 64, 161, 41, $WS_GROUP) GUICtrlSetOnEvent($Button1, "Click_to_Exit") GUISetState(@SW_SHOW) While 1 if $countdown = 0 or $flag_to_Exit = True then GUIDelete($MessageBoxForm1) ExitLoop EndIf GUICtrlSetData($Button1,"OK ("&$countdown&")") $countdown -= 1 Sleep(999) WEnd EndFunc Func Click_to_Exit() GUIDelete($MessageBoxForm1) $flag_to_Exit = True EndFunc ;===================================================================================================================================================================== ; Function of Event of the GUI on GUIOnEventMode enable ;===================================================================================================================================================================== Func SpecialEvents() If @GUI_CtrlId = $GUI_EVENT_CLOSE Then Exit EndFunc ;==>SpecialEvents ; End of Special Events ;===================================================================================================================================================================== [font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font] Link to comment Share on other sites More sharing options...
hhzz Posted September 15, 2009 Share Posted September 15, 2009 (edited) I´m reading Autoit´s help, but i cant find anything about it.I want to do a MsgBox with Button OK and a time count. So, if not pressed, the app itself continue when the time ends.I have been looking for this too. The default MsgBox doesn't have any indication how long someone has before the message box will disappear. Even if you put in a message saying "Time out in X seconds", it still isn't clear to the user since he/she may not know how long it has been up.@nfaustin: thank you for posting an interim solution for us!But, we should add this to the "wish" list. I am going to look if it has been suggested yet.Edit: I have added to the wish list #1178 Edited September 15, 2009 by hhzz Link to comment Share on other sites More sharing options...
nfaustin Posted September 15, 2009 Share Posted September 15, 2009 Remember it using mode Opt("GUIOnEventMode", 1) ; ON If your main script did not use this just turn off the GUIOnEventMode after exiting the function. Opt("GUIOnEventMode", 0) ; OFF Just search in the forum how to manipulate this mode. I remember someone post it how to manipulate the GUIEventmode. [font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font] Link to comment Share on other sites More sharing options...
GEOSoft Posted September 15, 2009 Share Posted September 15, 2009 I have been looking for this too. The default MsgBox doesn't have any indication how long someone has before the message box will disappear. Even if you put in a message saying "Time out in X seconds", it still isn't clear to the user since he/she may not know how long it has been up.@nfaustin: thank you for posting an interim solution for us!But, we should add this to the "wish" list. I am going to look if it has been suggested yet.Edit: I have added to the wish list #1178That was a total waste of adding something into the wish list. MsgBox() is a standard Windows dialog and has no provision for what you want. If you want a time count to display then you will have to create a custom message box using the AutoIt GUI and a timer. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
JScript Posted September 15, 2009 Share Posted September 15, 2009 I´m reading Autoit´s help, but i cant find anything about it.I want to do a MsgBox with Button OK and a time count. So, if not pressed, the app itself continue when the time ends.I know we can set MsgBox with timeout, but i want to put a counter in the button itself, so the user can view it.ThanksHello, maybe it is this that you are seeking:_MsgBox.au3 (UDF)- support resources and URL for custom image... Custom buttons + icons (support GIF animated) + position, show countdown..I hope to have helped. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
hhzz Posted September 15, 2009 Share Posted September 15, 2009 Hello, maybe it is this that you are seeking:_MsgBox.au3 (UDF)- support resources and URL for custom image... Custom buttons + icons (support GIF animated) + position, show countdown..I hope to have helped.That's totally awesome, jscript! Link to comment Share on other sites More sharing options...
JScript Posted September 15, 2009 Share Posted September 15, 2009 That's totally awesome, jscript!Maybe... http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
netegg Posted December 5, 2009 Share Posted December 5, 2009 (edited) expandcollapse popup; Note: Modify MsgBox window style, dynamic display countdown prompt text. ; Syntax: MsgBoxDJS (msgbox style signs, 'title', 'prompt text' [, countdown length (seconds) [, dynamic control, a sign of [, handle]]]) ; Parameters: msgbox style signs, 'title', 'text prompt', handles all with the MsgBox function, please refer to the MsgBox () function description. ; Countdown duration (seconds) - [optional] units of seconds, the default is 10. ; Dynamic control's logo - [optional] 0 = dynamic "title", 1 = dynamic "prompt text" (default), 2 = dynamic "button." ; Note: in the title or the message box displays the time dynamically by default displayed in the string in front of, and if necessary adjust the position of marks in% s. ; Return value: (with the MsgBox function) Success = return press the button ID. Failed = Returns -1 (the message box is the user ignored). ; Author: Afan - http://www.autoit.net.cn (this udf borrowed guland idea, THX ~) Func MsgBoxDJS($flag, $title, $text, $timeout = 10, $Cflag = 1, $hwnd = '') Global $Timer = DllCallbackRegister('Timer', 'int', 'hwnd;uint;uint;dword') If $timeout = '' Or $timeout = -1 Then $timeout = 10 Global $_title = $title, $_text = $text, $_Cflag = $Cflag, $_ibj = 1, $_ttc = $timeout, $bttxtbj = 0 Global $TimerDLL = DllCall('user32.dll', 'uint', 'SetTimer', 'hwnd', 0, 'uint', 0, 'int', 1000, 'ptr', DllCallbackGetPtr($Timer)) Local $Mkmsg If $Cflag = 0 Then If StringRegExp($title, '%s') = 0 Then $title = '%s' & $title $_title = $title EndIf $title = StringRegExpReplace($title, "%s", StringFormat('%03s', $_ttc), 1) EndIf If $Cflag = 1 Then If StringRegExp($text, '%s') = 0 Then $text = '%s' & $text $_text = $text EndIf $text = StringRegExpReplace($text, "%s", StringFormat('%03s', $_ttc), 1) EndIf $Mkmsg = MsgBox($flag, $title, $text) DllClose($TimerDLL) DllCallbackFree($Timer) Return $Mkmsg EndFunc ;==>MsgBoxDJS Func Timer($hwnd, $uiMsg, $idEvent, $dwTime) Global $TimerDLL, $bttxtbj, $_Cflag, $_title, $_ttc, $_text, $_ibj, $Timer If $idEvent = $TimerDLL[0] Then Global $bttxt, $CtrlF, $Static If $bttxtbj = 0 Then If $_Cflag = 0 Then $CtrlF = ControlGetFocus(StringRegExpReplace($_title, "%s", StringFormat('%03s', $_ttc), 1)) If $_Cflag = 1 Or $_Cflag = 2 Then $CtrlF = ControlGetFocus($_title) $bttxt = ControlGetText($_title, $_text, $CtrlF) If $_Cflag = 1 Then $Static = 'Static1' ControlGetText($_title, StringRegExpReplace($_text, "%s", StringFormat('%03s', $_ttc), 1), 'Static1') If @error Then $Static = 'Static2' EndIf $bttxtbj = 1 EndIf If $_Cflag = 0 Then $_title1 = StringRegExpReplace($_title, "%s", StringFormat('%03s', $_ttc - $_ibj + 1), 1) $_title2 = StringRegExpReplace($_title, "%s", StringFormat('%03s', $_ttc - $_ibj), 1) WinSetTitle($_title1, $_text, $_title2) ElseIf $_Cflag = 1 Then $_text1 = StringRegExpReplace($_text, "%s", StringFormat('%03s', $_ttc - $_ibj + 1), 1) $_text2 = StringRegExpReplace($_text, "%s", StringFormat('%03s', $_ttc - $_ibj), 1) ControlSetText($_title, $_text1, $Static, $_text2) ElseIf $_Cflag = 2 Then ControlSetText($_title, $_text, $CtrlF, $bttxt & StringFormat(' %03s', $_ttc - $_ibj)) EndIf If $_ibj = $_ttc Then If $_Cflag = 0 Then $_title = $_title2 If $_Cflag = 1 Then $_text = $_text2 DllClose($TimerDLL) DllCallbackFree($Timer) ControlClick($_title, $_text, $CtrlF, '', 2) EndIf $_ibj += 1 EndIf EndFunc ;==>Timer ;=========================================================================================end Edited December 5, 2009 by netegg Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now