AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get new coords after a window is moved?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TheIrishThug



Joined: 19 Mar 2006
Posts: 379

PostPosted: Sun May 18, 2008 10:17 pm    Post subject: Get new coords after a window is moved? Reply with quote

I'm trying to write a program that monitor and arrange windows that belong to a certain program. The problem is I don't know what windows message or event I can hook into in order for my program to know that one of the windows I'm watching was just moved and get the new coordinates of the window's location. Anyone know what I need for this?
Back to top
View user's profile Send private message Visit poster's website AIM Address
Trikster



Joined: 15 Jul 2007
Posts: 1194
Location: Enterprise, Alabama

PostPosted: Sun May 18, 2008 10:23 pm    Post subject: Reply with quote

Code:
OnMessage(0x201, "Gui_Move")

GUI_Move(wParam, lParam)
{
   global active_ID, ini_guiposX, ini_guiposY
   CoordMode, Mouse, Screen
   MouseGetPos, Xpos, Ypos, OutputvarWin, OutputVarControl
   WinGetPos, winXpos, winYpos, , , ahk_id %active_ID%
    if (OutputvarWin = active_ID)
    {
       if (OutputVarControl = "")
       {         
          xoffset := Xpos - winXpos
          yoffset := Ypos - winYpos
;          MsgBox, %xoffset% - %yoffset%
          Loop
            {
             GetKeyState, state, LButton
               if state = D
               {
                  MouseGetPos, Xpos, Ypos
                  ini_guiposX := Xpos - Xoffset
                  ini_guiposY := Ypos - Yoffset
                  Gui,1: show, x%ini_guiposX% y%ini_guiposY%,
               }
               else
                  break
            }
       }
   }
return
}


Posted by Zed Gecko in the thread [Desktop Widget] RUN-Box
_________________
ScriptPad/~dieom/dieom/izwian2k7/Ian/God

Back to top
View user's profile Send private message
TheIrishThug



Joined: 19 Mar 2006
Posts: 379

PostPosted: Sun May 18, 2008 11:00 pm    Post subject: Reply with quote

I cannot seem to make the RunBox example work as stated. Gui_Move was being triggered, but the OutputvarWin was never equal to active_ID.

Also, I thought OnMessage only worked for when the AHK script received the message. If this is true, then I would need more than just OnMessage, because I want to watch windows of other applications.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group