AutoHotkey Community

It is currently May 26th, 2012, 9:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: correct window position
PostPosted: August 13th, 2005, 9:30 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2005, 9:55 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2543
Could you give an example and a bit of code that you are trying to use please?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2005, 10:30 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2005, 10:52 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2543
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 ;) ...

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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2005, 11:19 pm 
Offline

Joined: October 27th, 2004, 1:22 am
Posts: 64
Location: GA
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 8)


Last edited by tpatel5 on August 14th, 2005, 4:46 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 12:01 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 12:25 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 12:45 pm 
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 :)

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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 12:50 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 1:00 pm 
another question. how is the set by default? does it go by screen or by relative to screen by default?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 1:06 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2005, 4:27 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2543
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2005, 12:18 am 
wow, thanx 'corrupt'. i would have never been able to figure that out.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2005, 12:33 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2005, 12:33 am 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, JSLover, patgenn123, rbrtryn, virpara and 56 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