Jump to content
Sign in to follow this  
snowreaper03

getting a bot to open a minimized window?

Recommended Posts

snowreaper03

hey im trying to make something that opens a minimized window to full screen but how do u get it to pick the right minimized window?

Share this post


Link to post
Share on other sites
AutoChris

hey im trying to make something that opens a minimized window to full screen but how do u get it to pick the right minimized window?

<{POST_SNAPBACK}>

From the Help File

WinSetState ( "title", "text", flag )

Parameters

title The title of the window to show.

text The text of the window to show.

flag The "show" flag of the executed program:

@SW_HIDE = Hide window

@SW_SHOW = Shows a previously hidden window

@SW_MINIMIZE = Minimize window

@SW_MAXIMIZE = Maximize window

@SW_RESTORE = Undoes a window minimization or maximization

@SW_DISABLE = Disables the window

@SW_ENABLE = Enables the window

Share this post


Link to post
Share on other sites
Rece

hey im trying to make something that opens a minimized window to full screen but how do u get it to pick the right minimized window?

I'm trying the same but WinSetState() or WinActivate() doesn't work on a minimized window... I can't "open" it...

Share this post


Link to post
Share on other sites
GrungeRocker

I'm trying the same but WinSetState() or WinActivate() doesn't work on a minimized window... I can't "open" it...

winsetstate is working all fine on an minimized window oO

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites
Rece

winsetstate is working all fine on an minimized window oO

Not for me... :lmao:

I tryed these but nothing happens after minimizing all:

WinMinimizeAll()
Sleep(3000)
WinActivate("Total Commander")

WinMinimizeAll()
Sleep(3000)
WinSetState("Total Commander", "", @SW_RESTORE)

If the Total Commander window is not minimized but is not on top then WinActivate works. But if it is minimized then not...

Share this post


Link to post
Share on other sites
rambo3889

I think this will work:

Winsetstate("Total Commander","",@SW_MAXIMIZE)


My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youÂ’re the best in town Fight!

Share this post


Link to post
Share on other sites
Rece

I think this will work:

Winsetstate("Total Commander","",@SW_MAXIMIZE)

No... :lmao:

...and I don't want to maximize the window. It can be not maximized and I only want to "open" it but not change its size...

Edited by Rece

Share this post


Link to post
Share on other sites
GrungeRocker

well but it should work all fine oO

maybe it's a bug or you made an syn.-error or something....


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites
Rece

well but it should work all fine oO

maybe it's a bug or you made an syn.-error or something....

I tryed it with several of the latest betas and on both Win2K and WinXP...

How do you mean "syn.-error"? This 3 lines are the full code...

Edited by Rece

Share this post


Link to post
Share on other sites
SmOke_N

Sometimes theres an error in the Title (some people leave out a space or something non-trivial and spend an eternity trying to figure that out from the autoinfo tool)....

Try this code exactly like this: (I am assuming that your title is correct to you)

Opt('WinTitleMatchMode', 2)
WinMinimizeAll()
Sleep(3000)
WinSetState('Total Commander', '', @SW_RESTORE)

Edit:

To Test this theory run this code with this window open:

If you are using FireFox:

WinMinimizeAll()
Sleep(2000)
WinSetState('etting a bot to open a minimized window? - AutoIt Forums - Mozilla Firefox', '', @SW_RESTORE)

If WinActive('etting a bot to open a minimized window? - AutoIt Forums - Mozilla Firefox') Then MsgBox(0, 'Active', 'My theory sucks')

Opt('WinTitleMatchMode', 2)
WinMinimizeAll()
Sleep(2000)
WinSetState('etting a bot to open a minimized window? - AutoIt Forums - Mozilla Firefox', '', @SW_RESTORE)

If you are using IE:

WinMinimizeAll()
Sleep(2000)
WinSetState('etting a bot to open a minimized window? - AutoIt Forums - Microsoft Internet Explorer', '', @SW_RESTORE)

If WinActive('etting a bot to open a minimized window? - AutoIt Forums - Mozilla Firefox') Then MsgBox(0, 'Active', 'My theory sucks')

Opt('WinTitleMatchMode', 2)
WinMinimizeAll()
Sleep(2000)
WinSetState('etting a bot to open a minimized window? - AutoIt Forums - Microsoft Internet Explorer', '', @SW_RESTORE)

Notice I left off the 'g' at the beginning of the title.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Rece

Thanks a lot! The problem is the following: there is a visible window with title "Total Commander 6.53 - ~company name~" but there is an invisible window too with title "Total Commander"... ;)

WinMinimizeAll()
Sleep(2000)
WinSetState('Total Commander 6.53', '', @SW_RESTORE)
^^^ This is working.

Here is my script I want to use this function in. (The script watches that there is a running process of Total Commander or not and if it is running then activates its window...) I corrected it and now it's working:

Func Tiltas( $ExeUt )
    If $alapb[5][1] = "0" Then
        $wintitle = 0
        $hatar = StringInStr( $ExeUt, "\", 0, -1 )
        $ExeNev = StringRight( $ExeUt, ( StringLen( $ExeUt ) - $hatar ) )
        $colProcesses = $objWMIService.ExecQuery( "Select * from Win32_Process Where Name = '" & $ExeNev & "'")
        For $objProcess in $colProcesses
            If $hatar = 0 Then
                $objpath = $ExeUt
            Else
                $objpath = $objProcess.ExecutablePath
            EndIf
            If ( $objProcess.GetOwner(@UserName) = 0 ) And ( $objpath = $ExeUt ) Then
                $PID = $objProcess.ProcessID
                $ProcList = WinList()
                For $i = 1 To $ProcList[0][0]
                    If BitAnd( WinGetState( $ProcList[$i][0] ), 2 ) And( $ProcList[$i][0] <> "" ) _
                       And ( StringLeft( $ProcList[$i][0], 7 ) <> "TRd ww:" ) Then
                        If WinGetProcess( $ProcList[$i][0] ) = $PID Then
                            Return( $ProcList[$i][0] ); return the window title
                        EndIf
                    EndIf
                Next
                Return Chr(149); ("") - the program is running but we can't find the window
            EndIf
        Next
    EndIf
    Return ""; the program is not running
EndFunc

;...

$tiltas = Tiltas( "c:\program files\totalcmd\totalcmd.exe" )
Select
    Case $tiltas = ""
; we do something (run the program)
    Case $tiltas = Chr(149)
; we do something (e.g. error message)
    Case Else
; we activate the window - this is interesting now
        WinActivate( $tiltas )
;MsgBox(0,'debug',$tiltas)
EndSelect

The solution is this line:

If BitAnd( WinGetState( $ProcList[$i][0] ), 2 ) And( $ProcList[$i][0] <> "" ) And ( StringLeft( $ProcList[$i][0], 7 ) <> "TRd ww:" ) Then;...

If I don't use BitAnd( WinGetState( $ProcList[$i][0] ), 2 ) then it doesn't work because the window title belongs to the invisible (hidden) window... :lmao:

Edit:

You need this to work correctly:

Opt("WinTitleMatchMode", 3); Exact match
Edited by Rece

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×