clickイベントにキーコードがありません。 PowerShell v2の次の機能 - 後のバージョンでは簡単な方法があるかもしれません。
function Get-KeyState([uint16]$keyCode)
{
$signature = '[DllImport("user32.dll")]public static extern short GetKeyState(int nVirtKey);'
$type = Add-Type -MemberDefinition $signature -Name User32 -Namespace GetKeyState -PassThru
return [bool]($type::GetKeyState($keyCode) -band 0x80)
}
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object system.Windows.Forms.Form
$button = New-Object System.Windows.Forms.Button
$button.Text = 'hi'
$Form.Controls.Add($button)
$button.add_Click(
{
$VK_SHIFT = 0x10
$ShiftIsDown = (Get-KeyState($VK_SHIFT))
if ($ShiftIsDown){
[System.Windows.Forms.MessageBox]::Show("Hi, you clicked the button with shift." ,"My Dialog Box")
}
else{
[System.Windows.Forms.MessageBox]::Show("Hi, you clicked the button without shift." ,"My Dialog Box")
}
}
)
$Form.ShowDialog()
PS v3の方が優れていますか? – nkasco