Jump to content

Restore Minimized Window


Recommended Posts

I must be doing something wrong because I have searched and tried a number of different codes to restore a gui that I minimized. 

What I am trying to do is check if the window exists, and is minimized, then restore it or launch it.

Using this very similar example it works as intended: 

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()

    Local $hWnd = "Untitled - Notepad"
    Local $iState = WinGetState($hWnd)


    If BitAND($iState, $WIN_STATE_MINIMIZED) Then
        WinSetState("Untitled - Notepad","", @SW_RESTORE)
    Else
        Run("notepad.exe")
    EndIf

EndFunc   ;==>Example

Using my code it does not:

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

_lmin()
Func _lmin()
    Local $launch = "Launcher"
    Local $iState = WinGetState($launch)
    If BitAND($iState, $WIN_STATE_MINIMIZED) Then
        WinSetState("Launcher", "", @SW_RESTORE)
    Else
        _Launcher()
    EndIf
EndFunc   ;==>_lmin

The "window" is a gui that I opened and minimized.

I have tried:

GUICTRLGETSTATE / SETSTATE

WINGETSTATE / SETSTATE

WINACTIVATE / EXISTS

Edited by Daemante2018
Link to comment
Share on other sites

Right, my bad.

Reason I didn't post the code is because the functionality is not allowed here and the function/GUI itself works without issue. Its just getting it to restore if minimized when the button is pressed again.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <launchclient.au3>
#include <EditConstants.au3>

Func _Launcher($Launcher)
    $Launcher = GUICreate("Launcher", 662, 267, 649, 87)
    $PASSLEECH = GUICtrlCreateInput("Password", 360, 144, 273, 21, $ES_PASSWORD)
    GUICtrlSetTip(-1, "Password")
    GUICtrlSetCursor(-1, 5)
    $SAVEMAIN = GUICtrlCreateButton("Save", 224, 176, 75, 25)
    $SAVELEECH = GUICtrlCreateButton("Save", 560, 176, 75, 25)
    $PASSMAIN = GUICtrlCreateInput("Password", 24, 144, 273, 21, $ES_PASSWORD)
    GUICtrlSetTip(-1, "Password")
    GUICtrlSetCursor(-1, 5)
    $USERLEECH = GUICtrlCreateInput("Username", 360, 112, 273, 21, $ES_PASSWORD)
    GUICtrlSetTip(-1, "Username")
    GUICtrlSetCursor(-1, 5)
    $USERMAIN = GUICtrlCreateInput("Username", 24, 112, 273, 21, $ES_PASSWORD)
    GUICtrlSetTip(-1, "Username")
    GUICtrlSetCursor(-1, 5)
    $SHOWCRED1 = GUICtrlCreateCheckbox("Show Credentials", 24, 184, 97, 17)
    $SHOWCRED2 = GUICtrlCreateCheckbox("Show Credentials", 360, 184, 97, 17)
    $LeechText = GUICtrlCreateLabel("LEECH CLIENT", 432, 64, 138, 28)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Warning = GUICtrlCreateLabel("ONLY use ""Windowed"" mode 1920x1080!", 152, 8, 369, 28)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $MainClient = GUICtrlCreateLabel("MAIN CLIENT", 96, 64, 122, 28)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $LAMAIN = GUICtrlCreateButton("L A U N C H", 24, 216, 275, 41)
    GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xB9D1EA)
    GUICtrlSetCursor(-1, 0)
    $LALEECH = GUICtrlCreateButton("L A U N C H", 360, 216, 275, 41)
    GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xB9D1EA)
    GUICtrlSetCursor(-1, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    Global $ACCini = "accounts.ini" ;define ini file

    ;----------------------------------------------
    ;Retrieve the ASCII value of the default password char
    ;----------------------------------------------
    $DefaultUserLeech = GUICtrlSendMsg($USERLEECH, $EM_GETPASSWORDCHAR, 0, 0)
    $DefaultPassLeech = GUICtrlSendMsg($PASSLEECH, $EM_GETPASSWORDCHAR, 0, 0)
    $DefaultUserMain = GUICtrlSendMsg($USERMAIN, $EM_GETPASSWORDCHAR, 0, 0)
    $DefaultPassMain = GUICtrlSendMsg($PASSMAIN, $EM_GETPASSWORDCHAR, 0, 0)
    ;----------------------------------------------

    GUISetState(@SW_SHOW, $Launcher)
    While 1
        $nMsg = GUIGetMsg(1)
        If $nMsg[1] = $Launcher Then
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUISetState(@SW_HIDE, $Launcher)
                    ExitLoop
                Case $SHOWCRED1 ; main creds
                    If (GUICtrlRead($SHOWCRED2) = $GUI_CHECKED) Then
                        GUICtrlSendMsg($USERMAIN, $EM_SETPASSWORDCHAR, 0, 0)
                        GUICtrlSendMsg($PASSMAIN, $EM_SETPASSWORDCHAR, 0, 0)
                        GUICtrlSetData($USERMAIN, IniRead($ACCini, "Main Credentials", "Username", $USERNAMEMAIN))
                        GUICtrlSetData($PASSMAIN, IniRead($ACCini, "Main Credentials", "Password", $PASSWORDMAIN))
                    Else
                        GUICtrlSendMsg($USERMAIN, $EM_SETPASSWORDCHAR, $DefaultUserMain, 0)
                        GUICtrlSendMsg($PASSMAIN, $EM_SETPASSWORDCHAR, $DefaultPassMain, 0)
                        GUICtrlSetData($USERMAIN, IniRead($ACCini, "Main Credentials", "Username", $USERNAMEMAIN))
                        GUICtrlSetData($PASSMAIN, IniRead($ACCini, "Main Credentials", "Password", $PASSWORDMAIN))
                    EndIf
                    GUICtrlSetState($USERMAIN, $GUI_FOCUS) ;Input needs focus to redraw characters
                    GUICtrlSetState($PASSMAIN, $GUI_FOCUS) ;Input needs focus to redraw characters
                Case $SAVEMAIN
                    $USERNAMEMAIN = GUICtrlRead($USERMAIN)
                    IniWrite($ACCini, "Main Credentials", "Username", $USERNAMEMAIN)
                    $PASSWORDMAIN = GUICtrlRead($PASSMAIN)
                    IniWrite($ACCini, "Main Credentials", "Password", $PASSWORDMAIN)
                    MsgBox($MB_TOPMOST, "", "Credentials Saved!")
                Case $LAMAIN
                    _Check4Main() ;check if windows already exists then call launch
                Case $SHOWCRED2 ; leech creds
                    If (GUICtrlRead($SHOWCRED1) = $GUI_CHECKED) Then
                        GUICtrlSendMsg($USERLEECH, $EM_SETPASSWORDCHAR, 0, 0)
                        GUICtrlSendMsg($PASSLEECH, $EM_SETPASSWORDCHAR, 0, 0)
                        GUICtrlSetData($USERLEECH, IniRead($ACCini, "Leech Credentials", "Username", $USERNAMELEECH))
                        GUICtrlSetData($PASSLEECH, IniRead($ACCini, "Leech Credentials", "Password", $PASSWORDLEECH))
                    Else
                        GUICtrlSendMsg($USERLEECH, $EM_SETPASSWORDCHAR, $DefaultUserLeech, 0)
                        GUICtrlSendMsg($PASSLEECH, $EM_SETPASSWORDCHAR, $DefaultPassLeech, 0)
                        GUICtrlSetData($USERLEECH, IniRead($ACCini, "Leech Credentials", "Username", $USERNAMELEECH))
                        GUICtrlSetData($PASSLEECH, IniRead($ACCini, "Leech Credentials", "Password", $PASSWORDLEECH))
                    EndIf
                    GUICtrlSetState($USERLEECH, $GUI_FOCUS) ;Input needs focus to redraw characters
                    GUICtrlSetState($PASSLEECH, $GUI_FOCUS) ;Input needs focus to redraw characters
                Case $SAVELEECH
                    $USERNAMELEECH = GUICtrlRead($USERLEECH)
                    IniWrite($ACCini, "Leech Credentials", "Username", $USERNAMELEECH)
                    $PASSWORDLEECH = GUICtrlRead($PASSLEECH)
                    IniWrite($ACCini, "Leech Credentials", "Password", $PASSWORDLEECH)
                    MsgBox($MB_TOPMOST, "", "Credentials Saved!")
                Case $LALEECH
                    _Check4Leech() ;check if windows already exists then call launch
            EndSwitch
        EndIf
    WEnd
EndFunc   ;==>_Launcher

Edit: Just noticed that the window in question is not being focused if you click anywhere off of it.

Edited by Daemante2018
Link to comment
Share on other sites

what do you mean with "Reason I didn't post the code is because the functionality is not allowed here" ?

and lmin will never be executed because launcher is the one running.  it is working with notepad since it is a seperate process...

Link to comment
Share on other sites

  • Developers

@Daemante2018, So we tell you that a game launcher isn't allowed to be discussed here and to read our forum rules.
It appears that  forgot to read those rules as it clearly stated: 

Quote

7. Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above.

Consider this your last warning and reminder to properly read these rules.

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

  • Jos locked this topic
  • Moderators

@Daemante2018 I am going to up the ante and give you 3 days to think it over before you are able to post again, since we had a pretty lengthy conversation via PM and I expressly told you NOT to try this.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...