supraspecies Posted July 23, 2015 Share Posted July 23, 2015 OK, here's the problem I'm encountering. Sometimes when my script calls up a message after the installation of some program, the message appears in the background rather than foreground. I'm not clicking on any windows (I'm not doing any clicking at all) and it doesn't matter whether I use simple MsgBox or GUI. It happens rarely, but it happens. I know I can use TopMost attribute, I know I can use WinSetActive, but that's not what I'm asking here. The only thing I want to know is whether it's an AutoIt bug, or Windows' bug. I just want to find the cause for this issue. Personally, I suspect it's something in Windows.OS: Windows 7 SP1 x64. Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2015 Share Posted July 23, 2015 It's more likely to be a script bug. 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...
Developers Jos Posted July 23, 2015 Developers Share Posted July 23, 2015 Not sure what you are considering as a bug as any other window can be create or setting it's attribute to TopMost.So what exactly would you expect from a plain MsgBox()?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
supraspecies Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) @ JohnOneIt's doubtful that it's a script bug, as it happens only sometimes, and where would that bug be if all I do is call an MsgBox like MsgBox(0,'','').@ JosYeah, any window can be TopMost, but that doesn't explain why would my MsgBox appear behind an already existing window which is not set as TopMost. Specifically, behind a simple open folder window. Edited July 23, 2015 by supraspecies Link to comment Share on other sites More sharing options...
tweakster2010 Posted July 23, 2015 Share Posted July 23, 2015 I've seen this but its normally as msgbox or UAC is prompting for me while im clicking onto another screen and at work I use W7 Sp1 32 and 64 so I dont think its an OS bug. I would definitely agree its odd behavior though. I just learned to stop clicking when I know a box is due to come and my issue doesn't happen. Maybe some more details onto what the entirety of a script that does that might help maybe spot a line or something causing it? Link to comment Share on other sites More sharing options...
supraspecies Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) @ tweakster2010 Afraid that's not it then, as I wasn't doing any clicking when I've seen this behavior. And my UAC is off. Here is the whole script. It's a wrapper for the installer of software called "Tunngle". My script pre-installs my settings, custom GUI skin for Tunngle and bypasses some annoying messages during installation:expandcollapse popup#notrayicon #include <Misc.au3> #include <Process.au3> _Singleton("Tunngle Installer", 0) $var1 = RegRead('HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tunngle_is1', 'InstallLocation') If $var1="" then $var1 = RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tunngle_is1', 'InstallLocation') EndIf If ProcessExists ('tunngle.exe') Or ProcessExists ('TnglCtrl.exe') Then $msg = MsgBox (16, "Setup", "Tunngle is still running. Please shut it down before proceeding with installation.") Exit EndIf RegWrite("HKCU\Software\Tunngle.net\Tunngle", "Skin", "REG_SZ", "Tunngle HD") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "PlaySound", "REG_DWORD", "0") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFV_ClientClose", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFV_ExternalLink", "REG_DWORD", "0") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFV_NewVersion", "REG_DWORD", "0") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SB_Register", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFVB_LifetimeOffer1", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFVB_LifetimeOffer2", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFV_ZoneFW", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SB_JoinNet", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFV_WizardStartup", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SAFV_WizardBeforeLogin", "REG_DWORD", "1") RegWrite("HKCU\Software\Tunngle.net\Tunngle", "SortNicks", "REG_DWORD", "1") DirCreate(@tempdir & "\Tunngle_Setup") DirCreate(@DocumentsCommonDir & "\Tunngle\Skins") DirCreate(@DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD") DirCreate(@AppDataDir & "\Tunngle") FileInstall("cfg_13080811.ini", @AppDataDir & "\Tunngle\cfg_13080811.ini") FileInstall("Tunngle HD.cfg", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD.cfg") FileInstall("Tunngle HD.skf", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD.skf") FileInstall("Tunngle HD.skn", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD.skn") FileInstall("Tunngle HD\findex_ico_button.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\findex_ico_button.bmp") FileInstall("Tunngle HD\ico_mute.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\ico_mute.bmp") FileInstall("Tunngle HD\ico_soundon.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\ico_soundon.bmp") FileInstall("Tunngle HD\msg_ico_group_closed.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\msg_ico_group_closed.bmp") FileInstall("Tunngle HD\msg_ico_group_empty.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\msg_ico_group_empty.bmp") FileInstall("Tunngle HD\msg_ico_group_opened.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\msg_ico_group_opened.bmp") FileInstall("Tunngle HD\qbutton_blog.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_blog.bmp") FileInstall("Tunngle HD\qbutton_events.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_events.bmp") FileInstall("Tunngle HD\qbutton_facebook.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_facebook.bmp") FileInstall("Tunngle HD\qbutton_favorite.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_favorite.bmp") FileInstall("Tunngle HD\qbutton_forum.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_forum.bmp") FileInstall("Tunngle HD\qbutton_google+.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_google+.bmp") FileInstall("Tunngle HD\qbutton_home.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_home.bmp") FileInstall("Tunngle HD\qbutton_lobby.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_lobby.bmp") FileInstall("Tunngle HD\qbutton_privnet.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_privnet.bmp") FileInstall("Tunngle HD\qbutton_twitter.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_twitter.bmp") FileInstall("Tunngle HD\qbutton_youtube.bmp", @DocumentsCommonDir & "\Tunngle\Skins\Tunngle HD\qbutton_youtube.bmp") FileInstall("Tunngle_Setup.exe", @TempDir & "\Tunngle_Setup\Tunngle_Setup.exe", 1) ShellExecute(@tempdir & "\Tunngle_Setup\Tunngle_Setup.exe", "/NORESTART", @tempdir & "\Tunngle_Setup") WinWait("[TITLE:Select Setup Language; CLASS:TSelectLanguageForm]","Select the language to use during the installation") ControlClick("[TITLE:Select Setup Language; CLASS:TSelectLanguageForm]","Select the language to use during the installation","TNewButton1") WinWait("[TITLE:Setup; CLASS:#32770]","Creating a Windows System Restore Point") ControlClick("[TITLE:Setup; CLASS:#32770]","Creating a Windows System Restore Point","[ID:7]") WinWait("[TITLE:Setup - Tunngle; CLASS:TWizardForm]","Welcome to the Tunngle Setup Wizard") ControlClick("[TITLE:Setup - Tunngle; CLASS:TWizardForm]","Welcome to the Tunngle Setup Wizard","TNewButton1") WinWait("[TITLE:Setup; CLASS:#32770]","Would you like setup to check if a newer version") ControlClick("[TITLE:Setup; CLASS:#32770]","Would you like setup to check if a newer version","[ID:7]") WinWait("[TITLE:Setup - Tunngle; CLASS:TWizardForm]","How should Tunngle be installed?") ControlDisable("[TITLE:Setup - Tunngle; CLASS:TWizardForm]","How should Tunngle be installed?","TNewButton1") ProcessWaitClose('Tunngle_Setup.exe') $var2 = RegRead('HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tunngle_is1', 'InstallLocation') If $var2="" then $var2 = RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tunngle_is1', 'InstallLocation') EndIf If $var2 == "" Then DirRemove(@DocumentsCommonDir & "\Tunngle\Skins", 1) DirRemove(@DocumentsCommonDir & "\Tunngle") DirRemove(@AppDataDir & "\Tunngle", 1) RegDelete("HKCU\Software\Tunngle.net\Tunngle") RegEnumKey ('HKCU\Software\Tunngle.net', 1) $nokeys=(@error=-1) RegEnumVal ('HKCU\Software\Tunngle.net', 1) $novalues=(@error=-1) If $nokeys And $novalues Then RegDelete ('HKCU\Software\Tunngle.net') Else ShellExecute($var2 & '\Tunngle.exe', '', $var2) EndIf EndIf If $var1='' And $var2<>'' Then $msg = MsgBox (68, "Tunngle Setup", "To complete the installation of Tunngle, your computer must be restarted." & @CRLF & @CRLF & "Would you like to restart now?") IF $msg=6 then Shutdown(2) EndIf EndIf The very last part of the script. It doesn't really have a direct connection to anything else, that's why I didn't post the whole script. As I said, I've seen this behavior multiple times in various different scripts of mine. Edited July 23, 2015 by supraspecies Link to comment Share on other sites More sharing options...
MilesAhead Posted July 23, 2015 Share Posted July 23, 2015 I can remember that happening to me a lot when programming using MFC. The messagebox would display but it was behind the application window. It happened often enough that I made my messageboxes System Modal. supraspecies 1 My Freeware Page Link to comment Share on other sites More sharing options...
kylomas Posted July 24, 2015 Share Posted July 24, 2015 (edited) supraspecies,By default MSGBOX is modal (I believe) so I suspect a timing issue. The solution from MilesAhead should solve your problem.Here is a discussion of dialog box types.kylomas Edited July 24, 2015 by kylomas clarification supraspecies 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
supraspecies Posted July 24, 2015 Author Share Posted July 24, 2015 Yes, System Modal bypasses that issue, thank you, MilesAhead. And thanks kylomas for more insight on this, it explains a lot. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 24, 2015 Share Posted July 24, 2015 You should add the $MB_SYSTEMMODAL value to it to make sure it's set to TOPMOSTMB_SYSTEMMODAL0x00001000LSame as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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