Wednesday, December 10, 2025

How to send Ctrl + F4 key in Powershell - How to send CTRL ALT Shift keys in Powershell - How to open Application in Powershell - How to open File Explorer in Powershell

 Start-Sleep -Seconds 5


$wshell = New-Object -ComObject WScript.Shell

$wshell.SendKeys("^{F4}")



or

#Note This first line is mandatory 


[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

# Start WinWord (if not already running)

Start-Process -FilePath "explorer.exe"

# Wait for WinWord to open and become active

Start-Sleep -Seconds 3

(New-Object -ComObject "wscript.shell").SendKeys("^{ESC}")

# Activate the WinWord window (adjust the title if necessary)

[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")


ref:- https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=windowsdesktop-10.0


https://stackoverflow.com/questions/19824799/how-can-i-send-ctrl-or-alt-any-other-key

No comments:

Post a Comment