Git Product home page Git Product logo

Comments (5)

MScholtes avatar MScholtes commented on August 16, 2024

Hello jiska78,

did you try this:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Maximized YourCompiledScript.exe

Greetings

Markus

from ps2exe.

jiska78 avatar jiska78 commented on August 16, 2024

from ps2exe.

MScholtes avatar MScholtes commented on August 16, 2024

Hello Stuart,

a compiled script does not create its own console window, it only requests a console from the operating system. therefore it has no control (the console might be there already).

A way I think that might work could be this code at the beginning of your script:

$SW_HIDE             = 0  # Hides the window and activates another window
$SW_SHOWNORMAL       = 1  # Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position
$SW_SHOWMINIMIZED    = 2  # Activates the window and displays it as a minimized window
$SW_SHOWMAXIMIZED    = 3  # Activates the window and displays it as a maximized window
$SW_MAXIMIZE         = 3  # Maximizes the specified window
$SW_SHOWNOACTIVATE   = 4  # Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except the window is not actived
$SW_SHOW             = 5  # Activates the window and displays it in its current size and position
$SW_MINIMIZE         = 6  # Minimizes the specified window and activates the next top-level window in the Z order
$SW_SHOWMINNOACTIVE  = 7  # Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated
$SW_SHOWNA           = 8  # Displays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated
$SW_RESTORE          = 9  # Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position
$SW_SHOWDEFAULT      = 10 # Sets the show state based on the SW_ value specified in the STARTUPINFO structure
$SW_FORCEMINIMIZE    = 11 # Minimizes a window, even if the thread that owns the window is not responding

Add-Type -Name WinAPI -Namespace Native -MemberDefinition '
// Retrieve handle for console window
[DllImport("Kernel32.dll")] 
public static extern IntPtr GetConsoleWindow();

// send message to window handle
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
'

# Maximize window
$ConsoleHandle = [Native.WinAPI]::GetConsoleWindow()
[Native.WinAPI]::ShowWindow($ConsoleHandle, $SW_MAXIMIZE) | Out-Null

Greetings

Markus

from ps2exe.

jiska78 avatar jiska78 commented on August 16, 2024

from ps2exe.

MScholtes avatar MScholtes commented on August 16, 2024

You're welcome

from ps2exe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.