Q:

Shortening pre-existing class method calls

I currently have the following code written in PowerShell.  
The script is basically made to press the Spacebar on the keyboard every few minutes. 
Add-Type -AssemblyName System. Windows. Forms. SendKeys

# Interval in seconds between two consecutive keypresses
$interval = 300 # == 5 minutes
# String code for key to press. 
$Key = " " # Hit spacebar

Write-Host "Pressing key for the first time in 10 seconds"
Start-Sleep -Seconds 10 # Key will be pressed once 10 seconds after execution to confirm the script is running. 
While ($true) {
    [System. Windows. Forms. SendKeys]::SendWait($Key)
    Write-Host "Sleeping $interval seconds"   
    Start-Sleep -Seconds $interval
}

What I don't like about this script is that I have to call the 'SendKeys' method using this long notation:
[System. Windows. Forms. SendKeys]::SendWait($Key)

I'd like to find a way to call it in a shorter way simply using:
SendKeys::SendWait($Key)

How exactly do I 'import' the class SendKeys to make the notation shorter. 
I've been looking all over the internet but I can't find a solution. 
At this point I'm wondering if it's even possible at all. 
If anyone could help me it would be much appreciated.  Not that it'll change anything in how the script functions but at least I'll be happy to know how it's done. 
Thanks in advance,
Kind regards,
Insannik

A:

In PowerShell v5+, you can use the using directive:
using namespace System. Windows. Forms

Add-Type -AssemblyName System. Windows. Forms

[SendKeys]::SendWait(' ')

Note: using statements must be the first non-comment item in a script. 
Alternatively, you can assign the type to a variable and use the static invoke syntax:
$s = [System. Windows. Forms. SendKeys]

$s::SendWait(' ')

As an aside, System is always imported and can be left off type paths:
[Windows. Forms. SendKeys] # valid

