I want to create a script which types a word if I press a single button. I have Logitech mouse so I can assign "Run something" to buttons". I would like to be able to type in the word with one of the buttons.
Here is the code I'm trying to use
Add-Type -AssemblyName System.Windows.Forms
timeout 1
'Potato'.ToCharArray() | ForEach-Object {[System.Windows.Forms.SendKeys]::SendWait($_)}
I'm not sure that code is right, but when I assing that .ps1 file to a button, nothing happens.
You can simply do the following:
$wshell = New-Object -ComObject wscript.shell
$wshell.SendKeys('Potato')
This will then send the keys to the currently focused application and not a winforms object you have created.