Posts Tagged move hidden window

Moving Windows Part2

A little while ago a posted an application which was able to move windows remotely. After receiving some feedback from users who actually use this application (originally only made as proof of concept) I decided to work on it a little more.

So here’s a little Explanation how to use it:

  • download the aplication directly from this blog
  • run the executeable (.NET 1.1 is needed)
  • activate the window you want to move (use ALT+Tab or what ever you want)
  • the label should change and displays the actual position of your window
  • you can move the window via left,right,up and down-buttons

I think this should cover it. If somebody needs additional help or functionality just post it.

And as ususal code and executeable in the attachment.


, ,

No Comments

Moving Windows remotely with .NET

A colleague of mine has a dual-monitor windows system.

Unfortunatly he has a different monitor setup for home and work (work – 2nd monitor on the left; home – 2nd monitor on the right). Now when you work with certain Java applications which save their position on their own you come to the point where an window pops up out of the viewing range.

Now you hav nearly now way to move that window, because you can’t click it. Moving over the task bar doesn’t work either. So I wrote a simple Application which can move the lost window back into the viewing range.

Here a bit out of the c# code:

[ DllImport("user32.dll") ]
static extern IntPtr GetForegroundWindow(); 

[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);

[DllImport("user32.dll", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint);

private void timer1_Tick(object sender, System.EventArgs e)
	IntPtr temp  = GetForegroundWindow();
	if( me != temp)
		window = temp;
		label1.Text = window.ToString();
			RECT t = new RECT();
		bool r = GetWindowRect(window, out t);

		posx = t.Location.X;
		posy = t.Location.Y;
		sizex = t.Width;
		sizey = t.Height;
		label1.Text = label1.Text + "\nx: "  + t.Location.X+ "\ny: " + t.Location.Y
				+"\nwidth: "+sizex + "\nheight: " + sizey;

private void button2_Click(object sender, System.EventArgs e)
	posx = posx +10;
	MoveWindow((IntPtr)window, posx, posy , sizex, sizey, true);

This is just to get a basic idea what I’ve done here. You can also look at the complete source code yourself (vs2003 project is attached) or just use the application as is (although it is pretty ugly – more like a proof of concept.


follow-up here

    , ,

    No Comments