chropose Posted September 15, 2010 Share Posted September 15, 2010 (edited) I found the answer: while 1 ControlSend("Untitled", "", "Edit1", "{a down}") Sleep(2000) ControlSend("Untitled", "", "Edit1", "{a up}") Sleep(1000) wend thanks to Tvern for reminding me of ControlSend Edited September 15, 2010 by chropose Link to comment Share on other sites More sharing options...
norax Posted September 15, 2010 Share Posted September 15, 2010 ummm try to be a little more clear do you mean hold the mouse down for 2 sec then stop for 1 or click repeatedly for 2 sec then stop or what exactly are you tryin to do =\ Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 (edited) sorry, i mean to press something on keyboard, let's say i wanna have notepad to press and hold "H" for 2 secs and then stop pressing for 1 sec, continuously in loop. Edited September 15, 2010 by chropose Link to comment Share on other sites More sharing options...
norax Posted September 15, 2010 Share Posted September 15, 2010 (edited) sorry, i mean to press something on keyboard, let's say i wanna have notepad to press and hold "H" for 2 secs and then stop pressing for 1 sec, continuously in loop.while 1send("{a down}")sleep(2000)send("{a up}")sleep(1000)wendreplace a with whatever key on the keyboard u want Edited September 15, 2010 by norax Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 thanks. ill try it now. Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 hey, thanks it worked. btw, how to specify this script to work only on a specific program? let's say i wanted this script to work only on notepad so when i changed the window focus to browser address bar, the script didnt do anything to interrupt it. Link to comment Share on other sites More sharing options...
UnDeFiNeD Posted September 15, 2010 Share Posted September 15, 2010 (edited) hey, thanks it worked. btw, how to specify this script to work only on a specific program? let's say i wanted this script to work only on notepad so when i changed the window focus to browser address bar, the script didnt do anything to interrupt it. Try this: While 1 Sleep(200) if WinActive("[CLASS:Notepad]") = NOT 0 Then Send("{a down}") Sleep(2000) Send("{a up}") Sleep(1000) EndIf WEnd Edited September 15, 2010 by UnDeFiNeD Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 undefined, i tried that script, it doesnt work. it only makes the script working if window focus is currently on notepad. if the focus changed, nothing happens at all. Link to comment Share on other sites More sharing options...
norax Posted September 15, 2010 Share Posted September 15, 2010 undefined, i tried that script, it doesnt work. it only makes the script working if window focus is currently on notepad. if the focus changed, nothing happens at all. While 1 Sleep(200) if WinActive("your programs window title here") Then Send("{a down}") Sleep(2000) Send("{a up}") Sleep(1000) EndIf WEnd Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 (edited) While 1 Sleep(200) if WinActive("your programs window title here") Then Send("{a down}") Sleep(2000) Send("{a up}") Sleep(1000) EndIf WEnd norax, if the current window is on "untitled" (Notepad), the script work and only works if the window is on untitled. if the focus changed nothing happens. still same like undefined's script. Edited September 15, 2010 by chropose Link to comment Share on other sites More sharing options...
norax Posted September 15, 2010 Share Posted September 15, 2010 While 1 Sleep(200) if WinActive("your programs window title here") Then Send("{a down}") Sleep(2000) Send("{a up}") Sleep(1000) EndIf WEnd norax, if the current window is on "untitled" (Notepad), the script work and only works if the window is on untitled. if the focus changed nothing happens. still same like undefined's script. im not sure what your wanting it to do then. if you want it to only not run on a specific window then do this While 1 Sleep(200) if WinActive("program title here") Then Sleep(250) Else Send("{a down}") Sleep(2000) Send("{a up}") Sleep(1000) EndIf WEnd if this is not it then ill need a better explanation of what you want lol Link to comment Share on other sites More sharing options...
Tvern Posted September 15, 2010 Share Posted September 15, 2010 If you want to a window, even if that window is not the active one, replace Send() with ControlSend(). The helpfile has an example using notepad. Link to comment Share on other sites More sharing options...
UnDeFiNeD Posted September 15, 2010 Share Posted September 15, 2010 undefined,i tried that script, it doesnt work. it only makes the script working if window focus is currently on notepad. if the focus changed, nothing happens at all.You said "let's say i wanted this script to work only on notepad" Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 You said "let's say i wanted this script to work only on notepad"let's say i wanted this script to work only on notepad so when i changed the window focus to browser address bar, the script didnt do anything to interrupt it. Link to comment Share on other sites More sharing options...
chropose Posted September 15, 2010 Author Share Posted September 15, 2010 i've tried adding "Control" so it becomes ControlSend: While 1 Sleep(200) if WinActive("[CLASS:Notepad]") = NOT 0 Then ControlSend("{a down}") Sleep(2000) ControlSend("{a up}") Sleep(1000) EndIf WEnd and this: While 1 Sleep(200) if WinActive("Untitled") Then ControlSend("{a down}") Sleep(2000) ControlSend("{a up}") Sleep(1000) EndIf WEnd and also: While 1 Sleep(200) if WinActive("Untitled") Then Sleep(250) Else ControlSend("{a down}") Sleep(2000) ControlSend("{a up}") Sleep(1000) EndIf WEnd all of them doesn't work. Link to comment Share on other sites More sharing options...
Tvern Posted September 15, 2010 Share Posted September 15, 2010 i've tried adding "Control" so it becomes ControlSend:...all of them doesn't work.They wouldn't because ControlSend() has more parameters than Send().Like I said the helpfile for ControlSend() has an example specifically for notepad. All you need to do is replace Send with that example and then change the example text with your own. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now