Twml Posted January 28, 2017 Share Posted January 28, 2017 Im wondering how to open a MsgBox i have with a button that i have Here is the button displaying line: $idToS = GUICtrlCreateButton("Click Me", 180, 10, 280, 20) and my MsgBox line: $iMessage = MsgBox(1,"title","line 1" & @CRLF & "" & @CRLF & "line 2" & @CRLF & "line 3") right now the main box just opens and the msgbox gets opened with it, how can i make the msgbox stay closed until the button is clicked? Link to comment Share on other sites More sharing options...
water Posted January 28, 2017 Share Posted January 28, 2017 Welcome to AutoIt and the forum! Could you please post the whole script? Helps us to help you My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Twml Posted January 28, 2017 Author Share Posted January 28, 2017 Here is my full Au3 file right now both boxes open when the script is run, i want the msgbox to only open when button is clicked that is at top of the main window. Im new to AutoIT, this is a example script that comes with autoit that i changed a bit to add more info but now i cant get this button to work file.au3 Link to comment Share on other sites More sharing options...
careca Posted January 29, 2017 Share Posted January 29, 2017 expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Opt("GUICoordMode", 2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) GUICreate("Parent1") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUICtrlCreateButton("OK", 10, 30, 50) GUICtrlSetOnEvent(-1, "OKPressed") GUICtrlCreateButton("Cancel", 0, -1) GUICtrlSetOnEvent(-1, "CancelPressed") GUISetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) WEnd EndFunc ;==>Example Func OKPressed() MsgBox($MB_SYSTEMMODAL, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>OKPressed Func CancelPressed() MsgBox($MB_SYSTEMMODAL, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) EndFunc ;==>CancelPressed Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE MsgBox($MB_SYSTEMMODAL, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE MsgBox($MB_SYSTEMMODAL, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Case @GUI_CtrlId = $GUI_EVENT_RESTORE MsgBox($MB_SYSTEMMODAL, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) EndSelect EndFunc ;==>SpecialEvents From help file example Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
nitekram Posted January 29, 2017 Share Posted January 29, 2017 (edited) In your While loop, you need to look for that button press, so: Case $iMsg = $idToS $iMessage = MsgBox(1,"title","line 1" & @CRLF & "" & @CRLF & "line 2" & @CRLF & "line 3") EDIT I looked at your code, and I think you might want to start with the basics, as you are using DIM for a regular variable, they are reserved for arrays, and that message part of the code can go in the main while loop so, that if you click the click me button, then the msgbox will appear, waiting for your answer. Edited January 29, 2017 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Twml Posted January 29, 2017 Author Share Posted January 29, 2017 @nitekram added what you said and it does open when clicking button, but now when clicking ok on the popup closes the whole thing not just the msgbox this will work but i would like for ok on the msgbox to not close the whole thing if possible here is what i changed on my original with that you I originally wrote this all to work in mshta and it did but mshta is just buggy when used on different os then wrote on usually, so tried something new, if i keep using autoit i will definitially learn it from ground up, im just trying to Frankenstein this together for now so it does what i want it to. closer then i once was. While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $idToS $iMessage = MsgBox(1,"title","line 1" & @CRLF & "" & @CRLF & "line 2" & @CRLF & "line 3") ExitLoop Case Else ;;; EndSelect WEnd Link to comment Share on other sites More sharing options...
Twml Posted January 29, 2017 Author Share Posted January 29, 2017 Cant seem to find edit button for my last reply, but i got it to work now without closing the whole thing. Thank you all issue solved. 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