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:
Once you start the Process
, its MainWindowHandle
property should be set to some Windows handle that can be used for manipulating with the main window of the started application. I don't think there is a way to move it directly using .NET API, but you can use the MoveWindow
API function via P/Invoke.
Here are some links where you can find more information:
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);
}
}
Try SetWindowPos
as described here. This page shows how to call it from C#.