AutoHotkey Community

It is currently May 27th, 2012, 12:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Changing Screen sizes?
PostPosted: December 21st, 2009, 4:43 am 
Offline

Joined: July 31st, 2009, 12:59 am
Posts: 15
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 5:30 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 5:32 am 
Offline

Joined: July 31st, 2009, 12:59 am
Posts: 15
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 6:07 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 6:09 am 
Offline

Joined: July 31st, 2009, 12:59 am
Posts: 15
yeah it will be a specific point, so a lot of if's. that's what I was looking for, thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2009, 9:33 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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

_________________
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Leef_me, Ohnitiel, XstatyK, Yahoo [Bot] and 15 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