Jump to content

WinGetState($Window) = 16 (minimized)


nf67
 Share

Recommended Posts

Hi, since you can't WinMove() minimized windows I figured I'd restore the window first.

However, when checking if the window is minimized, this doesn't return "true".

Please take a look at the example below:

HotKeySet("h","Hide")
HotKeySet("s","Show")

;Activate a window, press "h", then press "s" again.

$Window = "[active]"

While 1
WEnd

Func Hide()
    $Window = WinGetTitle("[active]")
    MsgBox(0,$Window,"This window will now be hidden, try getting it back with ""s"".")
    WinSetState("[active]","",@SW_MINIMIZE)
EndFunc

Func Show()
    If WinGetState($Window) = 16 Then ; <-- Now this doesn't work :-/
        WinSetState($Window,"",@SW_RESTORE)
    EndIf

    WinMove($Window,"",0,0) ;Works fine, but you'll have to restore the window first, since the IF doesn't work...
EndFunc

Any suggestions on how to do this?

Thanks in advance. :(

Edited by nf67
Link to comment
Share on other sites

  • Moderators

nf67,

From the Help file for WinGetState:

"Multiple values are added together so use BitAND() to examine the part you are interested in"

So let us try that:

HotKeySet("h","Hide")
HotKeySet("s","Show")

;Activate a window, press "h", then press "s" again.

$Window = "[active]"

While 1
WEnd

Func Hide()
    $Window = WinGetTitle("[active]")
    MsgBox(0,$Window,"This window will now be hidden, try getting it back with ""s"".")
    WinSetState("[active]","",@SW_MINIMIZE)
EndFunc

Func Show()
    If BitAnd(WinGetState($Window), 16) = 16 Then ; <-- Now this does work!!!!!!!!!!!!!!!!!!
        WinSetState($Window,"",@SW_RESTORE)
    EndIf

    WinMove($Window,"",0,0) ;Works fine, but you'll have to restore the window first, since the IF doesn't work...
EndFunc

And it works. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

nf67,

I've never quite understood BitAND

Many of the styles you use in AutoIt are "bit-based" so it si quite important to understand BitAND and BitOR.

Think of BitAND this way - each of the bits is a flag and you need a mask to see if the correct flag is set.

Here is a (random) number at the bit level:

128  64   32   16   8    4    2    1

0    0    1    1    0    0    0    1  = 32 + 16 + 1 = 49

You can see how it does not return 16 even though the "16" "flag" is set. What BitAND does is to put a mask over the number and check the specific bit:

128  64   32   16   8    4    2    1

0    0    1    1    0    0    0    1  = 32 + 16 + 1 = 49

0    0    0    1    0    0    0    0  - Mask of 16

BitAND means only count where BOTH bits are 1, so we get

0    0    0    1    0    0    0    0  = 16!!!!

The same sort of logic works when you add styles using BitOR. Imgine you have 2 styles both of which set the same bit (among others of course!)

Style 1 = 00001010 - set bits 4 & 2
Style 2 = 00000010 - set bit 2

Add     = 00001100 - Oops, bits 4 & 3 now set.

BitOr   = 00001010 - OK, bits 4 & 2 still set

I hope that makes it crystal clear. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 1 year later...
  • Moderators

somdcomputerguy,

It has been shown that the foundation of AutoItland is heavily striated with M23rock

Thanks for the compliment but I would say that the bedrock was laid down over the years by the various Devs. :)

I will however freely admit to quarrying it quite heavily - and giving geology classes on many occasions! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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