0

I have an external .exe file that I need to run on my PC for a demo. I'm running the .exe file from the command line (from CMD) and when I run the .exe file it opens up in a winforms window with the title bar as a regular window.

I need to be able to run that .exe file with the following restrictions:

  1. Completely hide the title bar, so that the window won't have any border at all.
  2. Open the window in a split screen mode, so that it will occupy the right side of the screen to allow me to open a second window on the left side.

I thought about trying to wrap it in winform of my own and run it from there, but my guess is that there may be some parameters I can pass to the command line when running the .exe file.

Is there?

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Liran Friedman
  • 4,027
  • 13
  • 53
  • 96

2 Answers2

0

The Win32 API SetWindowLong ( https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).aspx) is what supports to change window styling.

Command Prompt allows only to change the title of a running application by passing a --title flag.

However you could try using a Powershell script which has access to Win32 APIs. Check this example for a starting point. https://gist.github.com/grenade/ed8dd77ae8eeb5b4a3c1cfd66e9c8ae7

0

A similar question locates here.

Inspired by Mikuz and weakish's answers, I suggest you to use autohotkey and use the following configuration.

#SingleInstance force
#IfWinNotActive ahk_exe explorer.exe
w_wasted = 2 ;6 ; width used by resize bars
h_wasted = 29 ;29 ; width used by caption frame and resize bars
LWIN & f::
  SetTitleMatchMode, 2
  WinGet Style, Style, A

  ; 0xC40000 = WS_BORDER (0x800000) + WS_DLGFRAME (0x400000) + WS_SIZEBOX aka WS_THICKFRAME (0x040000)
  if(Style & 0xC00000) { ; if has WS_CAPTION. Ignore sizebox value.
    WinGetPos, X, Y, Width, Height, A
    WinSet, Style, -0xC40000, A ; removes attributes, including sizebox...doesn't do a strict subtraction
    t_wid := Width+w_wasted
    t_hei := Height+h_wasted
    WinMove,A,,X,Y,t_wid,t_hei
  } else {
    WinSet, Style, +0xC40000, A
    ; Note: will set WS_SIZEBOX even if not previously present
    if(Width > w - w_wasted) { 
      Width := %w%-%w_wasted%
    }
    if(Height > h - h_wasted) {
      Height := %h%-%h_wasted%
    }
    WinMove,A,,%X%,%Y%,%Width%,%Height%
  }
  WinSet Redraw
  Return

To your restrictions, press Win+left/right as you like to tile current window and then press Win+F as defined in the configuration to hide the title bar. If you want to show the hidden title bar, press Win+F again when the window is active.

Note: This simple configuration only works with one window.