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 

correct window position
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
myst
Guest





PostPosted: Sat Aug 13, 2005 9:30 pm    Post subject: correct window position Reply with quote

i have a question about correcting the windows position so the program can click in the right areas. is there a way to make the program set the window in a specific place before it starts automating the mouse clicks? because sometimes i move the window, and then all the mouse clicks dont work anymore so it has to be exactly centered again. what can i do to remedy this?

Thank you.
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2419

PostPosted: Sat Aug 13, 2005 9:55 pm    Post subject: Reply with quote

Could you give an example and a bit of code that you are trying to use please?
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Sat Aug 13, 2005 10:30 pm    Post subject: Reply with quote

MouseClick, left, 261, 572
Sleep, 100
MouseClick, left, 174, 100
Sleep, 100
MouseClick, left, 304, 63

its just a lot of code like that. i just need the window to be in the same position so the mouse clicks will click on the right spots. do you know what i mean?
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2419

PostPosted: Sat Aug 13, 2005 10:52 pm    Post subject: Reply with quote

Yes... but I was hoping to suggest an alternate method to using MouseClick that may not depend on the window position... That's a bit difficult to do without a clue on what you're actually trying to do Wink ...

If you would prefer to use MouseClick then you will likely find a bit of useful info by looking up WinMove and similar commands in the AutoHotkey help file. If you have difficulty then please provide a bit more info...
Back to top
View user's profile Send private message Visit poster's website
tpatel5



Joined: 27 Oct 2004
Posts: 65
Location: GA

PostPosted: Sat Aug 13, 2005 11:19 pm    Post subject: Reply with quote

I think yoo are using screen coordinates, use this command to set your coordintates relative to the active window
Quote:
CoordMode, ToolTip|Pixel|Mouse|Caret|Menu [, Screen|Relative]

_________________
-Tru Cool


Last edited by tpatel5 on Sun Aug 14, 2005 4:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Aug 14, 2005 12:01 pm    Post subject: Reply with quote

didnt quite understand the last post. i think thats too advanced for me to understand yet.

this is for a game so it has to click certain objects and pop ups and stuff in specific locations so i can simply use shortcut keys in the game to replace the mouse clicks. thats why i need the game window exactly centered so it clicks the right spots in the game. i used to have a diff macro program that would automatically center the window when it was opened so it would accurately do the mouse clicks.
but then the free trial expired lol. but then i found this prog and i think its MUCH more powerfull and better to use and plus its free.

so now do you understand what im trying to do?
Back to top
Guest






PostPosted: Sun Aug 14, 2005 12:25 pm    Post subject: Reply with quote

The answer lies in the Help...

The normal mode of sending (and determining the position of) mouseclicks is to use the relative position in the window.

So, regardless where the window resides on screen, the clicks will always be done at an offset from the target window's top-left corner.

My (and other posters) guess is, that you somehow use the absolute positioning (relative to the screen). You can force relative positioning to the window by using the CoordMode option, like tpatel5 wrote...

Code:
CoordMode, Mouse, Relative
Back to top
Guest






PostPosted: Sun Aug 14, 2005 12:45 pm    Post subject: Reply with quote

o ok. i see what you mean now. but im not exactly sure how put the code you gave me into my script. could you put that code in an example script so i know how i apply it to mine?

then i can give it a try and see how it goes Smile

so theres no way to center the game window in the middle of my screen, in the same position as when i first opened up the game window?

Thanx guys
Back to top
Guest






PostPosted: Sun Aug 14, 2005 12:50 pm    Post subject: Reply with quote

o, i just understood tpatel's post, i didnt know those were all options. i just had to use the ones he highlighted in red. im gonna try to play around with it tonight and see what i can do with it. ill get back to you guys once im done playing around with it.

but ide still like an answer to my question about centering the window in my previous post
Back to top
Guest






PostPosted: Sun Aug 14, 2005 1:00 pm    Post subject: Reply with quote

another question. how is the set by default? does it go by screen or by relative to screen by default?
Back to top
Guest






PostPosted: Sun Aug 14, 2005 1:06 pm    Post subject: Reply with quote

damn, im leaving a lot of replys haha. maybe i should register or something so i can edit my posts. but anyway, i found out that it is set to CoordMode, Mouse, Relative by default anyway. i tested it out and even when i moved the window, it still worked. so i didnt even have to put CoordMode, Mouse, Relative anyway. as long as i have a window active, i have to use the relative coordinates in the autohotke spy prog. thanx for the help guys.
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2419

PostPosted: Sun Aug 14, 2005 4:27 pm    Post subject: Reply with quote

Code:
; Start Notepad for testing
Run, Notepad
WinWait, Untitled - Notepad
WinWaitActive, Untitled - Notepad

; Move Notepad window to the top left corner of the screen
WinMove, 0, 0

; Display message
MsgBox, 48, Begin, Center Notepad window..., 2

; Get the width and height of the Notepad window
WinGetPos,,, ww, hh, Untitled - Notepad

; Calculate where to move the window to center it
xx := (A_ScreenWidth//2) - (ww//2)
yy := (A_ScreenHeight//2) - (hh/2)

; Move the window to the calculated location
WinMove, xx, yy

; Display a message, close Notepad and exit
MsgBox, 48, Done, Notepad Window Centered, 2
WinClose, Untitled - Notepad
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Mon Aug 15, 2005 12:18 am    Post subject: Reply with quote

wow, thanx 'corrupt'. i would have never been able to figure that out.
Back to top
Guest






PostPosted: Mon Aug 15, 2005 12:33 am    Post subject: Reply with quote

btw corrupt, did you get that code from somewhere or did you make it? and if you got it from somewhere, where did you get it? from the help file?

and i dont think this part of the script is necessary, it pretty much has no use if the window is gonna be moved anyway.
; Move Notepad window to the top left corner of the screen
WinMove, 0, 0
Back to top
myst
Guest





PostPosted: Mon Aug 15, 2005 12:33 am    Post subject: Reply with quote

btw corrupt, did you get that code from somewhere or did you make it? and if you got it from somewhere, where did you get it? from the help file?

and i dont think this part of the script is necessary, it pretty much has no use if the window is gonna be moved anyway.
; Move Notepad window to the top left corner of the screen
WinMove, 0, 0
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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