swipeales Posted April 17, 2016 Share Posted April 17, 2016 Hello,i am new here and decided to give a shot to autoit (i use(d) ahk). I have problem with send command, i want to send key f which would send f and key d would send {d 2}, a sends l That doesn't work for f and d, only works for a. expandcollapse popup; Script Start - Add your code below here ;\\\\\\\\\\\\\\\\\\\\Set hotkeys HotKeySet("f", "_fTest") HotKeySet("d", "_dTest") HotKEySet("a", "_aTest") HotKeySet("F1", "_Exit") ;//////////////////// ;\\\\\\\\\\\\\\\\\\\\Declare vars ;//////////////////// ;\\\\\\\\\\\\\\\\\\\\Main loop While 1 Sleep(1000) WEnd ;//////////////////// ;\\\\\\\\\\\\\\\\\\\\Functions Func _fTest() Send("{f}") EndFunc ;==>_Start Func _dTest() Send("{d 2}") EndFunc ;==>_Pause Func _aTest() Send("{l}") EndFunc Func _Exit() Exit EndFunc ;==>_Exit ;//////////////////// Link to comment Share on other sites More sharing options...
AutoBert Posted April 17, 2016 Share Posted April 17, 2016 (edited) use it this way: Func _fTest() HotKeySet("f") Send("f") HotKeySet("f", "_fTest") EndFunc Edited April 17, 2016 by AutoBert swipeales 1 Link to comment Share on other sites More sharing options...
swipeales Posted April 17, 2016 Author Share Posted April 17, 2016 32 minutes ago, AutoBert said: use it this way: Func _fTest() HotKeySet("f") Send("{f}") HotKeySet("f", "_fTest") EndFunc thanks, i'd really like to use it the way i posted. I like things to be in order, is there any other solution? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 17, 2016 Developers Share Posted April 17, 2016 16 minutes ago, swipeales said: i'd really like to use it the way i posted. I like things to be in order, is there any other solution? No idea what you mean as the solution provide will do that, or else tell us what you are looking for? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
swipeales Posted April 17, 2016 Author Share Posted April 17, 2016 18 minutes ago, Jos said: No idea what you mean as the solution provide will do that, or else tell us what you are looking for? Jos i'd like to have for every hotkey a function. A calls aTest B calls bTest. Inside functions i would have keys to be pressed. Also, i have found one more issue, if i do something like this: ;sorry for the syntax just demonstration purpose (pseudocode) hotkeyset(e,e_Function) hotkeyset(d,d_Function) call the function Func e_Function() Send d endFunc Func d_Function() Send d 2 endFunc This will always call function d_Function (it will always say dd even if i call e, it will overwrite with dd). Thanks in advance for any help Link to comment Share on other sites More sharing options...
Developers Jos Posted April 17, 2016 Developers Share Posted April 17, 2016 Understood, but you have to disable the HotKey before sending the character or else you activate the hotkey again. That is why AutoBert posted the one example Func for the letter f. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
swipeales Posted April 17, 2016 Author Share Posted April 17, 2016 1 hour ago, AutoBert said: use it this way: Func _fTest() HotKeySet("f") Send("f") HotKeySet("f", "_fTest") EndFunc 21 minutes ago, Jos said: Understood, but you have to disable the HotKey before sending the character or else you activate the hotkey again. That is why AutoBert posted the one example Func for the letter f. Jos I just tried function fTest from AutoBer, and it prints f not d. Here is code: HotKeySet("f", "_fTest") Func _fTest() HotKeySet("f") Send("d") HotKeySet("f", "_fTest") EndFunc I have also one more question, if script won't terminate even though i closed it, it would go nuts and i can't use my keyboard, I had to restart my computer several times due this. Link to comment Share on other sites More sharing options...
AutoBert Posted April 17, 2016 Share Posted April 17, 2016 (edited) Reading helpfile for a func which don't works like expected is always a good idea, after them testing the example(s) mostly gives good ideas. Edited April 17, 2016 by AutoBert Link to comment Share on other sites More sharing options...
swipeales Posted April 17, 2016 Author Share Posted April 17, 2016 Just now, AutoBert said: Reading helpfile for a func which works like expected is always a good idea, after them testing the example(s) mostly gives good ideas. just tested it first time i hit f key it does nothing (but it should click d), looks like after that script pauses and keeps using normal f. I used your code Link to comment Share on other sites More sharing options...
Developers Jos Posted April 17, 2016 Developers Share Posted April 17, 2016 (edited) 1 hour ago, swipeales said: but it should click d It doesn't click anything but send a "d" to the active window. Jos Edited April 17, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
swipeales Posted April 17, 2016 Author Share Posted April 17, 2016 3 hours ago, Jos said: It doesn't click anything but send a "d" to the active window. Jos yeh haha my bad i mean it doesn't send d. it sends nothing then pauses a script Link to comment Share on other sites More sharing options...
Developers Jos Posted April 17, 2016 Developers Share Posted April 17, 2016 It will send it for sure ... what program are you trying to send it to? Jos swipeales 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
InunoTaishou Posted April 17, 2016 Share Posted April 17, 2016 HotKeySet("f", "_fTest") HotKeySet("d", "_dTest") HotKEySet("a", "_aTest") AutoItSetOption("WinTitleMatchMode", -2) Global $hWnd = WinGetHandle("VLC media player") While 1 Sleep(1000) WEnd Func _fTest() ControlSend($hWnd, "", "", "f") EndFunc ;==>_Start Func _dTest() ControlSend($hWnd, "", "", "d") EndFunc ;==>_Pause Func _aTest() ControlSend($hWnd, "", "", "a") EndFunc Func _Exit() Exit EndFunc ;==>_Exit Using controlsend you can keep the hotkeys set without having to un-register then re-register. I used VLC as an example, because I have it open. Just substitute whatever program you're trying to use send on. Link to comment Share on other sites More sharing options...
swipeales Posted April 17, 2016 Author Share Posted April 17, 2016 13 hours ago, Jos said: 6 hours ago, Jos said: It will send it for sure ... what program are you trying to send it to? Jos i was testing it on google chrome url, it wouldn't work 5 hours ago, InunoTaishou said: HotKeySet("f", "_fTest") HotKeySet("d", "_dTest") HotKEySet("a", "_aTest") AutoItSetOption("WinTitleMatchMode", -2) Global $hWnd = WinGetHandle("VLC media player") While 1 Sleep(1000) WEnd Func _fTest() ControlSend($hWnd, "", "", "f") EndFunc ;==>_Start Func _dTest() ControlSend($hWnd, "", "", "d") EndFunc ;==>_Pause Func _aTest() ControlSend($hWnd, "", "", "a") EndFunc Func _Exit() Exit EndFunc ;==>_Exit Using controlsend you can keep the hotkeys set without having to un-register then re-register. I used VLC as an example, because I have it open. Just substitute whatever program you're trying to use send on. I will try this, but i've heard ControlSend method is slower than Send method, is this true? Link to comment Share on other sites More sharing options...
InunoTaishou Posted April 17, 2016 Share Posted April 17, 2016 I don't know how it would be, and even if it was, you'd be talking micros of a milisecond difference between the two. You could always run a test to see which is faster, disabling the hot key, send, enable the hot key, or controlsend. swipeales 1 Link to comment Share on other sites More sharing options...
JohnOne Posted April 17, 2016 Share Posted April 17, 2016 Just use different hotkeys to those which you are sending. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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