WindowsメッセージのIDと効能を調べる。

過去2日間の記事で、「MetaTraderを制御するには、Windowsメッセージが使える」という印象を持ってもらえたかと思うのですが、今日は、どのメッセージIDで何ができるのかを調べる方法...の1つ...を紹介します。


1年以上昔に、とあるロシア人が考案した手法は…


「総当り的にメッセージIDを送りまくって、MT4 の反応を観察する」というモノでした...orz
具体的なコードは、

#property copyright "forextrader@tochka.ru" 
#include 
int hwnd;
void start()
{ 
	for (int i = 0; i < 100000; i++)
	{ 
		hwnd = WindowHandle(Symbol(),Period());
		PostMessageA(hwnd, WM_COMMAND, i, 0);
		Print(i);
		Sleep(3000);// 要調整
	}
}

で、WindowHandle で取得したウィンドウに対して、WM_COMMAND タイプのメッセージをパラメータ i = 0〜100000まで送りつけています。WM_COMMAND は、メニューやボタンを押した時に送られる定番のメッセージで、MT4 の操作方法を調べるのに相応しいのですが、、、この方法では非常に時間が掛かるので、正直、よくやるなぁ…といった感じです。^^;

メッセージの送り先は、1つ上か3つ上のウィンドウにした方が良い場合もありそうな気がしますが、敬意を表して、このロシア人が作り出した一覧表を転載しておきます。

33017 - make Autoscroll
33018 - switch to the submission of "Bars"
33019 - switch to make "Candles"
33021 - Grid (Ctrl + G)
33022 - switch to the submission of "Line"
33023 - shift schedule
33024 - volumes (Ctrl + L)
33025 - zoom in
33026 - zoom out
33054 - save as picture
33134 - timeframe D1
33136 - timeframe H4
33137 - timeframe M1
33138 - timeframe M5
33139 - timeframe M15
33140 - timeframe M30
33141 - timeframe W1
33157 - properties F8
33220 - Graphic template, save the template
33230 - paste-down arrow
33231 - Paste-Up
33232 - icons-ticks
33233 - cross
33234 - the cursor
33235 - Box-cyclical Line
33236 - equidistant channel
33237 - Fibonacci lines
33238 - Box-Fibonacci-arc
33239 - Box-Fibonacci-fan
33240 - Box Channels, Fibonacci
33241 - Box-Gann-grid Hanna
33242 - Box-Gann-line Hanna
33243 - Box-Gann-fan Hanna
33244 - horizontal line
33246 - Box Andrews pitchfork
33247 - Box-shape-rectangle
33248 - Box-channels-linear regression
33251 - Box-icons-stop
33253 - text
33254 - Box-icons-bad
33255 - Box-icons-well
33256 - Box-Fibonacci-time-zone
33257 - trend line
33258 - Box-Line-trend line for the corner
33259 - Box-figure-triangle
33260 - Vertical Line
33261 - text label
33315 - View tester strategies?
33334 - timeframe MN
34300-34699 (?) - Custom indicators in alphabetical order
34700 - Indicators-moving average of oscillator
34701 - Indicators-accelerator oscillator
34702 - Indicators-accumulation/distribution
34703 - Indicators-alligator
34704 - indicators-average directional movement index
34705 - indicators-average true range
34706 - Indicators-awesome oscillator
34707 - Indicators-bears power
34708 - indicator-bollinger bands
34709 - Indicators-bulls power
34710 - Indicators-commodity channel index
34711 - Indicators-demarker
34712 - Indicators-envelopes
34713 - Indicators-force index
34714 - Indicators-fractals
34715 - Indicators-gator oscillator
34716 - Indicators-ichimoku kinko hyo
34717 - Indicators-macd
34718 - indicators-market facilitation index
34719 - Indicators-momentum
34720 - indicators-money flow index
34721 - indicators-moving averages
34722 - Indicators-on balance volume
34723 - Indicators-parabolic sar
34724 - indicators-relative strength index
34725 - indicators-relative vigor index
34726 - Indicators-standard deviation
34727 - Indicators-stochastic oscillator
34728 - Indicators-volumes
34729 - Indicators-william's percent range
35400 - timeframe H1
35454 - order buylimit
35455 - order buystop
35456 - order selllimit
35457 - order sellstop
35458 - the new order F9
35464 - right price tag
35511 - Graphic template-download template
57602 - close the current chart

この表は、調査当時のMetaTraderのビルドで有効なので、最新版では機能しない可能性があるので要注意です。
次回は、もう少し実用的なIDの調べ方を紹介します。