Help with virsuale keys

 

please help me with this code

I need to use v keys to right: (AaBb)


// First need to check if VK_CAPITAL is ON?

          keybd_event(VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0);// Press Shift Key

          keybd_event(VK_A, 0, WM_COMMAND, 0);              // Press A Key (To Right A not a)

          keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0); // release Shift

          keybd_event(VK_B, 0, WM_COMMAND, 0);   // Press A Key (To Right a not A)


the Shift key keep down.

 

I have this code for alt+r:

keybd_event(0x12,0,0,0);
keybd_event(0x52,0,0,0);
keybd_event(0x12,0,0x0002,0);
keybd_event(0x52,0,0x0002,0);

The page that listed the key codes and the other parameters was somewhere in Microsoft documentation I think.

You probably need to release the A before the shift.
 
kypa:

I have this code for alt+r:

The page that listed the key codes and the other parameters was somewhere in Microsoft documentation I think.

You probably need to release the A before the shift.

Thank you Kypa
still not working

I Tried  this:

// First need to check if VK_CAPITAL is ON?
          keybd_event(0x10, 0, WM_COMMAND, 0);// Press Shift Key
          keybd_event(0x42, 0, WM_COMMAND, 0);   // Press B
          keybd_event(0x42, 0, 0x0002, 0);   // Release B
          keybd_event(0x10, 0, 0x0002, 0); // Release Shift
          keybd_event(0x41, 0, WM_COMMAND, 0);   // Press A Key (To Right a not A)
          // The exit is: BA why? I need to be Ba

but still something wrong

thank you

 

This maybe:

keybd_event(0x10, 0, 0, 0);
keybd_event(0x42, 0, 0, 0);
keybd_event(0x10, 0, 0x0002, 0);
keybd_event(0x42, 0, 0x0002, 0);
keybd_event(0x41, 0, 0, 0);
keybd_event(0x41, 0, 0x0002, 0);

How do you check the exit?

 
kypa:

This maybe:

How do you check the exit?

thank you

still same problem. the main problem is : 

any key I use can not release it .

even VK_CAPITAL if I press it once it keep ON always.

 
memouz76:

thank you

still same problem. the main problem is : 

any key I use can not release it .

even VK_CAPITAL if I press it once it keep ON always.

I chexk the exit in the Log in window in the metatrader

 

Log? You mean Expert or Journal tab of Terminal subwindow or something else? What code are you using to show the output?

MS documentation:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646304(v=vs.85).aspx

keybd_event function (Windows)
  • msdn.microsoft.com
Synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function. Syntax Parameters bVk [in] A virtual-key code. The code must be a value in the range 1 to 254. For a complete list, see Virtual Key Codes. bScan [in] A...
 
kypa:

Log? You mean Expert or Journal tab of Terminal subwindow or something else? What code are you using to show the output?

MS documentation:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646304(v=vs.85).aspx

My project is :
I have to Log in to many metatrader accounts from my MQ4 indicator.

so I Open the Log in Window. 

than enter the Account number I need to log in , than I should enter the password and the server name.

password and server name has some capital char and small char.

thats why I need to change caps lock or use the shift key.

I tried the code above but still I can not reset the caps lock or shift key to normal after I press it first time.

thank you

 

ok I got it,

even if the key state is true I should to press the key than put it up

like this:

if(GetKeyState(VK_CAPITAL)==true){keybd_event(VK_CAPITAL,0x14,KEYEVENTF_EXTENDEDKEY | 0,0);
keybd_event(VK_CAPITAL,0x14,KEYEVENTF_KEYUP,0);}
Thank you
 
Logging in to different accounts from within an indicator opens up to way to so many opportunities... :D
 
kypa:
Logging in to different accounts from within an indicator opens up to way to so many opportunities... :D

Yes,

I manage about 200 accounts.

so I need to get report about each account. thats why I need to Log in to each one and get the information report.

do you have another way to get that?