Sign in to follow this  
Followers 0
willichan

WinMove() not moving and resizing with single command

5 posts in this topic

I am having an interesting problem with WinMove() when moving multiple windows.

Running this code

WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1)
WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1)
WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1)
WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1)

both moves AND resizes the first window, but only moves the remaining windows without resizing them.

I tried interjecting a Sleep(100) between each WinMove() call, but no change in behavior.

However, if I double up the calls,

Global $a
$a = WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1)
If $a <> 0 Then WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1)
WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1)
If $a <> 0 Then WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1)
WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1)
If $a <> 0 Then WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1)
WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1)
If $a <> 0 Then WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1)

then everything seems to work, but it seems a rather uneligant solution.

Any thoughts?

(Using AutoIt 3.3.12.0 on a Win7-64bit machine)

 

Share this post


Link to post
Share on other sites



That worked. 

:huh2:  I am still puzzled as to why it would move the window without activating it first, but not resize it.

Share this post


Link to post
Share on other sites

Actually, I just found that activating first still intermittantly does not resize.

Global $a
$a = WinActivate("Session A - [24 x 80]", "")
If $a <> 0 Then WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1)
$a = WinActivate("Session B - [24 x 80]", "")
If $a <> 0 Then WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1)
$a = WinActivate("Session C - [24 x 80]", "")
If $a <> 0 Then WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1)
$a = WinActivate("Session D - [24 x 80]", "")
If $a <> 0 Then WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1)

This code works half the time, but only resized the first window the other half. :ermm:

So far the only solution that has not failed is to WinMove() twice for each window. :huh2:  :think:

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  
Followers 0

  • Similar Content

    • keelaji
      By keelaji
      Hello,
      first of all i searched in the forum but i didn't found any solution to my problem.
      I am using windows 10.
      I made a script that is supposed to change the title to the active window, resize it to the smallest size possible (should be around 800 x 600) and move to (0, 0).
      I can change the title but i fail to do the other 2 tasks.
      i use wingettitle [active] copied from the F1 help tool (and this works), i i put the title in a variable and than i use
      winsettitle ($variable, "one") (this works too)
      winmove ("one", 0, 0, 800, 600) (doesn't do anything)
      i also tried
      local $x = winget ( "one")
      msgbox (0, "", $x) (i get a completely white box so i suppose winget can't have any data about my window ??)
      any suggestion ?
    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm trying to move and resize a program call CPUID HWMonitor (http://www.cpuid.com/softwares/hwmonitor.html) but WinMove() doesn't work. Can someone tell me how to get this to work for this program? I've successfully moved other programs using WinMove(), and I've used WinGetTitle ("[ACTIVE]") to confirm the title is correct. WinActivate("CPUID HWMonitor") does work.
      If I run the following code nothing happens, doesn't move or resize, but AutoIt doesn't complain about the code either:
      WinMove("CPUID HWMonitor", 0, 0, 475, 715) The class changes every time the program opens (and I've nevery had a lot of success with classes tbh, bit hit and miss for me).
      Thanks all!
    • Leo1906
      By Leo1906
      Hey guys, I could need your help aggain ..
      Is there a way to clip GUIs together (child GUIs - in one script). So if I use WinMove with speed set to one of those GUIs, the others follow at the same speed like they where one block?
      I can't think of an option to do this in pure Autoit. Creating an adlib for each GUI won't help I'm afraid, because adlibs are paused on GUI-move?
      And using this type of function didn't help either: 

      I can't imagine any other way of achieving multiple GUI moves at once using Autoit, because Autoit waits for the WinMove command to finish ..
      Any thoughts? Maybe a build in windows function for clipping GUIs together?
       
      Thanks for your help
    • FMS
      By FMS
      Hello,
      Below is a code whish i made for this problem i've. (code 1)
      The problem is that iff i try Winmove to to show the hidden button it's not working as i tought.
      What i try to do is just simple expand the GUI to make the hidden button visible. (code 2)
      I've already looked into GUICoordMode but don't think that's the problem.(or I don't understand it properly)
      Also tried to look into the forum but din't find anything around this subject but could't find anything around this subject.
      Does somebody knows what I'm doing wrong?
       
      Code 1 (winmove prblem) :
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 134, 103, 192, 124) $Button1 = GUICtrlCreateButton("1", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("2", 8, 40, 75, 25) $Button3 = GUICtrlCreateButton("3", 8, 72, 75, 25) $expand_button = GUICtrlCreateButton("EXP", 96, 40, 27, 25) $hidden_button = GUICtrlCreateButton("Hidden", 160, 40, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $expand_button WinMove($Form1, "From1", 192, 124, 300, 103) EndSwitch WEnd  
      Code 2 What I'm trying to expand to :
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 265, 114, 192, 124) $Button1 = GUICtrlCreateButton("1", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("2", 8, 40, 75, 25) $Button3 = GUICtrlCreateButton("3", 8, 72, 75, 25) $expand_button = GUICtrlCreateButton("EXP", 96, 40, 27, 25) $hidden_button = GUICtrlCreateButton("Hidden", 160, 40, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • DesireDenied
      By DesireDenied
      Hi all,
      Can anyone tell me please, how to make my GUI stop moving/resizing elements that lays below $hInput (editbox) when I am trying to change the window size?
      The problem is that when I try to initialize my GUI 23px high I dont even get the buttons drawn, and if I try to redraw the window to smaller one, all elements get stuck together.
      All I want to do is to have a simple GUI, initialized with edit box only, and to have a window slowly expand if user type: add %s (command).
      ; INCLUDES #Region - INCLUDES #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <Array.au3> #include <WinAPI.au3> #EndRegion #Region - OPTIONS Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GUICtrlRead tab index #endregion #Region - GLOBAL VARIABLES Global Enum $Title, $Handle, $X, $Y, $Width, $Height, $isVisible, $isActive Global Enum $Short, $Long Global Enum $Len=0, $Client, $Order, $Year Global $hGUI Global $AI[7], $HP[8] $AI[$Title] = "Illustrator" $HP[$Title] = "Helper" $HP[$Handle] = $hGUI $HP[$isVisible] = True $HP[$isActive] = True $HP[$Y] = 2 $HP[$Width] = 160 $HP[$Height] = 23 Global $aClient[][] = [ ["SHORT", "LONG"], ["1st", "First client"], ["2nd", "Second client"] ] Global $tAutoExit = TimerInit() #EndRegion #Region - GUI ; GUI INITIALIZATION $hGUI = GUICreate("Helper", 160, 110, Default, 2, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_TRANSPARENT)) ;~ GUISetBkColor(0x3399FF) $hInput = GUICtrlCreateInput("", 0, 0, 160, 23) GUICtrlSetOnEvent($hInput, "InputHandler") $Button1 = GUICtrlCreateButton("File", 8, 28, 145, 22) $Button2 = GUICtrlCreateButton("Folder", 8, 50, 145, 22) $Button3 = GUICtrlCreateButton("Win Search", 8, 72, 145, 22) GUISetState(@SW_SHOW) Sleep(2000) WinMove($HP[$Title], "", Default, Default, Default, 23, 3) #EndRegion GUI #Region - MAIN LOOP While 1 CheckForRequest($HP) AutoExit(10) Sleep(10) WEnd #EndRegion #Region - FUNCTIONS Func AutoExit($iSeconds) If TimerDiff($tAutoExit) > $iSeconds*1000 Then Exit EndFunc Func CheckForRequest($vObject) If $vObject[$isActive] And _IsPressed("1B") Then Fade($HP) If (_IsPressed("12") And _IsPressed("C0")) Then Fade($HP) EndFunc Func InputHandler() Local $sMsg = GUICtrlRead(@GUI_CtrlId) ConsoleWrite("+ Command: " & $sMsg & @CRLF) Switch $sMsg Case "bye" ConsoleWrite("> Exiting... " & @CRLF) Exit Case "ai" ConsoleWrite("> " & $AI[$Title] & @CRLF) Case "hp" ConsoleWrite("> " & $HP[$Title] & @CRLF) Case StringInStr($sMsg, " ") <> False GetArgs($sMsg) Case Else EndSwitch Fade($HP) EndFunc Func GetArgs($sMsg) Local $aMsg = StringSplit($sMsg, " ") Switch $aMsg[0] Case 2 To 3 isClientFolder($aMsg) isNewCommand($aMsg) EndSwitch EndFunc Func isNewCommand($aArgs) If $aArgs < 2 Then Return -1 Switch $aArgs[1] Case "add" CommandAdd($aArgs[2]) Case "del" CommandDel($aArgs[2]) EndSwitch EndFunc Func CommandAdd($vVar) Local $t = 0 ConsoleWrite("-> Adding new command..." & @CRLF) WinMove($HP[$Title], "", Default, Default, Default, 140, 1) GUICtrlSetState($Button1, $GUI_SHOW) While $t < 4 $t += 1 Sleep(1000) WEnd EndFunc Func CommandDel($vVar) ConsoleWrite("-> Removing existing command..." & @CRLF) EndFunc Func isClientFolder($aArgs) Local $aSearch = _ArraySearch($aClient, $aArgs[$Client]) Local $hSearch, $sFileName = "" Local $aOrderNo, $sOrderNo, $sOrderName, $nOrder=1 Local $sPath = "D:\" Local $iYear = "2015" ; Check if user is looking for client folder If $aSearch=-1 Then Return -1 ; Check if user have specified the year If ($aArgs[$Len]=3 And ($aArgs[3]>11 And $aArgs[3]<15)) Then $iYear = "20" & $aArgs[$Year] EndIf ; Set up new working path $sPath &= $iYear & "\" $sPath &= $aClient[$aSearch][$Long] & "\" ; Reorder? $aOrder = StringSplit($aArgs[$Order], ".") $sOrderNo = $iYear ; Deep search Do FileChangeDir($sPath) $sOrderNo &= "."& $aOrder[$nOrder] $hSearch = FileFindFirstFile($sOrderNo &"*") $sFileName = FileFindNextFile($hSearch) FileClose($hSearch) If $sFileName = "" Then Return -1 Else $sPath &= "\" & $sFileName &"\" EndIf $nOrder += 1 Until $nOrder > $aOrder[$Len] ShellExecute($sPath, "", "", "open") EndFunc Func Fade(ByRef $vObject) If $HP[$isVisible] Then For $i=255 To 0 Step -1 WinSetTrans($vObject[$Title], "", $i) If IsInt($i/10) Then Sleep(2) Next GUICtrlSetData($hInput, "") Else For $i=0 To 255 Step 1 WinSetTrans($vObject[$Title], "", $i) If IsInt($i/10) Then Sleep(2) Next EndIf $vObject[$isVisible] = Not $vObject[$isVisible] $vObject[$isActive] = Not $vObject[$isActive] EndFunc #endregion