resize-a-window-using-winmove

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

resize-a-window-using-winmove

16 Feb 2018, 12:05

hi, guys
this code from here:
https://autohotkey.com/board/topic/1359 ... g-winmove/

Code: Select all

WinTitle := "AutoHotkey Help" 
WinActivate, %WinTitle%
WinMove, %WinTitle%, , 0, 0 , 300, 300 ; This is what you asked for!
Ctr = 0
Loop 50 {
  WinMove, %WinTitle%, , %Ctr% , , 300, 300
  Ctr += 5
  }
Ctr = 0
Loop 50 {
  WinMove, %WinTitle%, , , %Ctr% , 300, 300
  Ctr += 5
  }
I added a line to it at the beginning and it work very will

Code: Select all

 
Run, \\srv\Al-Motahida\Projects\IACPA\IACPA\
Sleep, 200
WinTitle := "IACPA" 
WinActivate, %WinTitle%
WinMove, %WinTitle%, , 0, 0 , 300, 1040 
return
Ctr = 0
Loop 50 {
  WinMove, %WinTitle%, , %Ctr% , , 300, 300
  Ctr += 5
  }
Ctr = 0
Loop 50 {
  WinMove, %WinTitle%, , , %Ctr% , 300, 300
  Ctr += 5
  Sleep, 200
  }
My question is: I have two windows, and I want to open them and put them together as in the attached picture.
2 windows.png
2 windows.png (68.44 KiB) Viewed 2524 times
my anthor window name is "D:\Prog\test"

Any help would be greatly appreciated.
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: resize-a-window-using-winmove

17 Feb 2018, 04:44

Thanks Mr. BoBo
I know that my English is not good, excuse me
This is not what I was looking for
I want if I pressed a hotkey or typed hotstring to show two specific windows on the screen.
I appreciate your help
thank you very much.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: resize-a-window-using-winmove

17 Feb 2018, 05:42

Check out A_ScreenHeight/-Width and do some math to get the exact coords for resizing/-moving those windows.
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: resize-a-window-using-winmove

18 Feb 2018, 12:04

I failed in that
I appreciate your help
thank you very much
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: resize-a-window-using-winmove

18 Feb 2018, 13:28

Hi.
It shouldn't be necessary, to loop the position like in your example.
Try following script:

Code: Select all

SetTitleMatchMode, 3
RunWait, \\srv\Al-Motahida\Projects\IACPA\IACPA
RunWait, D:\Prog\test
Sleep, 200
WinMove, \\srv\Al-Motahida\Projects\IACPA\IACPA,, 300, 0, 300, 1040
WinMove, D:\Prog\test,, 0, 0, 300, 1040 
return
Einfach nur ein toller Typ. :mrgreen:
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: resize-a-window-using-winmove

19 Feb 2018, 02:13

hi, divanebaba
The two windows were opened
But the "WinMove" and "Resize" command did not work.
Thanks for help.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: resize-a-window-using-winmove

19 Feb 2018, 03:02

Then try this:

Code: Select all

SetTitleMatchMode, 3
RunWait, \\srv\Al-Motahida\Projects\IACPA\IACPA
RunWait, D:\Prog\test
Sleep, 200
WinMove, IACPA,, 300, 0, 300, 1040
WinMove, test,, 0, 0, 300, 1040 
return
It is possible, that you don't use full path in window title. You can change this in options of windows explorer (options for folder appearance).
Option called like "Show full path name in Titlebar" or something like this.
Einfach nur ein toller Typ. :mrgreen:
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: resize-a-window-using-winmove

19 Feb 2018, 05:23

hi, divanebaba
it's works very good
I appreciate your help
thank you very much
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: resize-a-window-using-winmove

19 Feb 2018, 13:54

Hi, All
First: I thank divanebaba for all helps.
Second: this is the final Script:

Code: Select all

; --------------------------------------------------------------part  1
#SingleInstance, Ignore
SetWorkingDir, D:\Re

Button_Names = Ec_1|Ec_2

Capslock::!F4
#q::
Gui, Destroy
Gui, -Caption +LastFound +AlwaysOnTop
Loop, 2
{
   I := A_Index
   Loop, Parse, Button_Names, |
      If(A_Index == I)
         Gui, Add, Button, % "x" 1 + (I-1) * 76 " y1 w75 h30 gButton" I, % A_LoopField
}
Gui, Show, Noactivate x15  y0 w1881 h32, MacroBar
Return

; --------------------------------------------------------------part  2
Button1:
SetTitleMatchMode, 3
RunWait, D:\font
RunWait, D:\Re
Sleep, 300
WinActivate, D:\Re
Sleep, 300
WinMove, Re,, 0, 40, 400, 600 
Sleep, 300
WinActivate, font
Sleep, 300
WinMove, D:\font,, 400, 40, 400, 600
return

Button2:
SetTitleMatchMode, 3
RunWait, D:\indesign
RunWait, D:\Re
Sleep, 200
WinActivate, D:\indesign
WinMove, D:\indesign,, 400, 40, 400, 600
Sleep, 200
WinActivate, Re
WinMove, Re,, 0, 40, 400, 600   
   
 ^!s::
ExitApp
My question is: Is it possible to divide the code into two files?
Part 1 into "*.ahk"
Part 2 into "*.ini"
If someone could show me how to do this, I would be very grateful!
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: resize-a-window-using-winmove

20 Feb 2018, 07:53

Can the script read "Buttons" part of the code from the INI file?
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: resize-a-window-using-winmove

26 Feb 2018, 10:36

Einfach nur ein toller Typ. :mrgreen:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Nerafius and 109 guests