FredX Posted October 17, 2014 Share Posted October 17, 2014 I would like to make life easier with the hotkeyset-function and the Send-function. Means: Instead of writing sentences or words pressing a key. Goal is to have a macro with 3 or 4 hotkeys that print out a word when pressing them. Now i'm not a good programmer i tried with google and some parts of Autoit3-macros i found in the net but what i managed was printing out a letter but not the whole word. All i have(stolen from this forum) so far is: Hotkeyset ("{A}", "A") While 1 Sleep (1000) ;Keeps script running Wend Func A() Send("{Liebe Mitbewohner und Nachbarn,}") Endfunc When i run this macro and press shift+a, it just prints the "L" but not the rest. I saw other macros with this function and more then one letters to be posted but they used for every letter a send-command, and this would be a big macro then, isn't there a better solution ? And if this macro is working, can i just put it several times into the script to have several hotkeys programmed ? Link to comment Share on other sites More sharing options...
Bert Posted October 17, 2014 Share Posted October 17, 2014 look at this: http://www.pcmag.com/article2/0,2817,2380508,00.asp The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
FredX Posted October 17, 2014 Author Share Posted October 17, 2014 Are you serious ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 17, 2014 Moderators Share Posted October 17, 2014 FredX,Welcome to the AutoIt forums. Your syntax is not quite right:HotKeySet("a", "_A") ; Help file suggests using lower case letters While 1 Sleep(10) ;Keeps script running - 10ms will suffice WEnd Func _A() Send("Liebe Mitbewohner und Nachbarn,") EndFunc ;==>_ANote the lack of surrounding braces ({ }) in both the HotKey definition and the Send function. They are only required in the definition when you need to define a special key (e.g. {ENTER}) and when used inside the Send function limit the characters sent to the first alone - as you have found. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FredX Posted October 17, 2014 Author Share Posted October 17, 2014 Thank you for the welcome. I actually had a spooky experience: I tried out your correction and it worked great, so great that it did not stop to print those greetings to my dear neighbours, i used the taskmanager then to stop the process So what would be the way to make the macro limit sending the message to one pressing of the hotkey ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 17, 2014 Moderators Share Posted October 17, 2014 FredX,Entirely my fault - sorry. :blush:I had tested using a key which did not feature in the sent text - but there are lots of "a" in that phrase and each time you send one it fires the HotKey again. So you need to cancel the HotKey on entry to the function and then reset it as you exit:HotKeySet("a", "_A") While 1 Sleep(10) ;Keeps script running WEnd Func _A() HotKeySet("a") ; Prevent each "a" firing the function Send("Liebe Mitbewohner und Nachbarn,") HotKeySet("a", "_A") ; Reset the HotKey ready for the next press EndFunc ;==>_AThat should keep your "neighbours" under control! Seriously, you should use a modifier key as well as a character when you define the HotKey or you will find the same thing happening each time you type an "a" in the test. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Bert Posted October 17, 2014 Share Posted October 17, 2014 Are you serious ? It is a tool that lets you create macros that work off keystrokes. I used version 2 of it for many years and it saved me loads of trouble. Now it won't do the printer part however to make macros that work of keystrokes it does that quite well. Yes it is 8$ US but for what it does, it does it well. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
FredX Posted October 17, 2014 Author Share Posted October 17, 2014 FredX, Entirely my fault - sorry. :blush: I had tested using a key which did not feature in the sent text - but there are lots of "a" in that phrase and each time you send one it fires the HotKey again. So you need to cancel the HotKey on entry to the function and then reset it as you exit: HotKeySet("a", "_A") While 1 Sleep(10) ;Keeps script running WEnd Func _A() HotKeySet("a") ; Prevent each "a" firing the function Send("Liebe Mitbewohner und Nachbarn,") HotKeySet("a", "_A") ; Reset the HotKey ready for the next press EndFunc ;==>_A That should keep your "neighbours" under control! Seriously, you should use a modifier key as well as a character when you define the HotKey or you will find the same thing happening each time you type an "a" in the test. M23 Not a prob at all, such happenings keep life fresh Glad the macro works so far. Now i tried to use more then 1 hotkeys and i just copied the first part again into the script and changed the variable to _B and the hotkey to 2 . HotKeySet("1", "_A") While 1 Sleep(10) ;Keeps script running WEnd Func _A() HotKeySet("1") ; Prevent each "a" firing the function Send("Liebe Mitbewohner und Nachbarn,") HotKeySet("1", "_A") ; Reset the HotKey ready for the next press EndFunc ;==>_A HotKeySet("2", "_B") While 1 Sleep(10) ;Keeps script running WEnd Func _B() HotKeySet("2") ; Prevent each "a" firing the function Send("mit freundlichen Grüßen") HotKeySet("2", "_B") ; Reset the HotKey ready for the next press EndFunc ;==>_A And while the first hotkey still works(i changed the "a" to "1"), the second does nothing, but at least i can start the macro and not getting a error message. But there seems to miss a part telling the macro "hey, there is another hotkey defined also, don't forget to work with it also". How can i combine the 2 hotkeys so i have them both active and waiting ? Link to comment Share on other sites More sharing options...
Solution kylomas Posted October 17, 2014 Solution Share Posted October 17, 2014 (edited) FredX, Your second HotKey instruction is never allowed to execute do to the 1ST while...wend loop. Just move the HotKeySet like this... HotKeySet("1", "_A") HotKeySet("2", "_B") While 1 Sleep(10) ;Keeps script running WEnd Func _A() HotKeySet("1") ; Prevent each "a" firing the function Send("Liebe Mitbewohner und Nachbarn,") HotKeySet("1", "_A") ; Reset the HotKey ready for the next press EndFunc ;==>_A While 1 Sleep(10) ;Keeps script running WEnd Func _B() HotKeySet("2") ; Prevent each "a" firing the function Send("mit freundlichen Grüßen") HotKeySet("2", "_B") ; Reset the HotKey ready for the next press EndFunc ;==>_A ;Liebe Mitbewohner und Nachbarn,2Liebe Mitbewohner und Nachbarn,mit freundlichen Grüßen kylomas Edited October 17, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
FredX Posted October 17, 2014 Author Share Posted October 17, 2014 Works great now. Just a last question, i tried to make a combination because using normal numbers can interfere with writing then. I tried HotKeySet("LSHIFT+1") and HotKeySet("ALT+1") but nothing happened, it just printed out "!", but examples show it like that, what did i do wrong ? Link to comment Share on other sites More sharing options...
kylomas Posted October 17, 2014 Share Posted October 17, 2014 FredX, See M23's post (#4). Also, see the Send command in the Help file for key definition... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
FredX Posted October 17, 2014 Author Share Posted October 17, 2014 (edited) Had overseen the hint of M23. I checked the helpfile and found out that instead of "ALT" the "!" is used. So defining a hotkey with "!1" would mean ALT+1. Interestingly it posted the word in the editor where i tried it out but then i could not do anything else, not pressing enter and nothing, stopped the script then but still. Then i shut down the autoit3-editor and after a while of pressing all keys on different homepages and editors i am able to write again. I don't know what i did wrong, it worked but i don't know why it screwed up my keys. Another problem is, i only can do 5 posts more today. EDIT: after finishing the macro and pressing alt+1 all went to normal, seems the macro set my keys into another mode anyhow. Edited October 17, 2014 by FredX Link to comment Share on other sites More sharing options...
FredX Posted October 17, 2014 Author Share Posted October 17, 2014 Anyway, my flat did not burn down, my pc still running, macro is working as planned now, thanks a lot to all who helped and have a good weekend ! Link to comment Share on other sites More sharing options...
kylomas Posted October 17, 2014 Share Posted October 17, 2014 I hope you removed the second (useless) while...wend loop.. Good Luck (and have a good weekend yourself), kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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