Errors, bugs, questions - page 2523

 
Sergey Dzyublik:

It worked with WM_CONTEXTMENU.
Slightly tweaked the code, it's easier to debug and can be reused:

Thank you, the menu appears!

Baffled how to select a menu item. Tried WM_ENTERIDLE and MN_GETHMENU, no luck.

Isn't selecting a certain menu item itself an internal MT5 command?


ZZY This option did not work.

  const long hwnd = GetMenu(handle);
  PRINT64(hwnd);
  PRINT64(user32::SendMessageW(hwnd, WM_KEYDOWN, VK_DOWN, 0));
 
fxsaber:

Isn't selecting a particular menu item itself some sort of internal MT5 command?

Yes, that's what was hinted at in the beginning. but internal commands don't seem to work without registermessage
 
TheXpert:
Yes, that's what was hinted at in the beginning. but internal commands don't seem to work without registermessage

Everyone knows how to do Register for MT4. But MT5...

 
fxsaber:

Everyone knows how to do Register for MT4. But MT5...

Yes.
 
Tried to use the ideas from this sourcebook, again it didn't work!
  string nullstring;
  const long hpopup=FindWindowW("#32768", nullstring);

#define  MN_GETHMENU     0x01E1  
  const long hmenu = SendMessageW(hpopup, MN_GETHMENU,0,0);
  
  uint id=GetMenuItemID(hmenu, 0);
#define  WM_COMMAND                     0x0111
  SendMessageW(RootHandle,WM_COMMAND,id,0);
 
fxsaber:
Tried to use the ideas from this sourcebook, again it didn't work!


#include <WinAPI\winuser.mqh>

#define  GA_ROOT            0x00000002
#define  WM_CONTEXTMENU     0x007B
#define  MN_GETHMENU        0x01E1

#define  TVM_GETITEM                 0x110C
#define  TVM_GETNEXTITEM             0x110A


#define  PRINT(x) ; Print(#x, ":", string(x))
#define  PRINT64(x) ; printf("%s%s%#.08x", #x, ":", x)


long GetHandle(long handle, int &controls[]){
   long next_handle = handle;                                                                        
   for (int i = 0; i < ArraySize(controls); i++){
      next_handle = user32::GetDlgItem(next_handle, controls[i]);
      PRINT64(next_handle);
   }           
   return next_handle;                
}
  

void OnStart(){
  long RootHandle = user32::GetAncestor(::ChartGetInteger(0, CHART_WINDOW_HANDLE), GA_ROOT);
  PRINT64(RootHandle);  
  
  int controls[] = {0xE81E, 0x804E, 0x28EF, 0x28FE}; 
  long handle = GetHandle(RootHandle, controls);
  PRINT64(handle);
  
  //PRINT(user32::SendMessageW(handle, WM_CONTEXTMENU, 0, -1));
  PRINT(user32::PostMessageW(handle, WM_CONTEXTMENU, 0, -1));
  PRINT("Sleep");
  
  Sleep(10);
  long hwnd = FindWindowW("#32768", "");
  PRINT64(hwnd);
  
  long menu_handle = SendMessageW(hwnd, MN_GETHMENU, 0, 0);
  PRINT(IsMenu(menu_handle));
  PRINT(GetMenuItemCount(menu_handle));
    
  long sub_menu_handle = GetSubMenu(menu_handle, 1);   // 9
  PRINT(GetMenuItemCount(sub_menu_handle));            // 1
}
 
fxsaber:
Tried to use the ideas from this source code, again it didn't work!

It seems to simulate pressing the keyboard arrows and clicking on the menu:

#define  WM_KEYDOWN                     0x0100
#define  WM_KEYUP                       0x0101
#define  WM_LBUTTONDOWN                 0x0201
#define  WM_LBUTTONUP                   0x0202
#define  VK_UP                          0x26
#define  VK_DOWN                        0x28


//перемещение по меню (сколько пунктов, столько раз)
PostMessageW(handle, WM_KEYDOWN, VK_DOWN,0);
PostMessageW(handle, WM_KEYUP, VK_DOWN,0);

//нажатие пункта
SendMessageW(handle,WM_LBUTTONDOWN,0,0); 
SendMessageW(handle,WM_LBUTTONUP,0,0);
 
Sergey Dzyublik:

Thanks, I got it. The menuspy programme I picked up here was very helpful.

Drafts by kero
  • wasm.in
(NB: некоторые порой потребуется запускать as admin, а то и as system) -WinDrag Однажды наткнулся на австралийский "The Customiser" by Wanga...
 
Alexey Navoykov:

I was responding to a specific phrase. Calm down. Take some valerian and go to bed, it's not good for you to worry. ...Some people get hot when they hear the word "C++".

I wasn't replying to you only, if you don't get it, and your phrase is quite revealing... Whether I'm worried or not, I'll decide myself, without your participation. So don't be rude and drink some valerian, you won't like what I have to say.

Everyone who is interested, outraged, perplexed by differences in MQL vs C++ - create a separate topic and discuss it all there on your own. Or may I help?

 
Break, the hot Finnish guys.
Reason: