How do I determine whether the scroll button is pressed or depressed and if so, depress it ! - page 6

 
LEOK:

If this is the function, I still need the inside of it...

// 3.2.1. The function returns the auto-scrolling state of the specified graph. If successful, the function returns TRUE, otherwise it returns FALSE.
bool ServiceGetAutoScroll(int hwndChart); // The system descriptor of the chart window from which the auto-scroll state is returned.

You won't be satisfied with the internals of the function. And I would have too much to copy from different places. I have a class for working with MT4 windows. Everything is done centrally there. Too much has to be copied.

This function, for example:

// 3.2.1. Функция возвращает состояние автопрокрутки на указанном графике. В случае успеха функция возвращает TRUE, иначе - FALSE.
EXPFUNC(BOOL) ServiceGetAutoScroll(const HWND hwndChart) // Системный дескриптор окна графика, с которого возвращается состояние автопрокрутки.
 {
  try
   {
    Init(); // Инициализация библиотеки.
    return(MT4_WINDOWS->GetAutoScroll(hwndChart));
   }
  catch(TCHAR* szExclusion)
   {
    Utils::Debugging::MessageBoxStop(_T("ServiceGetAutoScroll()"), szExclusion);
   }
  catch(tstring &sExclusion)
   {
    Utils::Debugging::MessageBoxStop(_T("ServiceGetAutoScroll()"), sExclusion);
   }
  catch(...)
   {
    Utils::Debugging::MessageBoxStop(_T("ServiceGetAutoScroll()"), _T("Системная ошибка!") + LAST_ERROR);
   }
  return(FALSE);
 }

Will it suit you? There is a whole class behind the GetAutoScroll() method.

Use what has already been done so that you don't waste your time. Otherwise, you may start programming by developing your own processor, or better yet, by mining and processing silicon.

 

Anyway, the first version of the script seems to work somehow !

Of course, there are simpler and more reliable versions, but I never got them ...

The script is attached ...

Files:
getpixel.ex4  5 kb
 
If you want to show me the code, show me the code. If you don't want to show me the code, don't say anything.
 
FAQ:
If you want to show it, show the code. If you don't want to show the code, keep quiet.


So it's all been discussed and shown ...

There is nothing hidden in this code, please:

#property copyright "Copyright © 2012 ЛЕО"
#import "user32.dll" 
      int      GetWindow            (int, int);
      int      GetAncestor          (int hWnd, int gaFlags);
      int      GetWindowTextLengthA (int);
      int      GetWindowTextA       (int, string, int);
      int      GetWindowDC          (int hWnd);
#import
#import "gdi32.dll" int GetPixel (int hDC, int x, int y);

int         hwnd, hg, h;
string      Name = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
string      pr[2];

int deinit() {ObjectsDeleteAll();Comment ("");}

int start() {
      ObjectsDeleteAll(); Comment ("");
      int hwnd  = GetAncestor (WindowHandle(Symbol(),Period()),2); //дескриптор основного окна терминала
      
      // Первое дочернее окно
      int temp  = GetWindow (hwnd, 5);              
      GetWindowTextA (temp, Name, GetWindowTextLengthA(temp)+1);
      
      // Поиск первого дочернего окна по имени
      if (Name != "Стандартная" || Name == "Графики" || Name == "Графические инструменты") {
            for (int i=0;i<10;i++) {
                  temp  = GetWindow (temp, 2);  if (temp == 0) break;
                  GetWindowTextA (temp, Name, GetWindowTextLengthA(temp)+1);
                  if (Name == "Стандартная" || Name == "Графики" || Name == "Графические инструменты") {hg = temp; break;}
            }
      } else hg = temp;
      
      // Поиск второго дочернего окна "Графики"
      int h  = GetWindow (hg, 5);              
      GetWindowTextA (h, Name, GetWindowTextLengthA(h)+1);
      if (Name != "Графики") {
            for (i=0;i<10;i++) {
                  h  = GetWindow (h, 2);  if (h == 0) break;
                  GetWindowTextA (h, Name, GetWindowTextLengthA(h)+1);
                  if (Name == "Графики") break;
            }
      }
      
      // если цвет пикселя кнопки =10526880, значит кнопка нажата, в противном случае нет
      while (!IsStopped()) {
            if (GetPixel (GetWindowDC(h),166,3) == 10526880) pr[0] = "ПРОКРУТКА"; else pr[0] = "прокрутка";
            if (GetPixel (GetWindowDC(h),200,3) == 10526880) pr[1] = " СМЕЩЕНИЕ"; else pr[1] = " смещение";
            Comment ("\n ",pr[0],pr[1]); Sleep(500);
      }
      return(0);
}

 
I personally don't really give a shit. If I have to, I'll read the Ex4. I'm worried about other participants who might then have a similar question.
 

Weaknesses in the code:

1. there is no linkage to the graph. This code will retrieve the button position of any active chart.

2. This code does not provide for autonomous panel position. That is, this code will not always work.

3. This code works only with the Russian localization.

4. It is interesting, but not very gentlemanly :-)).

It is scary to look at WinAPI code in MLQ4 after C++.

 

I'm sorry, I just made it up with what I could think of, I'm a beginner, not an ACC like you!

That's why I asked for the code to be posted so that there would not be these 3 disadvantages !

I don't understand about the colour (4th point) !?

 
LEOK:

About the colour (4th point) I don't get it !?

I'm shocked about the colour as well.
What's wrong with TB_ISBUTTONCHECKED ?
 
LEOK:

I'm sorry, I just made it up with what I could think of, I'm a beginner, not an ACC like you!

That's why I asked for the code to be posted so that there would not be these 3 disadvantages !

I don't understand about the colour (4th item)!

It's a technical culture like that. It is not cultural to unscrew bolts and nuts with pliers. There is a spanner for that.

How to do without these 3 disadvantages, has already written several times.

 
jartmailru:
I'm shocked about the colour, too.
Why is TB_ISBUTTONCHECKED so annoying?


You can't say: like or dislike it if I haven't seen it, don't know and haven't tried it !

That's why I'm asking for help and once again asking for a code example with TB_ISBUTTONCHECKED on mql4 ...

Reason: