 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ghosty1212
Joined: 30 Jul 2009 Posts: 15
|
Posted: Mon Dec 21, 2009 3:43 am Post subject: Changing Screen sizes? |
|
|
| 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 |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Mon Dec 21, 2009 4:30 am Post subject: |
|
|
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 |
|
 |
ghosty1212
Joined: 30 Jul 2009 Posts: 15
|
Posted: Mon Dec 21, 2009 4:32 am Post subject: |
|
|
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 |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Mon Dec 21, 2009 5:07 am Post subject: |
|
|
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 |
|
 |
ghosty1212
Joined: 30 Jul 2009 Posts: 15
|
Posted: Mon Dec 21, 2009 5:09 am Post subject: |
|
|
| yeah it will be a specific point, so a lot of if's. that's what I was looking for, thanks. |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 460
|
Posted: Wed Dec 23, 2009 8:33 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|