How to trigger event by for example "Shift + z" key ?

 

I've been looking for the answer to the captioned question, but been unable to find it so far.

CHARTEVENT_KEYDOWN can only pass code of a(one) pressed key by lparam. Thus it can not tell "shift + z" key input from "z" key input.

Is there any way to capture a set of two key inputs, like "Ctrl + a", "Shift + z", etc. to trigger an event ?

Any help would be appreciated.

 
Have you tried to figure out what is:
Value of the sparam parameter ?
 
Soewono Effendi #:
Have you tried to figure out what is:
Value of the sparam parameter ?

No, as I could not find the explanation about a bit mask describing the status of keyboard buttons for CHARTEVENT_KEYDOWN in MQL4 reference although I wondered what it is.

I assume that a bit mask describing the status of "Shift" key for CHARTEVENT_KEYDOWN and CHARTEVENT_MOUSE_MOVE are different.

If so, where I can find the bit mask of keyboard information for CHARTEVENT_KEYDOWN ?

 
cloudwandering #:

No, as I could not find the explanation about a bit mask describing the status of keyboard buttons for CHARTEVENT_KEYDOWN in MQL4 reference although I wondered what it is.

I assume that a bit mask describing the status of "Shift" key for CHARTEVENT_KEYDOWN and CHARTEVENT_MOUSE_MOVE are different.

If so, where I can find the bit mask of keyboard information for CHARTEVENT_KEYDOWN ?

Simply try to Print(sparam) while pressing SHIFT / CTRL / ALT - key and monitor this sparam value.
You could also try to press L/M/R-mouse button.

enjoy


For your reference:
https://www.mql5.com/en/book/applications/events/events_keyboard
MQL5 Book: Creating application programs / Interactive events on charts / Keyboard events
MQL5 Book: Creating application programs / Interactive events on charts / Keyboard events
  • www.mql5.com
MQL programs can receive messages about keystrokes from the terminal by processing in the OnChartEvent function the CHARTEVENT_KEYDOWN events. It...
 
cloudwandering #:

No, as I could not find the explanation about a bit mask describing the status of keyboard buttons for CHARTEVENT_KEYDOWN in MQL4 reference although I wondered what it is.

I assume that a bit mask describing the status of "Shift" key for CHARTEVENT_KEYDOWN and CHARTEVENT_MOUSE_MOVE are different.

If so, where I can find the bit mask of keyboard information for CHARTEVENT_KEYDOWN ?

While reviewing forum topic MQL4 site automatically provided, which is Can I check if CTRL or SHIFT is pressed when using CHARTEVENT_KEYDOWN?.

I find the solution, so closing this topic.

Thank you for your support.

MQL5 forum
MQL5 forum
  • www.mql5.com
MQL5: Forum on automated trading systems and strategy testing
 
Soewono Effendi #:

Simply try to Print(sparam) while pressing SHIFT / CTRL / ALT - key and monitor this sparam value.
You could also try to press L/M/R-mouse button.

enjoy


For your reference:
https://www.mql5.com/en/book/applications/events/events_keyboard

 Thank you for sending useful site that covers full information of keyboard events.

I will keep digging into MQL site next time, believing an answer to my question must exist somewhere.

 

Hi

You can try with some “flags” and mask for OnChartEvent function. For example you can set some flag “shiftpressed” as true when shift button is pressed and then only if this flag is true, detect if “Z” button is pressed and only with that combination follow your chosen action. Of course you should add also deactivation of the flag as soon as key is released or other key is pressed, but with some programming skills it’s doable to code.

Have a nice day👍📊