I'm trying to write a script which periodically toggles the caps lock, but I also to toggle I want to be able to script because it causes some issues with other issues (such as Alt Tabbing, and rolling on windows in the workspace to see a preview)
I have a script yet
: External time ($ true) {to {echo} with F12 Toggle "; $ X = [System.Console] :: ReadKey ()} while ($ x.Key -ne "F12") while ($ true) {$ wsh = New-Object -ComObject WScript.Shell $ wsh.SendKeys ('{ CAPSLOCK} 'Sleep 0.3 [System.Runtime.Interopservices.Marshal] :: Remove ReleaseComObject ($ wsh) - Variables wsh ($ host UI.RawUI.KeyAvailable) {$ key = $ Host.UI.RawUI.ReadKey ( ) Waiting for the user by pressing F12 ($ key.Key -ne "F12") {break external}}}}
user, and once they press F12 , Then I want it to toggle the Caps Lock key to never 0.3 seconds to resume the user press F12. Ideally, I want to get it in the background, but I do not know whether it is possible or not. I do not want the user to open the console window to toggle the script.
The way it runs now, after user presses F12, the script will once toggle the capsule and then exit. If I remove the conditional after the extract-variable, then the script runs because I want it to be the only way that can be turned off, if the console window is closed.
Here is a try BTW1 has converted sleep into 1 second, which will be used during testing CapsLock does not have much flash:
$ continue = $ true while ($ release) {if ([console] :: key available) {echo "toggle with F12"; $ X = [System.Console] :: ReadKey () switch ($ x.key) {F12 {$ continu = $ false}} and {$ wsh = new object -com objects WScript.Shell $ wsh.SendKeys ('{ CAPSLOCK} ') Sleep 1 [System.Runtime.Interopservices.Marshal] :: ReleaseComObject ($ wsh) | Out-rick virtual wsh}}
Comments
Post a Comment