Forum Discussion

BenoitB's avatar
BenoitB
Community Hero
6 years ago
Solved

Size and Pos of Indicator

Hello,

 

I made a method for low-level click that works quite well unless under the Indicator.

I don't want to hide Indicator all time,  just hide it before clicking if click coordinates are under Indicator.

I didn't find the way to have size and pos of this Indicator so askting to Community.

 

My code:

 

/**
 * Click dans un objet via les méthodes Low Level
 * @author Biache Benoit
 * @memberof system
 * @function
 * @param {Object} Obj - Objet à cliquer, s'il n'est pas existant alors ignore le click
 * @param {number} [X=-1] - Position X du click depuis le bord gauche de l'objet, s'il est non défini ou défini à <b>-1</b> alors prend le milieu
 * @param {number} [Y=-1] - Position Y du click depuis le bord haut de l'objet, s'il est non défini ou défini à <b>-1</b> alors prend le milieu
 * @param {number} [Wait=200] - Durée en ms de l'appui sur le bouton gauche, la durée du relâchement est celle de l'appui / 2. Si elle n'est pas définie alors prend 200ms comme durée d'appui
 * @param {number} [Repeat=1] - Nombre de click à jouer. S'il n'est pas défini alors n'effectue qu'un clic
 */
function clickInObject(Obj, X = -1, Y = -1, Wait = 200, Repeat = 1) {
  if ((Obj == undefined) || (Obj == null) || ((Obj != null) && (!Obj.Exists)))
    return;
  X  = X == -1 ? Obj.Width >> 1 : X;
  Y  = Y == -1 ? Obj.Height >> 1 : Y;
  Xr = Obj.ScreenLeft + X;
  Yr = Obj.ScreenTop + Y;
  if (system.debug)
    Log.Message("clickInObject(Obj, " + X.toString() + ", " + Y.toString() + ", " + Wait.toString() + ", " + Repeat.toString() + ") - Click Low Level", "X reel = " + Xr.toString() + ", Y reel = " + Yr.toString() , pmLowest, system.logDebug);
  // Check if Indicator need to be hide 
  // if ...
  //   Indicator.Hide();
  for (let loop = 0; loop < Repeat; loop++) {
    LLPlayer.MouseDown(MK_LBUTTON, Xr, Yr, Wait);
    LLPlayer.MouseUp(MK_LBUTTON, Xr, Yr, Wait >> 1);
    aqUtils.Delay(100);
  }  
  // If Indicator was hidden, show it again
  Indicator.Show();
}

 

 

.