mahecu Posted December 13, 2007 Share Posted December 13, 2007 Hi, I have a watir script where I am using an autoit control to get the mouse to click on certain web page locations. I would like to know if there is a method for getting the screen width and height, to then supply the coordinates to the autoit control. Mark Link to comment Share on other sites More sharing options...
therks Posted December 13, 2007 Share Posted December 13, 2007 In AutoIt you can use @DesktopWidth and @DesktopHeight to get those values. Don't know about your watir issue though. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
zfisherdrums Posted December 13, 2007 Share Posted December 13, 2007 Hello mahecu, Would you mind sharing your WATiR script. You can PM me if you do not wish to "junk up" the forum with non-AuoIt code. I'm curious as to why you're needing AutoIt to handle control events on the web page. Is this just a workaround for a particularly nasty web element? Zach... Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
mahecu Posted December 14, 2007 Author Share Posted December 14, 2007 Hi Zach, Thanks for your interest. I am using AutoIt as a workaround. I am writing watir scripts to test an access control system my company develops. The system is accessed through Internet explorer and has many uncommon elements which I cannot attach to. In the case of the screenshot below I need to be able to click on the red bars and drag the mouse downwards to set timezones. The code below shows the mouse coordinates I am currently using but these only work when the screen resolution is set to 1024 x 768. If I can get the screen width and height I can then base my coordinates on these values. For example, currently I have an x coordinate of 275 using the 1024 x 768 resolution but if this coordinate is used with a 1280 x 1024 resolution it will not click in the same place. If I can get the screen width I can set up a variable that calculates the correct coordinate for that screen position whatever the resolution is by multiplying the screen width by 275/1024. a = WIN32OLE.new("AutoItX3.Control") $ie.send_keys('{F11}') # set browser to fullscreen mode to prevent toolbars from skewing coordinates a.mouseclickdrag("left",275,195,275,479,0) # set timezone for sunday a.mouseup a.mouseclickdrag("left",325,195,325,479,0) # set timezone for monday a.mouseup a.mouseclickdrag("left",375,195,375,479,0) # set timezone for tuesday a.mouseup a.mouseclickdrag("left",425,195,425,479,0) # set timezone for wednesday a.mouseup a.mouseclickdrag("left",475,195,475,479,0) # set timezone for thursday a.mouseup a.mouseclickdrag("left",525,195,525,479,0) # set timezone for friday a.mouseup Thanks, Mark Hello mahecu, Would you mind sharing your WATiR script. You can PM me if you do not wish to "junk up" the forum with non-AuoIt code. I'm curious as to why you're needing AutoIt to handle control events on the web page. Is this just a workaround for a particularly nasty web element? Zach... Link to comment Share on other sites More sharing options...
zfisherdrums Posted December 15, 2007 Share Posted December 15, 2007 (edited) a = WIN32OLE.new("AutoItX3.Control") width = a.WinGetPosWidth( ie.url, "") height = a.WinGetPosHeight(ie.url, "") I'm not sure if I'm accessing the URL property correctly but I think the idea comes across. Zach... Edited December 15, 2007 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
mahecu Posted December 17, 2007 Author Share Posted December 17, 2007 Hi Zach, Thanks for your help, really appreciate it. At the moment I keep getting width and height values of 1 but I think you have put me on the right path to my solution. Cheers, Mark a = WIN32OLE.new("AutoItX3.Control") width = a.WinGetPosWidth( ie.url, "") height = a.WinGetPosHeight(ie.url, "") I'm not sure if I'm accessing the URL property correctly but I think the idea comes across. Zach... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now