Forum Discussion

kirk_bottomley's avatar
kirk_bottomley
Contributor
10 years ago

Drawing with Low Level XY

One of the tests my company has always had to do manually is drawing on calibrated bitmap images, clicking at labelled points in the picture to calibrate medical protocols.

I can record the test with a Low Level procedure, and generate the list of X-Y coordinates and interactions, and the test will run fine on the machine I record the test with. However, if the playback machine has a different resolution it will not play back properly.

I can get the resolution of the playback machine, and the twips conversion they have as a result (see below for the code I found), but I don't know how to apply the conversion during playback. I would really rather not have to manually convert all the coordinates even once, let alone doing it for each possible resolution. 

 

Is there a way to convert X-Y playback on the fly with a conversion formula for different resolutions?

 

How to extract Twips on the playback machine:

This will return the machine's Twips per Pixel. Just call the function when you need to insert the Twips into a formula instead of "magic numbers" like 12 or 15 (that may or may not be correct).

function Twips()
{
var hWnd = Win32API.GetDesktopWindow();
var hDC = Win32API.GetDC(hWnd);
var logPixY = Win32API.GetDeviceCaps(hDC, Win32API.LOGPIXELSY);

Win32API.ReleaseDC(hWnd, hDC);

return 1440 / logPixY;
}
  • Ravik's avatar
    Ravik
    Super Contributor

    Hi Kirk,

     

    I think it would be better to take X-Y Coordination as runtime, If you taken runtime it will give X-Y Cordination on the basis of screen resolution

     

    like -

     

    With objGrid.TBL_objName

     

    intXCordination = .EmbeddableTextBoxWithUIPermissions.Right

    intYCordination =.EmbeddableTextBoxWithUIPermissions.top

    Call .Click (intXCordination, intYCordination)

    Delay(100)

     

    End With

     

    it may help you.

     

    • kirk_bottomley's avatar
      kirk_bottomley
      Contributor
      I think it would be better to take X-Y Coordination as runtime

      I can get the X-Y coordinates of the click points in the bitmap on my system for my resolution. I can record them in a low level procedure relative to the window that displays them. However, I can't know ahead of time what resolution a tester will have, and the bitmap scales with it. I could record a low level procedure for every known resolution, but that would be extraordinarily time consuming. 

      The window scales to the resolution. I can determine the resolution. I could theoretically scale the recorded X-Y coordinates accordingly at runtime, but that's what I'm posting about: how to do that. 

       

      I appreciate the input, but it looks like the code you posted requires me to know where to click at design time. I'm not having an issue seeing or clicking objects, I need a way to click precisely at specific points on an image. I see the image display box, I can click the points on my system, I just need a way to translate those coordinates to another system's resolution.

       

      So essentially, something that can catch the XY coordinates coming out of the playback, and apply a conversion. I'm recording the clicks at 1920x1080, so on any system that plays it back, instead of clicking (X,Y), it clicks:

      ((X / 1920 * CurrentMachineHeight), (Y / 1080 * CurrentMachineWidth)).