Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening process and changing window position

Tags:

c#

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:

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();
        }
    }
}
like image 823
bartek Avatar asked Jun 13 '10 12:06

bartek


People also ask

How do I reset my screen position?

In Windows 10, 8, 7, and Vista, hold down the “Shift” key while right-clicking the program in the taskbar, then select “Move“. In Windows XP, right-click the item in the task-bar and select “Move“. In some instances, you may have to select “Restore“, then go back and select “Move“.

How do you change a window position?

This can be done by holding the Shift key and right-clicking the program's taskbar icon. Select Move from the menu that appears, and begin pressing the arrow keys to force the window to move position.

How do I reset the app positions in Windows 10?

After doing a little digging, try the following: Right click on the program's "icon" on the taskbar. Select Move. Use the keyboard arrows to move the window to the position you want.


1 Answers

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);


    }
}
like image 81
bartek Avatar answered Sep 22 '22 10:09

bartek