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 

Changing Screen sizes?

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



Joined: 30 Jul 2009
Posts: 15

PostPosted: Mon Dec 21, 2009 3:43 am    Post subject: Changing Screen sizes? Reply with quote

Ok so basically I want to be able to make something that clicks somewhere on a screen, but for this to happen, I need to have screen sizes. So basically I built a GUI with some common screen size, but I want to know is with a DropDownList, what can I do so that when they select a screen size (e.g. 1024x768) what would I do? Would there be If-Else statements? Would I make it so that if they selected that, it would apply to a specific section for a variable? If you need any clarification please ask. thanks!
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Mon Dec 21, 2009 4:30 am    Post subject: Reply with quote

A_ScreenWidth
A_ScreenHeight
The built in variables to give screen size
On most computers you can right click on the desktop and in that menu is display modes where you can easily change the size
Back to top
View user's profile Send private message
ghosty1212



Joined: 30 Jul 2009
Posts: 15

PostPosted: Mon Dec 21, 2009 4:32 am    Post subject: Reply with quote

after that, what would I do?
i.e.
if A_ScreenWidth is 1024x768 then click 220, 665
would it just be a bunch of if-then statements or something?
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Mon Dec 21, 2009 5:07 am    Post subject: Reply with quote

Depends you could move the mouse to the center of the screen
Code:
CoordMode, Mouse, Screen
MouseMove (A_ScreenWidth/2),(A_ScreenHeight/2)

if you want to click on a position relative to screen size.
if you want absolute positions you might need a lot of if's
If you leave CoordMode alone mouse movements are relative to the active window which should not change much unless you are using it full screen.
Back to top
View user's profile Send private message
ghosty1212



Joined: 30 Jul 2009
Posts: 15

PostPosted: Mon Dec 21, 2009 5:09 am    Post subject: Reply with quote

yeah it will be a specific point, so a lot of if's. that's what I was looking for, thanks.
Back to top
View user's profile Send private message
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Wed Dec 23, 2009 8:33 am    Post subject: Reply with quote

I went a little kookie with this! If you position the mouse and press 'capslock' it will store the current mouse x,y. If you press 'ctrl+capslock' it will save the list of x,y coords along with the current screen width and height. Press 'alt+capslock' (maybe on another computer or after changing resolution) to play back the recorded mouse x,y clicks scaled to the current screen width and height. It will not actually click at the scaled coords now, but will use outputdebug to demonstrate.

Code:
Return

CapsLock::   ;press capslock (do not click with the mouse) to record a click to be scaled; it will be added to the queue
   CoordMode, Mouse, Screen
   MouseGetPos, x, y
   storedClicks := storedClicks ? storedClicks . "`n" . x . "|". y : x . "|". y
Return

^CapsLock::   ;control+capslock stores the series of clicks
   FileDelete, clicks.txt
   ;screen height and width on computer this was recorded
   FileAppend, %A_ScreenWidth%|%A_ScreenHeight%¶, clicks.txt
   FileAppend, %storedClicks%, clicks.txt
OutputDebug, %storedClicks%
Return

!CapsLock::   ;alt+capslock plays back the scaled click queue
   FileRead, queue, clicks.txt
   StringSplit, q, queue, ¶   ;separate the original screen from the click data
   StringSplit, origWH, q1, |   ;split the x,y coords (w=origWH1, h=origWH2)
   StringSplit, clicks, q2, `n   ;split the clicks
   Loop, % clicks0
   {   StringSplit, coord, clicks%A_Index%, |   ;x=coord1, y=coord2
      coord1 += 0   ;make sure they are numbers
      coord2 += 0
      scaleX :=(A_ScreenWidth * coord1) / origWH1   ;scale the coords
      scaleY := (A_ScreenHeight * coord2) / origWH2
OutputDebug, origX: %coord1% > scaledX: %scaleX%
OutputDebug, origY: %coord2% > scaledY: %scaleY%
OutputDebug, ___________________________
;~       Click, %scaleX%, %scaleY%
   }
Return

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
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