我想从c#应用程序(独立flashplayer)打开并在屏幕上将其设置为(0,0).我怎样才能做到这一点?到目前为止,我已经设法打开flashplayer:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
bar*_*tek 42
谢谢你们,它现在正在工作!:)
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);
}
}
Run Code Online (Sandbox Code Playgroud)
启动后Process,MainWindowHandle应将其属性设置为某个Windows句柄,该句柄可用于使用已启动应用程序的主窗口进行操作.我认为没有办法直接使用.NET API移动它,但您可以MoveWindow通过P/Invoke 使用API函数.
以下是一些链接,您可以在其中找到更多信息:
MainWindowHandleProcessMSDN的财产MoveWindowpinvoke.net上的API函数| 归档时间: |
|
| 查看次数: |
30928 次 |
| 最近记录: |