Oreoleo Posted January 27, 2008 Share Posted January 27, 2008 Hey, I'm new to autoit. I've been trying to code something where, I could press a button, for example 4, and it would send it every 15ms. I would keep the button pressed and it would keep sending it, until I stop pressing it. This is as far as I've gotten, but it won't do the trick because it would just keep queuing it if I don't let off the button. HotKeySet("4", "Fi") Func Fi() For $i = 1 To 15 Step 1 sleep(15) Send("4") Next EndFunc Help would be greatly appreciated! Thanks, cya Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 27, 2008 Share Posted January 27, 2008 HotKeySet("4", "Fi") Func Fi() Send("444444444444444") EndFunc The above is a simplification of the code that you wrote. Explain more exhaustively, what you want the script to do. Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
pligor Posted January 27, 2008 Share Posted January 27, 2008 Could you give some more detail of what you are trying to do?.. Link to comment Share on other sites More sharing options...
martin Posted January 27, 2008 Share Posted January 27, 2008 Hey, I'm new to autoit. I've been trying to code something where, I could press a button, for example 4, and it would send it every 15ms. I would keep the button pressed and it would keep sending it, until I stop pressing it. This is as far as I've gotten, but it won't do the trick because it would just keep queuing it if I don't let off the button. HotKeySet("4", "Fi") Func Fi() For $i = 1 To 15 Step 1 sleep(15) Send("4") Next EndFunc Help would be greatly appreciated! Thanks, cya Welcome to the AutoIt forums You could have 2 hotkeys. One to start send the key and one to stop. If you want to send "4" then you can't use 4 for the HotKey because it will just trigger the Fi function again. HotKeySet("{F1}","Fi") HotKeySet("{F2}","Fo") HotKeySet("{ESC}","GO_OUT") Global $stay = true while 1 Sleep(20) WEnd Func Fi() while $stay Send("4") sleep(100) wend endfunc Func Fo() $stay = false endfunc Func GO_Out() Exit EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Oreoleo Posted January 27, 2008 Author Share Posted January 27, 2008 @martin your script is almost what I was looking for. Just wondering if there was a way for say an F3 button to restart the script instead of having to Go_out and then re-opening the au3 file. I tried this but it didn't work HotKeySet("{F1}","Fi") HotKeySet("{F2}","Fo") HotKeySet("{ESC}","GO_OUT") HotKeySet("(F3)","Restart") Global $stay = true while 1 Sleep(20) WEnd Func Fi() while $stay Send("4") sleep(1000) wend endfunc Func Fo() $stay = false endfunc Func GO_Out() Exit EndFunc Func Restart() Run("haha.au3") Endfunc Link to comment Share on other sites More sharing options...
rasim Posted January 27, 2008 Share Posted January 27, 2008 @martin your script is almost what I was looking for. Just wondering if there was a way for say an F3 button to restart the script instead of having to Go_out and then re-opening the au3 file. I tried this but it didn't work HotKeySet("{F1}","Fi") HotKeySet("{F2}","Fo") HotKeySet("{ESC}","GO_OUT") HotKeySet("(F3)","Restart") Global $stay = true while 1 Sleep(20) WEnd Func Fi() while $stay Send("4") sleep(1000) wend endfunc Func Fo() $stay = false endfunc Func GO_Out() Exit EndFunc Func Restart() Run("haha.au3") Endfunc Try this, but before using compile script: HotKeySet("{F1}","Fi") HotKeySet("{F2}","Fo") HotKeySet("{ESC}","GO_OUT") HotKeySet("{F3}","Restart") Global $stay = true while 1 Sleep(20) WEnd Func Fi() while $stay Send("4") sleep(1000) wend endfunc Func Fo() $stay = false endfunc Func GO_Out() Exit EndFunc Func Restart() ShellExecute(@ScriptFullPath) Exit Endfunc Link to comment Share on other sites More sharing options...
martin Posted January 27, 2008 Share Posted January 27, 2008 @martin your script is almost what I was looking for. Just wondering if there was a way for say an F3 button to restart the script instead of having to Go_out and then re-opening the au3 file. I tried this but it didn't work HotKeySet("{F1}","Fi") HotKeySet("{F2}","Fo") HotKeySet("{ESC}","GO_OUT") HotKeySet("(F3)","Restart") Global $stay = true while 1 Sleep(20) WEnd Func Fi() while $stay Send("4") sleep(1000) wend endfunc Func Fo() $stay = false endfunc Func GO_Out() Exit EndFunc Func Restart() Run("haha.au3") Endfunc What do you want to happen. If you restart then there is no point in ending the script first so I suspect I don't understand your question. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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