 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
David
Joined: 08 Aug 2004 Posts: 25 Location: Lubbock, Texas
|
Posted: Fri Oct 08, 2004 10:31 pm Post subject: WinMove |
|
|
This code should open four Explorer windows, each pointing to C:\, and tile them. What it does is open one window and move it around the screen.
However, if each of the Run, explorer.exe statements points to a different drive (e.g., explorer.exe C:\, explorer.exe U:\, explorer.exe V:\, explorer.exe I:\), so that each window has a different title, it works. So evidentally WinMove grabs the first window it finds that matches the title rather than the last opened window? I was assuming WinWait should set the "Last Found" window to the last-opened window, which WinMove would then operate on.
Can WinMove point to different windows in tern when all the titles and class IDs are identical?
| Code: | +^#z::
SetTitleMatchMode, 3
; Window 1
Run, explorer.exe C:\
WinWait C:\
WinMove, C:\, , 0, 0, 640, 467
; Window 2
Run, explorer.exe C:\
WinWait, C:\
WinMove, C:\, , 640, 0, 640, 467
; Window 3
Run, explorer.exe C:\
WinWait, C:\
WinMove, C:\, , 0, 467, 640, 467
; Window 4
Run, %windir%/explorer.exe C:\
WinWait, C:\
WinMove, C:\, , 640, 467, 640, 467
Return
|
|
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 443 Location: SLC, Utah
|
Posted: Fri Oct 08, 2004 11:09 pm Post subject: |
|
|
The problem with opening 4 explorer windows all pointing to C:\ is a limitation to explorer not opening a window that already exists. There might be a switch or registry setting to change that.
I have a script that has two different examples of where it has windows identical and will take care of each one based on their window ID's.
| Code: | WinGet, windowlist, list, C:\
Loop, %windowlist%
{
StringTrimRight, windowid, windowlist%a_index%, 0
if a_index = 1
WinActivate, ahk_id %windowid%
WinMove, ahk_id %windowid%,, 0, 0, 640, 467
} |
Here is another example that I have an INI file setup where if a Window exists move it to a specified location. But I only wanted it to move it when it first opened, so that I could move it around after I openned it.
| Code: | title = Calculator
left = 700
top = 0
WinGet, winid, ID, %title%
if win_%winid% <> 1
{
WinMove, ahk_id %winid%,, %left%, %top%
win_%winid% = 1
} |
thanks,
beardboy |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Sat Oct 09, 2004 12:14 am Post subject: |
|
|
On the off chance that you need it, you can operate on windows that have identical titles and classes by using WinGet as in this example: | Code: | WinGet, id, list, ahk_class ExploreWClass ; double-pane explorer windows.
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinActivate, ahk_id %this_id%
MsgBox, 4, , Visiting all Explorer windows`n%a_index% of %id%`nahk_id %this_id`n`nContinue?
IfMsgBox, NO, break
} |
|
|
| Back to top |
|
 |
Guest
|
Posted: Sat Oct 09, 2004 4:36 am Post subject: |
|
|
First, instead of saying, "This code should ...," I should have said, "I'd like this code to ...." I think I might have come off sounding a little judgmental of AHK. Not intended -- sorry.
Anyway, WinGet is great. Thanks, beardboy and Chris. This is the resulting code that does what I had wanted.
| Code: | screenWidth = 1152
screenHeight = 824 ; actual height (864) minus 40, to allow for taskbar
EnvDiv, screenWidth, 2
EnvDiv, screenHeight, 2
Loop, 4
{
Run, explorer.exe
Sleep, 1000
}
WinGet, windowList, List, ahk_class ExploreWClass
WinMove, ahk_id %windowList1%, , 0, 0, %screenWidth%, %screenHeight%
WinMove, ahk_id %windowList2%, , %screenWidth%, 0, %screenWidth%, %screenHeight%
WinMove, ahk_id %windowList3%, , 0, %screenHeight%, %screenWidth%, %screenHeight%
WinMove, ahk_id %windowList4%, , %screenWidth%, %screenHeight%, %screenWidth%, %screenHeight%
Return |
|
|
| Back to top |
|
 |
Beastmaster
Joined: 15 Apr 2004 Posts: 181
|
Posted: Sat Oct 09, 2004 12:17 pm Post subject: |
|
|
| Quote: | Loop, 4
{
Run, explorer.exe /e,C:\
} |
This one should open four explorer instances/windows. Guess they're seen as separate windows by WinSpy (?). Haven't checked it yet.
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|