AutoHotkey Community

It is currently May 27th, 2012, 8:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: WinMove
PostPosted: October 8th, 2004, 11:31 pm 
Offline

Joined: August 8th, 2004, 10:04 pm
Posts: 25
Location: Lubbock, Texas
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2004, 12:09 am 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2004, 1:14 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2004, 5:36 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2004, 1:17 pm 
Offline

Joined: April 15th, 2004, 5:33 pm
Posts: 181
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.

8)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], sjc1000, specter333 and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group