Jump to content

Getting Window Size / Postion and resizing when incorrect.


HexCore
 Share

Recommended Posts

You all have been such a great help so far, hopefully you can help me out with this.

I have 2 windows that get resized when I turn off the monitors ( HDMI, so it rescales the windows when I turn off the monitor, it's a windows thing I haven't been able to get around ) I have work-arounds for all my windows except for 1 of my setups... I have 2 java applets which I use each one 1/2 screen.. those are the windows I can get to auto-rescale, I was hoping to be able to grab the window size / position and set it?

I have a scrip that set's focused windows in a constant loop,

While 1=1
sleep(24000)
WinActivate("System Center Operations Manager","Lync")
sleep(24000)
WinActivate("System Center Operations Manager","Hyper")
sleep(24000)
WinActivate("System Center Operations Manager","Exchange")
sleep(24000)
WinActivate("Cisco Unified Computing System Manager Vxxx")
WinActivate("Cisco Unified Computing System Manager Vxxx")
sleep(24000)
WinActivate("Tampa, Florida")
send ("{F5}")
sleep(24000)
WinActivate("Forefront Dashboard")
sleep(24000)
WinActivate("Denver, Colorado")
send ("{F5}")
sleep(24000)
WinActivate("Security Summary")
sleep(24000)
WinActivate("PasswordDashboard")
sleep(24000)
WinActivate("AgingIncidentsDashboard")
sleep(24000)
WinActivate("AvayaCallsDashboard")
sleep(24000)
WinActivate("IncidentSatisfactionDashboard")
sleep(24000)
WinActivate("IncidentsChartDashboard")
WEnd

These are the two windows that I need to have size / position checked

WinActivate("Cisco Unified Computing System Manager Vxxx")
WinActivate("Cisco Unified Computing System Manager Vxxx")

when I turn off my monitors it re-scales the windows, upon turning on the monitors I have lost my windows size / position... what would be your best recommendation on having these set correctly at all times.

Thanks in advance for all you comments.

Link to comment
Share on other sites

  • Moderators

HexCore,

If you use WinGetPos on those it will return their size and position. You could just run a quick check every so often (perhaps via Adlib) and reset any value which had changed using WinMove. :oops:

M23

Edit: Wrong button too soon! :D

Edited by Melba23

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

I'm sorry but this is where my lack of skill shows it's true colors, I don't follow how to use those commands with the constant loop, I"m afraid I"m going to create some frankenstien code that will make you face palm... I am still very new to using AutoIT so the lightbulb hasn't gone off on most of it yet... lol. I'm assuming I would have to call it? maybe pointing to a tutorial that would assist me in figuring this out? I really don't want the answer handed to me, I would like to figure it out on my own.. but having the loop is throwing me off...

Link to comment
Share on other sites

  • Moderators

HexCore,

There are lots of ways to do this, but this is the simplest to understand. Run this in SciTE and try moving or resizing the SciTE GUI: :oops:

:rip:

; Use ESC to quit
HotKeySet("{ESC}", "On_Exit")

; Get the initial size and position
$aInitPos = WinGetPos("[CLASS:SciTEWindow]")

; Run the check every 5 secs
AdlibRegister("_Check_Pos", 5000)

; And keep the script alive
While 1
    Sleep(10)
WEnd

; This is what is run every 5 secs
Func _Check_Pos()

    ; Clear a flag
    $fChanged = False
    ; Get the current position
    $aCurrPos = WinGetPos("[CLASS:SciTEWindow]")
    For $i = 0 To 3
        ; if the value is not what it was initially
        If $aCurrPos[$i] <> $aInitPos[$i] Then
            ; set the flag
            $fChanged = True
        EndIf
    Next
    ; if the flag is set
    If $fChanged Then
        ; Reset ehe windoe to the initial pos and size
        WinMove("[CLASS:SciTEWindow]", "", $aInitPos[0], $aInitPos[1], $aInitPos[2], $aInitPos[3])
        ConsoleWrite(@SEC & " - Reset window" & @CRLF)
    Else
        ConsoleWrite(@SEC & " - Window had not changed" & @CRLF)
    EndIf
EndFunc

Func On_Exit()
    Exit
EndFunc

All clear? :D

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

Melba23 beat me to the punch...I had this:

AdlibRegister("_WinCheck", 5000) ; Check the window every 5 seconds.

While 1 ; Create a loop to stop the script from closing.
    Sleep(100)
WEnd
Exit

Func _WinCheck()
    Local $aArray
    $aArray = WinGetPos("<title>") ; Change this to the correct window title.
    If $aArray[2] > 100 Or $aArray[3] > 100 Then ; Check the width & height is not greater than ...
        WinMove("<Title>", $aArray[0], $aArray[1], 50, 50) ; If it is then move the window to the same location but change the size to the default size.
    EndIf
EndFunc   ;==>_WinCheck
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

@ Melba23

ok I see how this is working, amazing!! what I don't understand is how to get the 2 pieces of code together

I currently have the

while 1=1

;code = all my winactivates that I want a constant loop with sleeps on them so each display screen is on monitor for a set amount of time.

wend

now other have suggest I use the "do" where I'm using my while loop for my winactivates...

this is where most of my confusion comes into play.

Edited by HexCore
Link to comment
Share on other sites

  • Moderators

HexCore,

Why not put all the WinActivate lines into the Adlib function and let it do everything? :oops:

That way you get all your GUIs activated and/or replaced every time you run the function. At the moment you are reactivating each GUI every 7 mins or so - set the Adllib timer for 5min (300000 secs) and Robert is your mother's brother. :D

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

ok, so I have it working correctly, figured out a few things.. one thing that I'm jammed up on is this

$aInitPos= WinGetPos("[Title:Cisco Unified Computing System Manager - VRxxx1]")

I have 2 windows, I was unable to find the class even with the Au3record (showed it as program manager)

the are both labled:

Cisco Unified Computing System Manager - VRxxxx1

Cisco Unified Computing System Manager - VRxxxx2

is there a way to wild card them together?

I changed it from class to title not sure if that was correct as I couldn't determine the actual class for what I was trying to pull.

Edited by HexCore
Link to comment
Share on other sites

  • Moderators

HexCore,

"Title" is the default ID parameter, so there is no need for the complicated syntax - just the name will do (Help file <Using AutoIt - Window Titles and Text (Advanced)) refers). :rip:

You could use REGEXPTITLE to get both GUIs - does the "xxx" signify a random 3-digit/character code? :D

Cisco GUIs have proven a difficult problem in the past - are you sure you get no useable info from the Window Info Tool? If we could just get the handle.....what does a WinList array tell you? :oops:

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

The Cisco Unified Computing System Manager - VRxxxx1

the VRxxxxx1 / VRxxxxx2 are server names, these are Cisco UCS manager interfaces. (java)

I use the xxxxx as my company woudln't appreciate me blasting server names out on the web :D but those are the only portion of the window title that are unique.

Edited by HexCore
Link to comment
Share on other sites

  • Moderators

HexCore,

Are they always the same? There is little point in using an SRE if the names are invariable - just use the real names. :oops:

Did you try WinList to see if they appear in the array? :D

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

not sure if I'm doing this correctly, looked at the WinList help and used this code:

$var = WinList()
For $i = 1 to $var[0][0]
  ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
  EndIf
Next
Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then
    Return 1
  Else
    Return 0
  EndIf
EndFunc

Which gave me handle / title, but that was already information I knew other than handle.

Link to comment
Share on other sites

ok... sorry I was using the Au3 record, not the window info tool.

Title: Cisco Unifified Computing System Manager - Vxxxxxx01

Class: SunAwtFrame

both windows have the same Classname, and I'm trying to display them both 1/2 screen each.

Link to comment
Share on other sites

ok so I used the class name for the WinGetPos which works fine with one of the windows, can I get it to work with both? or do I need to invoke 2 seperate functions, 1 for each windows size / pos? I am not seeing anything unique in the window tool or anything else other than the title.

Edited by HexCore
Link to comment
Share on other sites

  • Moderators

HexCore,

You should be able to address both GUIs using:

WinActivate("[Title:Cisco Unifified Computing System Manager - Vxxxxxx01 ; Class:SunAwtFrame]")
WinActivate("[Title:Cisco Unifified Computing System Manager - Vyyyyyy01 ; Class:SunAwtFrame]")

where you substitute the real names for the xxx/yyy sections. :D

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

Yes the above work perfect for the WinActivate yes the real names go where you see xxx/yyyy just using xxx/yyyy as not to give out my servernames

what I'm having trouble with is wrapping that into to the WinGetPos , I run 2 of those screens each at 1/2 size, they rescale when I turn off my monitors (hdmi) so when I turn on the monitors the windows don't auto resize which is what I'm tying to get this script to do for me.

so I'm trying to get this portion of the code to include each window:

; Use ESC to quit
HotKeySet("{ESC}", "On_Exit")
; Get the initial size and position
$aInitPos = WinGetPos("[CLASS:SunAwtFram]")

but I'm not sure how to capture it for each window? I have it working correctly for 1, but not both.... that's where my handup is. the Classes are the same, but the window titles are unique.

Link to comment
Share on other sites

  • Moderators

HexCore,

It is not that difficult - just use a different array for each window: :D

$aInitPos_xxx = WinGetPos("[Title:Cisco Unifified Computing System Manager - Vxxxxxx01 ; Class:SunAwtFrame]")
$aInitPos_yyy = WinGetPos("[Title:Cisco Unifified Computing System Manager - Vyyyyyy01 ; Class:SunAwtFrame]")

; and then you do this in the function

; Clear 2 flags
$fChanged_xxx = False
$fChanged_yyy = False

; Get the current position of each window
    $aCurrPos_xxx = WinGetPos("[Title:Cisco Unifified Computing System Manager - Vxxxxxx01 ; Class:SunAwtFrame]")
    $aCurrPos_yyy = WinGetPos("[Title:Cisco Unifified Computing System Manager - Vyyyyyy01 ; Class:SunAwtFrame]")
    ; And now check each window
    For $i = 0 To 3
        ; if the value of xxx is not what it was initially
        If $aCurrPos_xxx[$i] <> $aInitPos_xxx[$i] Then
            ; set the flag
            $fChanged_xxx = True
        EndIf
        ; if the value of yyy is not what it was initially
        If $aCurrPos_yyy[$i] <> $aInitPos_yyy[$i] Then
            ; set the flag
            $fChanged_yyy = True
        EndIf
    Next
    ; iI a flag is set
    If $fChanged_xxx Then
        ; Reset the xxx window to the initial pos and size
        WinMove("[Title:Cisco Unifified Computing System Manager - Vxxxxxx01 ; Class:SunAwtFrame]"), "", $aInitPos_xxx[0], $aInitPos_xxx[1], $aInitPos_xxx[2], $aInitPos_xxx[3])
        ConsoleWrite(@SEC & " - Reset xxx window" & @CRLF)
    Else
        ConsoleWrite(@SEC & " - yyy window had not changed" & @CRLF)
    EndIf
If $fChanged_xxx Then
        ; Reset the yyy window to the initial pos and size
        WinMove("[Title:Cisco Unifified Computing System Manager - Vyyyyyy01 ; Class:SunAwtFrame]"), "", $aInitPos_yyy[0], $aInitPos_yyy[1], $aInitPos_yyy[2], $aInitPos_yyy[3])
        ConsoleWrite(@SEC & " - Reset yyy window" & @CRLF)
    Else
        ConsoleWrite(@SEC & " - yyy window had not changed" & @CRLF)
    EndIf

Just try and think logically instead of trying to get clever and use the same code for both windows at the same time. :oops:

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...