dr4ckerz Posted December 30, 2015 Posted December 30, 2015 First of all, hello to all the good people who came to my thread to help me out and answer my questions. This is my first day of autoit and trying to learn it from a blank page you get at the beginning. I figured a good way to start is learning how to automate my mouse and keyboard (sending keys and clicks), I would also like to have a start/stop script key. Possibly also a loop to endlessly send the key or clicks and stop it with a key toggle, but that's for later because right now even the first step is not working out for me I looked around and googled for about an hour, came up with some code but it doesn't seem to be working. HotKeySet("d", "_dfgh") Func _dfgh() Send("{dfgh}") EndFuncWhat I'm trying to do is send "d","f","g","h" every time I start the function _dfgh - and this should be done every time I press "d". There shouldn't be a time limit except if I turn the entire script off with a toggle (I obviously don't know how to do that, next step! )
aa2zz6 Posted December 30, 2015 Posted December 30, 2015 (edited) Welcome to the AutoIT forums - To start off you have to call your function _dfgh() in order for it to run correctly. _dfgh() ;<<<< To run function Func _dfgh() ; function Send("{dfgh}") ; dfgh will not work! Only "d" is be typed out. EndFunc ; end functionI would suggest reading this forum another person posted about "Key Presses".#include <Misc.au3> ; <-- I would read the #include to further understand what #include does. ; https://www.autoitscript.com/autoit3/docs/keywords/include.htm $dll = DllOpen("user32.dll") ; <-- I would read this to further understand how to use DLL's ; https://www.autoitscript.com/autoit3/docs/functions/DllOpen.htm While 1 Sleep ( 50 ) If _IsPressed("KEY WILL GO HERE!", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") ExitLoop EndIf WEnd DllClose($dll)The above is an example out of the link from above. I added some comments that you should research and expand your knowledge on! Edited December 30, 2015 by aa2zz6
JohnOne Posted December 30, 2015 Posted December 30, 2015 HotKeySet("^d", "_dfgh") ;ctrl and d. using a key you are sending will render you in an awkward loop While 3 Sleep(333) ;keep script alive WEnd Func _dfgh() Send("{dfgh}") EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
dr4ckerz Posted December 30, 2015 Author Posted December 30, 2015 Oh maybe I'm being influenced by learning a bit autohotkey prior to this. For instance what I would do in autohotkey would be: ~d:: send, fghWith just this I would be able to send "dfgh" every time I pressed "d" without causing an infinite loop, but being able to press it infinitely. Do you mind telling me the equivalent in autoit? It would really help my learning process to see the equivalence. Thanks!
dr4ckerz Posted December 30, 2015 Author Posted December 30, 2015 HotKeySet("^d", "_dfgh") ;ctrl and d. using a key you are sending will render you in an awkward loop While 3 Sleep(333) ;keep script alive WEnd Func _dfgh() Send("{dfgh}") EndFunc But even this doesn't work out for me, Press ctrl+d and nothing happens
jdelaney Posted December 30, 2015 Posted December 30, 2015 (edited) If you only want to send fgh, use this (or add in the d on the send)...if you DON'T want to wait for the control to be unpressed, then delete the first 2 _isPressed:Run("Notepad") HotKeySet("^d", "_dfgh") ;ctrl and d. using a key you are sending will render you in an awkward loop While 3 Sleep(333) ;keep script alive WEnd Func _dfgh() While _IsPressed("A2") Or _IsPressed("A3") Or _IsPressed("44") WEnd Send("fgh") EndFuncActually, this works well:Run("Notepad") HotKeySet("^d", "_dfgh") ;ctrl and d. using a key you are sending will render you in an awkward loop While 3 Sleep(333) ;keep script alive WEnd Func _dfgh() While (_IsPressed("A2") Or _IsPressed("A3")) And _IsPressed("44") WEnd Send("fgh") EndFunc Edited December 30, 2015 by jdelaney dr4ckerz 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
dr4ckerz Posted December 30, 2015 Author Posted December 30, 2015 I'm sorry but this doesn't work for me. If it worked then I could research and make modifications to it or apply what I learned on this for future scripts that resemble it. But starting from a blank page and no working scripts is a bit hard, seems autoit is harder than AHK.
jdelaney Posted December 30, 2015 Posted December 30, 2015 I didn't add the include line...add that in at the top:#include <Misc.au3> IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
dr4ckerz Posted December 30, 2015 Author Posted December 30, 2015 I didn't add the include line...add that in at the top:#include <Misc.au3>Well now I learned a lot of things from this basic script, thank you very much won't forget my lessons
kcvinu Posted December 30, 2015 Posted December 30, 2015 @dr4ckerz - The people behind autoit made a very good help file for every newbie can learn by self study. At first, you may feel some muddiness. But you will slowly get the point. So keep in mind that every time your code fails to run, don't aproach the forum. A simple solution for that problem is described in the help file. I am sure. Read it carefully. You will find the solution. But if you can't get it from the help file after a few attempts, then think about posting your question here. Why i am saying this because, i know the help file is treasure for a newbie. Happy coding. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
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