Download MetaTrader 5

Arrange windows by simulating ALT+R doesn't work

To add comments, please log in or register
Marcus Riemenschneider
175
Marcus Riemenschneider  

Hey guys,

can someone tell me what's wrong with this script?


#property strict

#define  VK_R 0x52                              //--- letter R
#define  VK_LMENU 0xA4                          //--- left key of Alt
#define  KEYEVENTF_KEYUP 0x0003                 //--- key is released
#import "user32.dll"
    void keybd_event(int bVk, int bScan, int dwFlags, int dwExtraInfo);
#import

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   keybd_event(VK_LMENU, 0, 1, 0);
   keybd_event(VK_R, 0, 0, 0);
   keybd_event(VK_R, 0, KEYEVENTF_KEYUP, 0);
   keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP, 0);
   
  }
//+------------------------------------------------------------------+
whroeder1
16080
whroeder1  
Marcus Riemenschneider: can someone tell me what's wrong with this script?
Key up value is wrong. Try:
#property strict

#include <WinUser32.mqh>

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   keybd_event(VK_LMENU, 0, 1, 0);
   keybd_event(VK_R, 0, 0, 0);
   keybd_event(VK_R, 0, KEYEVENTF_KEYUP, 0);
   keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP, 0);
   
  }
//+------------------------------------------------------------------+
Marcus Riemenschneider
175
Marcus Riemenschneider  
whroeder1:
Key up value is wrong. Try:


I changed it but it still doesn't work. Then I only changed the value for key up and this also doesn't work.

Very strange because it works in another indicator where I am using a hotkey (CTRL + O).


Any other idea?

honest_knave
Moderator
2322
honest_knave  
#property strict
#import "user32.dll"
    void keybd_event(int bVk, int bScan, int dwFlags,int dwExtraInfo);
#import
#define  REL 0x0002
#define  ALT 0x12  
#define  R   0x52

void OnStart()
  {
   keybd_event(ALT,0,0,  0);
   keybd_event(R,  0,0,  0);
   keybd_event(ALT,0,REL,0);
   keybd_event(R,  0,REL,0);
  }
 
Marcus Riemenschneider
175
Marcus Riemenschneider  
honest_knave:
 


Works perfect now! Thank you! :)

I used a wrong value for ALT. Obviously there was an error in the key-code-table I where found it.

To add comments, please log in or register