Hotkey

From Visual DialogShell Wiki
Jump to navigation Jump to search
function hotkey($a,$b,$c,$d) {
[vdsForm]::RegisterHotKey($a.handle,$b,$c,$d) | out-null
	if ($global:hotkeyobject -ne $true) {
		$hotkey = dialog add $a label 0 0 0 0
		dialog name $hotkey hotkey
		$hotkey.add_TextChanged({
			if ($this.text -ne ""){
				hotkeyEvent $this.text
			}
			$this.text = ""
		})
	$global:hotkeyobject = $true
	}
<#
    .SYNOPSIS
    Adds a hotkey to the form
     
    .DESCRIPTION
     VDS
    Registers a hotkey by ID to fire function hotkeyEvent by vkey function.
	Example:
        hotkey $Form 1 $null (vkey home)
	hotkey $FastTextForm 1 ((vkey alt)+(vkey control)) (vkey v)
	function hotkeyEvent ($a) {
	switch ($a){
		1 {
		$FastTextForm.Text = "Visual DialogShell $(sysinfo dsver)"
		}
	}
}
    
    .LINK
    https://dialogshell.com/vds/help/index.php/hotkey
#>
}