abdulrahmanok Posted October 16, 2016 Share Posted October 16, 2016 (edited) Hi brothers , All I need is show msgbox evey 1 hour or 30 min The problem is when i try to do this : while 1 msgbox(0,"Example","Every 30 min ) sleep(300000) wend All Buttons in Gui stopped working for 30 min also ! solved : Thanks To : @Nikolas92 @Muhammad_Awais_Sharif Edited October 16, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
Nikolas92 Posted October 16, 2016 Share Posted October 16, 2016 use guictrlsetonevent or buttons instead of guigetmsg Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 2 minutes ago, Nikolas92 said: use guictrlsetonevent or buttons instead of guigetmsg Thank you for Response .. but how to do this Link to comment Share on other sites More sharing options...
Nikolas92 Posted October 16, 2016 Share Posted October 16, 2016 https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetOnEvent.htm Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 16, 2016 Share Posted October 16, 2016 from help file #include <MsgBoxConstants.au3> If ProcessExists("SciTE.exe") = 0 Then MsgBox($MB_SYSTEMMODAL, "", "You will need SciTE.exe to be running for ConsoleWrite to display.") EndIf Example() Func Example() ; Register the function MyAdLibFunc() to be called every 250ms (default). AdlibRegister("MyAdLibFunc") ; Sleep does not stop AdLib functions from running. Sleep(1000) ; AdLib functions don't run while a blocking function is shown e.g. MsgBox, InputBox, WinWait, WinWaitClose etc. MsgBox($MB_SYSTEMMODAL, "", "No console message(s) will be shown whilst the messagebox is displayed.") ; The AdLib function MyAdLibFunc() will start again. Sleep(2000) ; Unregister the function MyAdLibFunc() from being called every 250ms. AdlibUnRegister("MyAdLibFunc") EndFunc ;==>Example Func MyAdLibFunc() ; Assign a static variable to hold the number of times the function is called. Local Static $iCount = 0 $iCount += 1 ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF) EndFunc ;==>MyAdLibFunc Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 5 minutes ago, Nikolas92 said: https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetOnEvent.htm Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $day1 day1() Case $calc Calc() Case $List2 List() Case $Clear Clear() Case $MyBanner banner2() case $day2 day2() GUICtrlSetOnEvent("",notice()) EndSwitch WEnd Didn't work Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 16, 2016 Share Posted October 16, 2016 another example AdlibRegister("myfunction",1000) ;call after one second you can set your time ;here your regular code While 1 Sleep(100) WEnd Func myfunction() ConsoleWrite("myfunction is called " & @CRLF) EndFunc Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 4 minutes ago, Muhammad_Awais_Sharif said: from help file #include <MsgBoxConstants.au3> If ProcessExists("SciTE.exe") = 0 Then MsgBox($MB_SYSTEMMODAL, "", "You will need SciTE.exe to be running for ConsoleWrite to display.") EndIf Example() Func Example() ; Register the function MyAdLibFunc() to be called every 250ms (default). AdlibRegister("MyAdLibFunc") ; Sleep does not stop AdLib functions from running. Sleep(1000) ; AdLib functions don't run while a blocking function is shown e.g. MsgBox, InputBox, WinWait, WinWaitClose etc. MsgBox($MB_SYSTEMMODAL, "", "No console message(s) will be shown whilst the messagebox is displayed.") ; The AdLib function MyAdLibFunc() will start again. Sleep(2000) ; Unregister the function MyAdLibFunc() from being called every 250ms. AdlibUnRegister("MyAdLibFunc") EndFunc ;==>Example Func MyAdLibFunc() ; Assign a static variable to hold the number of times the function is called. Local Static $iCount = 0 $iCount += 1 ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF) EndFunc ;==>MyAdLibFunc This example uses "sleep" witch stop GUI functions Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 16, 2016 Share Posted October 16, 2016 try this one Link to comment Share on other sites More sharing options...
Nikolas92 Posted October 16, 2016 Share Posted October 16, 2016 #include <GUIConstantsEx.au3> Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $day1 = GUICtrlCreateButton("OK", 10, 30, 50) GUICtrlSetOnEvent($day1, "OKPressed") $calc = GUICtrlCreateButton("Cancel", 0, -1) GUICtrlSetOnEvent($calc, "CancelPressed") ... while 1 sleep(10) wend func .. endfunc Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 8 hours ago, Muhammad_Awais_Sharif said: try this one Sorry but i dont even now how to try this 8 hours ago, Nikolas92 said: #include <GUIConstantsEx.au3> Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $day1 = GUICtrlCreateButton("OK", 10, 30, 50) GUICtrlSetOnEvent($day1, "OKPressed") $calc = GUICtrlCreateButton("Cancel", 0, -1) GUICtrlSetOnEvent($calc, "CancelPressed") ... while 1 sleep(10) wend func .. endfunc I will try this ty 8 hours ago, Nikolas92 said: #include <GUIConstantsEx.au3> Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $day1 = GUICtrlCreateButton("OK", 10, 30, 50) GUICtrlSetOnEvent($day1, "OKPressed") $calc = GUICtrlCreateButton("Cancel", 0, -1) GUICtrlSetOnEvent($calc, "CancelPressed") ... while 1 sleep(10) wend func .. endfunc do you mean somtheing like this ? #include <GUIConstantsEx.au3> Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $day1 = GUICtrlCreateButton("OK", 10, 30, 50) GUICtrlSetOnEvent($day1, "OKPressed") $calc = GUICtrlCreateButton("Cancel", 0, -1) GUICtrlSetOnEvent($calc, "CancelPressed") while 1 sleep(10) wend try() func try() MsgBox(0,"Try","its try") endfunc because its not showing any Gui or anything! Sorry guys but I tried most of this ways before create this post. Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 16, 2016 Share Posted October 16, 2016 here is example expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include 'authread.au3' _AuThread_Startup() Opt("GUIOnEventMode", 1) Global $i = 1; Global $hThread #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("test", 615, 437, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") Local $Button1 = GUICtrlCreateButton("start msg after every 5 Second", 336, 24, 211, 57) GUICtrlSetOnEvent($Button1, "startMsgProcess") Local $Button2 = GUICtrlCreateButton("increment value", 40, 16, 195, 97) GUICtrlSetOnEvent($Button2, "Button2Click") Local $Button3 = GUICtrlCreateButton("stop msg", 336, 124, 211, 57) GUICtrlSetOnEvent($Button3, "stopmsgprocess") Local $Edit1 = GUICtrlCreateEdit("", 40, 128, 241, 201) GUICtrlSetData($Edit1, "Edit1") GUICtrlSetOnEvent($Edit1, "Edit1Change") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func ShowMsg() While True Sleep(5 * 1000) MsgBox(0,"test","Msg from an other script") WEnd EndFunc Func startMsgProcess() ConsoleWrite("called") $hThread = _AuThread_StartThread("ShowMsg") EndFunc Func stopmsgprocess() _AuThread_CloseThread($hThread) EndFunc Func Button2Click() GUICtrlSetData($Edit1,$i) $i = $i + 1 EndFunc Func Edit1Change() EndFunc Func Form1Close() Exit EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Link to comment Share on other sites More sharing options...
Nikolas92 Posted October 16, 2016 Share Posted October 16, 2016 #NoTrayIcon #include <GUIConstantsEx.au3> Opt("WinTitleMatchMode", 3) Opt('GUIOnEventMode', 1) Global $g_hForm = GUICreate('', 223, 185, @DesktopWidth/2, @DesktopHeight/2) $Button1 = GUICtrlCreateButton('OK', -1, 163, 124, 23) $Button2 = GUICtrlCreateButton('Cancel', 121, 163, 101, 23) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') GUICtrlSetOnEvent($Button1, '_try') GUICtrlSetOnEvent($Button2, '_try') GUISetState(@SW_SHOW) While 1 ; show msgbox every 30 minutes sleep(300000) msgbox(0,"Example","Every 30 min") WEnd Func _try() If @GUI_CtrlId = $Button1 Then msgbox(0, '', 'Pressed button ' & GUICtrlRead($Button1)) ElseIf @GUI_CtrlId = $Button2 Then msgbox(0, '', 'Pressed button ' & GUICtrlRead($Button2)) EndIf EndFunc Func _Exit() If @GUI_CtrlId = $GUI_EVENT_CLOSE Then Exit EndFunc Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 @Nikolas92 @Muhammad_Awais_Sharif Ty all For your efforts Both of your examples are working like i want the last problem that ( because I'm totatlly noob ) I can't make it working with my script this is full code : expandcollapse popupGUICtrlSetOnEvent($MyBanner, '_Start') ; This is my Try " $MyBanner " is Variable from Gui GUICtrlSetOnEvent($calc, '_Start') GUISetState(@SW_SHOW) func _start() ConsoleWrite("Hallo !" & @CRLF) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $MyGui) GUISetState(@SW_SHOW, $MyGui) notice() #endregion Code $opennew = @ScriptDir & "/WriteToTx.txt" Local $readOne = FileReadLine($opennew, 1) Local $read2 = FileReadLine($opennew, 2) Local $read3 = FileReadLine($opennew, 3) Local $read4 = FileReadLine($opennew, 4) Local $read5 = FileReadLine($opennew, 5) Local $read6 = FileReadLine($opennew, 6) $Fromchk1=ControlSetText("","",$From1,$readOne) $Fromchk2=ControlSetText("","",$From2,$read3) $Fromchk3=ControlSetText("","",$From3,$read5) $toschk1=ControlSetText("","",$to1,$read2) $toschk2=ControlSetText("","",$to2,$read4) $toschk3=ControlSetText("","",$to3,$read6) $selectDay=0 FileClose($opennew) While 1 $nMsg = GUIGetMsg() $Fromchk1=GUICtrlRead($From1) $Fromchk2=GUICtrlRead($From2) $Fromchk3=GUICtrlRead($From3) $Tochk1=GUICtrlRead($to1) $Tochk2=GUICtrlRead($to2) $Tochk3=GUICtrlRead($to3) $resault1=GUICtrlRead($resault) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $day1 day1() Case $calc Calc() Case $List2 List() Case $Clear Clear() Case $MyBanner banner2() case $day2 day2() EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 (edited) @Nikolas92 @Muhammad_Awais_Sharif BigThanks For helping me , Finally I did it after many tries This is Working Code : #include 'authread.au3' _AuThread_Startup() Func ShowMsg() While True Sleep(2 * 1000) MsgBox(0,"test","Msg from an other script") WEnd EndFunc and This To Call Func : $hThread = _AuThread_StartThread("ShowMsg") Thank You Great Teachers Edited October 16, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 16, 2016 Share Posted October 16, 2016 you are welcome great student Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 16, 2016 Author Share Posted October 16, 2016 15 minutes ago, Muhammad_Awais_Sharif said: you are welcome great student Muhammad_Awais_Sharif 1 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