質問

私を使用しようとしているこ サンプルコード を制御するWindows XPの画面にキーボード(OSK.exeからC#(.純3.5)住所検索ライブラリ:

[DllImport("User32.dll")]public static extern Int32 SetForegroundWindow(int hWnd);  
[DllImport("user32.dll")]public static extern int FindWindow(string lpClassName, string lpWindowName);
private void BringToFront(string className,string CaptionName)        
{            
   SetForegroundWindow(FindWindow(className,CaptionName));        
}

private void Form1_Load(object sender, EventArgs e)        
{            
   BringToFront("Notepad", "Untitled - Notepad");                            
}

どうして判定する正確なclassName?なっているのでしょうかをCaptionNameは"画面のキーボード'.

役に立ちましたか?

解決

のclassnameは:"OSKMainClass"

こちらのコードを使って探します。すだけで簡単にC#の形態アプリ

    [DllImport("User32.dll")]
    public static extern Int32 SetForegroundWindow(int hWnd);
    [DllImport("user32.dll")]
    public static extern int FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll")]
    public static extern int GetClassName(int hWnd, StringBuilder lpClassName, int nMaxCount);
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        int hWnd =  FindWindow(null, "On-Screen Keyboard");
        StringBuilder buffer = new StringBuilder(128);
        GetClassName(hWnd, buffer, buffer.Capacity);
        MessageBox.Show(buffer.ToString());
    }

たことから以下のような情報源から 活性化の窓口とAPIMSDN GetClassName機能

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top