0

Im doing a basic test MoveWindow(handle, 0, 0, 1280, 720, true) on DeSmuME's process and it results in no changes at all, I at least expected its X/Y pos to change to 0 (top left of the screen), but nope, nothing at all, whats strange though is its getting the handle fine and RECT structure works on it too, it manages to get the positions fine.

[StructLayout(LayoutKind.Sequential)]
public struct RECT {
  public int left;
  public int top;
  public int right;
  public int bottom;
}
[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT Rect);

[DllImport("user32.dll", SetLastError = true)]
static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int Width, int Height, bool Repaint);
static void Main(string[] args) {
  Process[] processes = Process.GetProcessesByName("DeSmuME_X432R_x64");
  foreach (Process p in processes) {
    IntPtr handle = p.MainWindowHandle;
    RECT Rect = new RECT();
    if (GetWindowRect(handle, ref Rect)) {
      MoveWindow(handle, 0, 0, 1280, 720, true);
    }
    Console.WriteLine(Rect.right);
    Console.ReadLine();
  }
}
  • Before focusing on whether this is an issue with DeSmuME specifically, have you proved that your code works on windows belonging to other applications? I suspect this is a problem with your code rather than a feature of DeSmuME – Martin May 20 '19 at 12:43
  • @Martin I've tested it with notepad and it worked splendid –  May 20 '19 at 12:44
  • It's possible its catching the CONSOLE window and not the GUI window, i'm not too sure. –  May 20 '19 at 12:47
  • I've just tested this code myself, and running `MoveWindow` _does_ successfully move the window for me. It resizes it but then the window automatically goes back to the default size – Martin May 20 '19 at 12:51
  • @Martin Could you possibly test on DeSmuME X432R February 15th 2015 Build located here: http://shikaver01.webcrow.jp/desmume_x432r/DeSmuME%20X432R%202015-02-15-0.7z –  May 20 '19 at 12:57
  • Definitely working for me: https://ibb.co/RPPCg7P. The only issue is that it sometimes moves and resizes the console and sometimes the form window – Martin May 20 '19 at 13:02
  • Ok strangely ive discovered a reason as to why on my end nothing occured, I have DeSmuME always open as admin, when it is as admin it does nothing, odd stuff haha –  May 20 '19 at 21:09
  • 1
    Alright well with WaitForInputIdle + Forcing Running As Admin works fine now, thank you for giving it a test allowing to to hone in on the issue @Martin +1 –  May 20 '19 at 22:06

0 Answers0