Opening process and changing window position

前端 未结 3 1933
臣服心动
臣服心动 2020-11-28 12:15

I want to open from c# an application (standalone flashplayer) and set it position to (0,0) on the screen. How can I do this? So far I\'ve managed to open flashplayer:

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 12:47

    thanks guys, it's working now! :)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Threading;
    
    namespace swflauncher
    {
        class Program
        {
            static void Main(string[] args)
            {
                Process flash = new Process();
                flash.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
    
                flash.StartInfo.FileName = "D:\\development\\flex4\\runtimes\\player\\10\\win\\FlashPlayer.exe";
                flash.Start();
                Thread.Sleep(100);
    
                IntPtr id = flash.MainWindowHandle;
                Console.Write(id);
                Program.MoveWindow(flash.MainWindowHandle, 0, 0, 500, 500, true);
            }
    
            [DllImport("user32.dll", SetLastError = true)]
            internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
    
    
        }
    }
    

提交回复
热议问题