virtual key board as a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nayanar
    New Member
    • Feb 2010
    • 11

    #16
    hey guys,

    i found out the solution

    in app1

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace buttons
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            //**********Using event in user32 for sending button value****************//
    
            [DllImport("user32")]
            public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int
            dwExtraInfo);
            private const byte VK_MENU = 0x12;
            private const byte VK_TAB = 0x09;
            private const int KEYEVENTF_EXTENDEDKEY = 0x01;
            private const int KEYEVENTF_KEYUP = 0x02;
    
            //************************************************************************//
    
            private void button1_Click(object sender, EventArgs e)
            {
                prevwin();//function to go to previously active window
                keybd_event(0x60, 0, 0, 0);// key press event 
                keybd_event(0x60, 0, KEYEVENTF_KEYUP, 0);// key release event 
            }
            private void button2_Click(object sender, EventArgs e)
            {
                prevwin();
                keybd_event(0x61, 0, 0, 0);
                keybd_event(0x61, 0, KEYEVENTF_KEYUP, 0);
            }
    
            private void prevwin()
            {
                // using ALT TAB to go to previously active window
    
                keybd_event(VK_MENU, 0xb8, 0, 0); //Alt Press 
                keybd_event(VK_TAB, 0x8f, 0, 0); // Tab Press 
                keybd_event(VK_TAB, 0x8f, KEYEVENTF_KEYUP, 0); // Tab Release 
                keybd_event(VK_MENU, 0xb8, KEYEVENTF_KEYUP, 0); // Alt Release
            }       
        }
    }
    In app2

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace textboxs
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Shown(object sender, EventArgs e)
            {
                textBox1.Focus();
            }
    
                    
        }
    }

    I got it Properly. try it out :-). Thank you very much for the help and concern.

    Comment

    • vishal1082
      New Member
      • Apr 2009
      • 92

      #17
      good job but this worries me, user may see the Alt+Tab menu while typing and it loses and gains focus again and again, and instead of using the Imported API's
      Code:
      SendKeys.Send(Keys.Enter.ToString());
      you could have used this, sends "enter" key to the active window.

      Comment

      • nayanar
        New Member
        • Feb 2010
        • 11

        #18
        Hi,

        as i opened both of the application using exe file and tried if the code works, then i did not get ALT+TAB menu. I surely try what u have mentioned above. thank you.

        Comment

        Working...