Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
See more:
Using SendKey class to send keystroke to any windows application.
It works fine, but it doesn't work om Mac OS run in VMware.

Please any one suggest me.
C#
[DllImport("user32.dll", SetLastError = true)]
      static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

public static void test()
      {
          byte VK_TAB = 0x09; // Windows tab keycode
          byte VK_TAB = 0x30; // Mac OS tab keycode

          const int KEYEVENTF_KEYUP = 0x2;
          const int KEYEVENTF_KEYDOWN = 0x0;

          keybd_event(VK_TAB, 0, KEYEVENTF_KEYDOWN, 0);
          keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);
      }

I have to create test method which send tab keystroke to another application.
It is working perfect in Windows, but not working in Mac OS which run in VMware in windows.

Please help me.
Posted
Updated 31-Mar-12 2:08am
v3
Comments
Kschuler 22-Mar-12 15:30pm    
I gave your question a vote of 3. I don't think it should have been downvoted just because the answer to your question is that it's not possible. I'm sure lots of people have run into this issue.
André Kraak 31-Mar-12 8:08am    
Edited question:
Added pre tags
Formatted text/code
Spelling/Grammar

1 solution

Yeah, and it's never going to. SendKeys will only with with Windows. You cannot send a keystroke to Mac O/S running in a VM because Mac O/S has no idea what to do with the Window message.
 
Share this answer
 
Comments
ProEnggSoft 22-Mar-12 14:39pm    
Good answer. 5!
Shahin Khorshidnia 22-Mar-12 14:40pm    
My 5
mayur1112 31-Mar-12 6:50am    
[code]
[DllImport("user32.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

public static void test()
{

byte VK_TAB = 0x09; // Windows tab keycode

byte VK_TAB = 0x30; // Mac OS tab keycode

const int KEYEVENTF_KEYUP = 0x2;

const int KEYEVENTF_KEYDOWN = 0x0;

keybd_event(VK_TAB, 0, KEYEVENTF_KEYDOWN, 0);

keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);
}[/code]


i have to create test method which send tab keystroke to another app . its working perfact in windows but not working in Mac OS which run in VMware in windows . please help me ..
[no name] 31-Mar-12 8:36am    
Posting your code and asking again is not going to make it possible. What you want to do is just not possible. If you really really need to do this then you might ask Apple to rewrite their OS to accept Windows messages.
Dave Kreskowiak 31-Mar-12 9:42am    
Yeah? So what? I already told you that it is IMPOSSIBLE to send keystrokes to Mac O/S from Windows.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900