I need to run a program every time I start writing and again 4 seconds after I stop writing.
How to do this?
I've tryied with autohotkey with no luck..
Untested script but should work with some tweaking, I don't think the psTools command is correct and I'm not going to install all these programs to test it for you. I'll be happy to help further if you need assistance from here.
AutoHotkey:
startDwellClicker() {
Input, key, V L1, {space}.{esc}.{shift}.{enter}.{tab}.{Ctrl} ;Waits for Anykey to be pressed
Run, pssuspend "-r \\%A_ComputerName% dwellclicker.exe" ;Resume DwellClicker
pauseDwellClicker()
}
pauseDwellClicker() {
Loop {
Input, key, V L1 T4
if (ErrorLevel = "Timeout") ;Waits for 4 second Time Out
Break
}
Run, pssuspend "\\%A_ComputerName% dwellclicker.exe" ;Pause DwellClicker
startDwellClicker()
}
I have no idea what ps is or RSI, but I know that AutoHotkey was made for you.
#persistent
waitTime := 4 ; seconds
isWriting := false
loop {
input, anyKey, V L1 M I T%waitTime%
if(errorLevel=="Timeout") {
if(isWriting) {
goSub stoppedWriting
isWriting := false
}
} else {
if(!isWriting) {
goSub startedWriting
isWriting := true
}
}
}
return
startedWriting:
send START
return
stoppedWriting:
send STOP
return
You have to make use of the Input
command and set its timeout time to whatever you want, in the example above I set it to 4 seconds. Please see Input for details on the available options for this command.
Edit. I misinterpreted ahkcoder's answer, his will do
Thank you! Didn't try the other codes, but seems very similar to what finally I did. I've used autohotkey :)
BTW: RSI is basically.. a big pain in hand, legs, shoulders, fingers because of computer :(... hehe
This is the working code:
Loop{
Input, SingleKey, L1 V I B, {F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Del}{BS}{WheelUp}{WheelDown}
MouseGetPos,xpos,ypos
stop:=0
Run "D:\RSI\DesactivaDwell.vbs"
While !stop {
wait:=2500
While wait>0{
;If ANY Key is pressed again, we set wait=4000. Input works as Sleep for 100ms ( Parameter T0.1)
Input,SingleKey, L1 V I B T0.5, {F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Del}{BS}{WheelDown}{WheelUp}{RButton}
If ErrorLevel=Timeout
wait-=500
Else
wait:=2500
}
Sleep,1000
Run "D:\RSI\ActivaDwell.vbs"
stop:=1
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.