请问,我如何才能使用c#来操作一个已经打开的windows窗体,比如说金山词霸.
不胜感激。。

解决方案 »

  1.   

    只能用API了,獲得你想要操作的窗口的句柄,再實現你想操作事情,
    百度裡有~搜搜吧!
      

  2.   

    API发消息.
    复杂些的控件如ListView32还要涉及跨进程的内存读写.
    LZ先找个Spy++把目标的窗体好好研究下吧.
      

  3.   

    三个API,GetWindowLong SetWindowLong SetLayeredWindowAttributes参考下[DllImport("user32.dll")]
    public static extern int GetWindowLong(int hwindow, int unindex);[DllImport("user32.dll")]
    public static extern int SetWindowLong(int hwindow, int unindex, int lnewvalue);[DllImport("user32.dll")]
    public static extern bool SetLayeredWindowAttributes(int hwnd, uint crKey, byte bAlpha, uint dwFlags);public const int GWL_EXSTYLE = -20;
    public const int WS_EX_LAYERED = 0x80000;
    public const int LWA_ALPHA = 0x2;
    public const int LWA_COLORKEY = 0x1;int handle = 0x7f063a;
    SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) ^ WS_EX_LAYERED);
    SetLayeredWindowAttributes(handle, 0, 128, LWA_ALPHA);
      

  4.   

    handle 你可以使用FindWindow获得
    [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
    private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);