! Smart Package Robot 's Mouse-Operations / CPC. - Convert Pixel Coordinate

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Mouse-Operations >

! Smart Package Robot 's Mouse-Operations / CPC. - Convert Pixel Coordinate

CPC. - Convert Pixel Coordinate

Previous Top Next


MiniRobotLanguage (MRL)

 

CPC. Command

CPC. - Convert Pixel Coordinate

 

Compatible Engine_01Direct Engine_01

 

Intention

 

 

  The CPC.-Command helps you to convert between Coordinates that are scalend or unscaled due to Windows Size-Settings.

  As you can see in the picture below, the Setting is "125%".

This will lead to a shift of Pixel-Coordinates in some dpi-aware Applications.

Generally if you make things by 125% larger, the virtual Screen-Resolution is decreased.

To get back from 125% to normal, you could use the formula: X=X/100*125

This is what the "Scale-Command" does internally.

To Unscale the formula is as simple: X=X/125*100

This is done under the hood if you choose an Unscale-command.

 

The robot detects the current dpi-/scaling settings at the start of the script.

Therefore changing the DPI-Scaling while the script is running may prevent the script from correct scaling.

 

To get nearly the same effect you could just choose a lower Screen Resolution. This will make less problems with pixel-based automations.

 

The robot tries to automatically scale/unscale the situation, but if this does not work, you will need to manually correct the coordinates using the CPC. Commands.

CPC. will use scaled  or unscaled input in multiple ways and scale/unscale it with the current settings.

 

Possible Uses are:

- Coordinate based Script was recorded in scaled Mode and now is going to be played in unscaled mode

- Coordinate based Script was recorded in 100% and is now going to be played on a Client with Scaled coordinates

 

As said, in many cases it will just work, buit in some cases you may need to correct the coordinates.

 

 

DPI-Anzege

 

 

 

What is the "Active Point"?

The "active Point" is the "Focus Point" of the robot. It is the point "On screen", where the next robot action - for example a mouse-click - will happen.

 

The CPC.-command can move the active point in the conversion process. For this use the "x" option.

The CPC.-command can also convert Point- and Rect-Coordinates (Variables) in one step.

 

A complete sequence could look like this:

 

STW.ct|TaiMain.UnicodeClass|MiniRobot.sh6 - HelpMaker 7.3.40.0

SCW.nc|1|TcxButtonEdit

' This will just move the active point and put also the new coordinates on the stack

CPC.uax

MMV.

ENR.

 

 

 

 

Syntax

 

CPC.[P1][|P2][|P3]...

 

 

Parameter Explanation

 

 

P1 - (optional)  Prototype-String with any of the following options

       

       a - Use actual Point for input coordinate

       s - Scale Operation (you have the coordinate from 100% and want the coordinate from for example 125%)

        u - UnScale-up Operation (you have the coordinate from for example 125% and want the coordinate from  100%)

 p - use Point Input Variable. This is one Variable with both coordinates separated by "," e.g. see VAP. command

       r - use RECT as Input. Will also use a RECT for Output. if specified together with "a" then "Actual Rect" (from last window or object)  will be taken, otherwise RECT in Variable P2.

        x - If specified, the result of the Operation will be set as active Point/active Rect. Using Prototype "arx" for example

 f - just get the scaling factor, if one Variable P" is given, result is Point-Format, if two variables are there, P2 is X and P3 is Y-Factor

       

 Generally the Command looks how many Output and Input Variables are there and tries to find out, if the result should be given as Point or in two variables as coordinates.

 Using the "r"-Rect Option, you can also specify 4 variables to get each coordinate in one variable (left,top,right,bottom).

 

       

 

P2 .. PX - (optional) Depending on the used Prototypes, P2 ... P5 may be Input or Output-Variables.

 

 

 

 

Example

 

'***********************************

' CPC.

'***********************************

GSB.Lab_Get_Factor

 

' Otion "f"

§§STA=50

' Resultat zum Beispiel 1.25 - 1.25

CPC.f|$$XSD,$$YSD

JIV.$$XSD!$$XAL|ero

JIV.$$YSD!$$YAL|ero

 

§§STA=60

' Option "fp" mit Point-Variable

CPC.f|$$XSA

%Point_to_Vars $$XSA|$$XSD|$$YSD

JIV.$$XSD!$$XAL|ero

JIV.$$YSD!$$YAL|ero

 

' Option "u" und "s" mit extra Rückgabevariablen

§§STA=70

GSB.Vorbereiten

CPC.u|$$XPA,$$YPA|$$XSD,$$YSD

'MBX.$$XSD,$$YSD --- $$XPA,$$YPA --- $$XPB,$$YPB

JIV.$$XSD!$$XPB|ero

JIV.$$YSD!$$YPB|ero

 

§§STA=80

GSB.Vorbereiten

CPC.s|$$XPA,$$YPA|$$XSD,$$YSD

JIV.$$XSD!$$XPC|ero

JIV.$$YSD!$$YPC|ero

 

' Option "u" und "s" ohne extra Rückgabevariablen

§§STA=90

GSB.Vorbereiten

CPC.u|$$XPA,$$YPA

JIV.$$XPA!$$XPB|ero

JIV.$$YPA!$$YPB|ero

 

§§STA=100

GSB.Vorbereiten

CPC.s|$$XPA,$$YPA

JIV.$$XPA!$$XPC|ero

JIV.$$YPA!$$YPC|ero

 

' Option "u" und "s" mit POINT und extra Rückgabevariablen

§§STA=110

GSB.Vorbereiten

CPC.up|$$POA|$$XSD

JIV.$$XSD!$$POB|ero

 

§§STA=120

GSB.Vorbereiten

CPC.sp|$$POA|$$XSD

JIV.$$XSD!$$POC|ero

 

' Option "u" und "s" mit POINT und ohne Rückgabevariablen

§§STA=130

GSB.Vorbereiten

CPC.up|$$POA

JIV.$$POA!$$POB|ero

 

§§STA=140

GSB.Vorbereiten

CPC.sp|$$POA

JIV.$$POA!$$POC|ero

 

' Option "u" und "s" mit POINT und ohne Rückgabevariablen und "x"

§§STA=130

GSB.Vorbereiten

CPC.upx|$$POA

JIV.$$POA!$$POB|ero

MMV.

GMP.ms|$$POM

CPC.sp|$$POM

JIV.$$POA!$$POB|ero

 

§§STA=140

GSB.Vorbereiten

CPC.spx|$$POA

JIV.$$POA!$$POC|ero

MMV.

GMP.ms|$$POM

CPC.sp|$$POM

JIV.$$POA!$$POC|ero

 

MBX.READY

ENR.

 

'-----------------------------------------------------------

'

'-----------------------------------------------------------

:Lab_passed

SAV.Restore

$$RES=108

ENR.

'-----------------------------------------------------------

:Vorbereiten

IVV.$$XAL=0

 GSB.Lab_Get_Factor  

EIF.

VAN.$$XPA=300

VAN.$$YPA=250

VAP.$$POA=$$XPA,$$YPA

' Unscaled

CAL.$$XPB=300/$$XAL*100

CAL.$$YPB=250/$$YAL*100

VAP.$$POB=$$XPB,$$YPB

' Scaled

CAL.$$XPC=300/100*$$XAL|i

CAL.$$YPC=250/100*$$YAL|i

VAP.$$POC=$$XPC,$$YPC

 

'MBX.Scaled: $$POC   Unscaled: $$POB

RET.

'-----------------------------------------------------------

:ero

' Fehler aufgetreten

$$ERO=§§STA

MBX. Fehler in $script$ $crlf$bei $$ERO

$$RES=0

ENR.

'-----------------------------------------------------------

:Lab_Get_Factor

DPI.s|$$XSC,$$YSC

CAL.$$XAL=100*$$XSC

CAL.$$YAL=100*$$YSC

RET.

'-----------------------------------------------------------

' Convert Point-Variable to 2 Variables

 

: %Point_to_Vars 3

VAO.§§§02

VAO.§§§03

GSB.Lab_PTV|§§§01|§§§02|§§§03

END%

 

:Lab_PTV

SAV.Save|$$P01|$$P02|$$P03

VAP.$$P01=§§_01

GES.b|$$P01|,|$$P02

GES.d|$$P01|,|$$P03

VAI.§§_02=$$P02

VAI.§§_03=$$P03

SAV.Restore

RET.

 

 

 

Remarks

-

 

 

Limitations:

 

-

 

 

See also:

 

    LBO. - Left Border

    MLE. - Mouse-Left-Click Event

    MLM - Mouse Left click Move (Invinsible)

    MLI - Mouse Left Click quIckly (Invinsible)

    MRC. / MRI. - Mouse-Right-Click

    MMV - Mouse MoVe