VAN0 Posted March 7, 2014 Share Posted March 7, 2014 (edited) Why doesn't the following work?1. Compile a GUI program to exe2. Create a shortcut to the compiled GUI program3. Right-click shortcut and do (Run: Minimized)4. Run the shortcut and the program should run initially minimizedHere is an example GUI program (using AutoIt3 beta v3.1.1.124): #include <GUIConstants.au3> $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Button1 = GUICtrlCreateButton("AButton1", 152, 80, 209, 41) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEndIs this possible in AutoIt?Livewire Just add a GUISetState(@SW_MINIMIZE) after the GUISetState(@SW_SHOW)You need to show first unless the minmize will be rejected. How do I make the code recognize that the "user" selected Run minimize from Windows (Right-click: Run Minimized)? Any ideas? Thank you. Edited March 7, 2014 by VAN0 Link to comment Share on other sites More sharing options...
BrewManNH Posted March 7, 2014 Share Posted March 7, 2014 You could use a combination of ProcessExists to see if the program is running, and then use WinGetState to see if it's minimized. 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...
VAN0 Posted March 7, 2014 Author Share Posted March 7, 2014 You could use a combination of ProcessExists to see if the program is running, and then use WinGetState to see if it's minimized. I think you misunderstood the question. I'm trying start the compiled script itself minimized if it was started via shortcut with "run minimized" option selected: Link to comment Share on other sites More sharing options...
BrewManNH Posted March 7, 2014 Share Posted March 7, 2014 I understood what you posted, maybe you should have asked what you wanted to do. Your post quoted someone asking how to detect that it was started minimized, that's the answer I gave you. The question you asked in your second post was answered in your first post, use GUISetState(@SW_MINIMIZED). 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...
VAN0 Posted March 7, 2014 Author Share Posted March 7, 2014 GUISetState(@SW_MINIMIZE) will minimize the window regardless of how it was started with or without "run minimized" option Link to comment Share on other sites More sharing options...
Bert Posted March 7, 2014 Share Posted March 7, 2014 create your exe with command line switch support. You can then specify the shortcut to run the EXE the way you want. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
VAN0 Posted March 7, 2014 Author Share Posted March 7, 2014 create your exe with command line switch support. You can then specify the shortcut to run the EXE the way you want. Yes, that's a one way to go. Or store settings in registry or .ini file. But all this is a work arou So there is no way within AU3 catch with what options the script was started? Link to comment Share on other sites More sharing options...
BrewManNH Posted March 7, 2014 Share Posted March 7, 2014 So, what exactly is it that you need? Do you need to detect that it was started minimized, do you need to start it minimized, do you need to create a shortcut that starts it minimized? I have no clue what it is you're looking for because you've given 3 different answers so far. if you need to detect if it was started minimized, use my answer, if you need to start it minimized use the answer in your first post and my second reply, if you need to create a shortcut to start it minimized use FileCreateShortCut, if you need to find out if the shortcut is set to start it minimized use FileGetShortCut. If none of these solutions fit what you think you're asking, then obviously you need to be a LOT clearer in asking the right question. 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...
VAN0 Posted March 7, 2014 Author Share Posted March 7, 2014 (edited) The original post has perfectly explained the question.So, let me chew it to a fine paste for you from the very beginning:having a simple script with GUI compiled into example.exe:#include <GUIConstants.au3> $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Button1 = GUICtrlCreateButton("AButton1", 152, 80, 209, 41) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEndWhen example.exe executed directly, a window showed on screen = GOOD, just as expected.Right click on example.exe and select "Create shortcut". You should see a new file created "example.exe - Shortcut", if you don't see that file you might need do folder refreshRight click on the new file example.exe - Shortcut and go to propertiesOn top of the properties window are several tabs, click on the one with name "Shortcut" in itFind a row with "Run:" and a dropdown menu next to it, select "Minimized" in the dropdown menuClick "Ok" buttonDouble click on example.exe - Shortcut file, a normal, not minimized, window showed on screen = NOT GOOD, because from user's point of view it was expected to be started minimizedWhat do I need to add to the code to make window show on screen (start normal) when example.exe executed directly and start minimized when it's started via shortcut with "run minimized" option?So if you still believe that both of your "solutions" are valid solutions for this question, would you mind, please, make a working example? Thank you. Edited March 7, 2014 by VAN0 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2014 Moderators Share Posted March 8, 2014 VAN0,Interesting - that shortcut selection does not appear to work for AutoIt exes (and Google tells me that they are not alone in this). There might be a way to detect from the registry that this setting has been made, but why go to all that trouble? MBALZESHARI had the right idea - the problem can be solved easily by using the commandline like this: #include <GUIConstantsEx.au3> $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Button1 = GUICtrlCreateButton("AButton1", 152, 80, 209, 41) ; Check if there was a command line parameter passed to the exe If $CMDLINE[0] And $CMDLINE[1] = "-min" Then GUISetState(@SW_SHOWMINIMIZED) Else GUISetState(@SW_SHOW) EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEndNow adding -min after the calling path in the shortcut properties will start the app minimized. And you can test it in SciTE by using the Shft-F8 shortcut or the <View - Parameters> menu item. M23P.S. The original post has perfectly explained the questionEvidently it did not - as shown by the responses. Remember that the message is what is understood by the recipient, not the sender. And we are all volunteers here, so getting ratty is just likely to drive people away. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Zedna Posted March 13, 2014 Share Posted March 13, 2014 Look at this my example '?do=embed' frameborder='0' data-embedContent>> Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Solution johnmcloud Posted March 13, 2014 Solution Share Posted March 13, 2014 (edited) Me = 1 vs MVPs/Mod = 0, this time and maybe only this time i have the ANSWER Yeah is not a competition but it is a satisfaction expandcollapse popup;~ ;johnmcloud - 2014 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ;~ Global Const $tagSTARTUPINFO = "int Size;ptr Reserved1;ptr Desktop;ptr Title;int X;int Y;int XSize;int YSize;int XCountChars;" & _ ;~ "int YCountChars;int FillAttribute;int Flags;short ShowWindow;short Reserved2;ptr Reserved3;int StdInput;" & _ ;~ "int StdOutput;int StdError" Global $sState = @SW_SHOW Global $sShortcut = _RunFromShortcut() If IsArray($sShortcut) Then If $sShortcut[6] = 3 Then $sState = @SW_SHOWMAXIMIZED If $sShortcut[6] = 7 Then $sState = @SW_SHOWMINIMIZED EndIf $hGUI = GUICreate("Johnmcloud knows best", 265, 250, -1, -1, $WS_MAXIMIZEBOX) _WinAPI_ShowWindow($hGUI, $sState) ;@SW_SHOWMAXIMIZED with GUISetState not work While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _RunFromShortcut() Local $tSI = DllStructCreate($tagSTARTUPINFO) DllCall('kernel32.dll', 'none', 'GetStartupInfoW', 'struct*', $tSI) If @error Then Return SetError(@error, @extended, 0) Local $vFlag = DllStructGetData($tSI, 'Flags') If BitAND($vFlag, 0x800) Then Local $sTitle = DllStructCreate('wchar ShortcutPath[261]', DllStructGetData($tSI, 'Title')) Local $sShortcutPath = DllStructGetData($sTitle, 'ShortcutPath') If $sShortcutPath Then Return FileGetShortcut($sShortcutPath) Else Return SetError(1, 0, 0) EndIf Else Return SetError(2, 0, 0) EndIf EndFunc ;==>_Shortcut Edited March 13, 2014 by johnmcloud VAN0 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2014 Moderators Share Posted March 13, 2014 johnmcloud,Well done! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
johnmcloud Posted March 13, 2014 Share Posted March 13, 2014 (edited) Thanks Melba Since I'm here, do you know why this work: _WinAPI_ShowWindow($hGUI, @SW_SHOWMAXIMIZED) But this not? GUISetState(@SW_SHOWMAXIMIZED, $hGUI) With GuiSetState i don't see nothing... The help say: "When windows are created they are initially hidden so you must use this function to display them (@SW_SHOW)" But @SW_SHOWMAXIMIZED isn't like @SW_SHOW + @SW_MAXIMIZED both in the same @MACRO? The curious thing is this work: GUISetState(@SW_SHOWMINIMIZED, $hGUI) Minimize yes, maximize not Edited March 13, 2014 by johnmcloud Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2014 Moderators Share Posted March 13, 2014 johnmcloud,I have come across this problem with GUISetState before. KaFu pointed out that the occasional failures of my GUIFrames UDF were caused by using GUISetState instead of _WinAPI_ShowWindow (or WinSetState). But I once had an exchange with trancexx when she was still a Dev and she was most insistent that AutoIt GUIs should use GUISetState - although as often the case she was not very forthcoming about exactly why so I cannot pass on any insight. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
johnmcloud Posted March 13, 2014 Share Posted March 13, 2014 I think tomorrow i'll open a new thread about this matter in dev section, just for understand why internal function work with minimize but not with maximize. Thanks 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