Jump to content

Looking for Auto Key Pressing Script Help


Recommended Posts

I've been looking for the past hour or so through forums trying to find a general layout and explanation of how to make a script that would automatically press keys, one after the other (not at the same time) but have had no such luck finding anything of the sort... I've found several threads of people asking for exactly what i'm asking for now, but only vague responses that really only leave me with more questions...

With that being said, and given the fact that I have not yet seen a general layout, if someone could help me, it would be much appreciated... So lets do this if someone would be so kind as to help me out with this.... F1 being the start/stop button for the script.... Buttons being pressed is 1 every 5 seconds, immediately followed by the pressing of the number 2 Key... to take place on the dominant (main) window that I have open... So in a notepad for example, when I hit F1, it would type 1 and then 2 every 5 seconds until I were to hit F1 again...

This is not what i'm looking for, but this is what I would want to see so I can understand exactly what it is and how it works... If someone could provide a script for this action along with a detailed explanation of what it is that each character in this script is specifically doing, so I know how to write this myself later and modify things in a similar manner, it would help me out immensely.. and yes, i've gone through several threads, read several links to other threads or help pages that so many people posted in said threads, and wasn't able to find the type of help I was looking for... I write this because I can't find what I'm looking for, and being brand new to scripts, I would need a little more description then what i've seen of a seemingly random collection of thrown together words that are to be put in some order that I don't know yet... I hope to get a response and some help soon, thanks for taking the time to read this...

Link to comment
Share on other sites

In reading your request your description could be for many different types of things. It would be helpful if you told us the name of the app you want to automate. In some cases there will be a UDF available that may be better than pressing keys.

Seeing how you are new, you may want to review the forum rules first. We are glad to help, but depending on just you want to do, it may be against the rules.

Edited by scullion
Link to comment
Share on other sites

Hi. Welcome to the forum. First off, this isn't a 'script request' place, and next to no-one will write a script for you. But I'd like to help, so here you go..

1. Read the docs, here.

2. Read 'em again, paying closer attention to this section - Language Reference

3. Read 'em again, paying closer attention to this section - Function Reference

4. Think of what you want your script/program to do. Repeat steps 1, 2, & 3 to see how it can be done in AutoIt.

5. Ask questions about your code here.

Well, there ya go! Hope it helps!

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Thank you for the suggestion of reviewing the forums rules, I have just done so...

I had thought that perhaps creating a simple script to press keys would be the most basic thing in terms of what I was looking for and was unaware that there might be more effective ways based on which app it is that I am using...

I am generally just looking for a basic guideline that I can then modify to my own purposes, hence why I said F1, 1, and 2, and 5 seconds... Immediately what comes to mind would be PhotoShop, Google Chrome, and Libre Office...

After reading and googling some things in the rules here, I don't believe what I am asking for would be breaking any rules... If so please be sure to let me know and what it is specifically that I am asking for that is against the rules... Thank you for your fast reply and I look forward to a response, and hopefully some help...

Edit: Thank you for that link somdcomputerguy, clearly I did not look where I should have been for what it was that I was searching for... I can see I have a more reading to do... I will be back on tmrw to see if anyone has offered any suggestions or advice... Also, I wasn't necessarily requesting a script, I have just been looking for a generalized outline explained in detail for people like me who aren't all too into writing scripts as of yet... I hope to find one or get a better grasp on doing this from what you provided...

Edited by KlownyZirkus
Link to comment
Share on other sites

Global $Paused
HotKeySet("{F1}", "TogglePause")
Global $Quit
HotKeySet("{END}", "END")
Opt("SendKeyDelay", 20)
While 1
sleep(100)
WEnd
Func TogglePause()
$Paused = NOT $Paused
While $Paused

Sleep(100)



Send("a")
Send("{ENTER}")
Sleep(100)
Send("b")
Send("{ENTER}")
Sleep(100)
Send("c")
Send("{ENTER}")
Sleep(100)
Send("d")
Send("{ENTER}")
Sleep(100)
Send("e")
Send("{ENTER}")
Sleep(100)
Send("f")
Send("{ENTER}")
Sleep(100)
Send("{END}")
WEnd
EndFunc
Func END()
Exit
EndFunc

Link to comment
Share on other sites

Edit: Thank you for that link somdcomputerguy, clearly I did not look where I should have been for what it was that I was searching for... I can see I have a more reading to do... I will be back on tmrw to see if anyone has offered any suggestions or advice... Also, I wasn't necessarily requesting a script, I have just been looking for a generalized outline explained in detail for people like me who aren't all too into writing scripts as of yet... I hope to find one or get a better grasp on doing this from what you provided...

Working example code is in the Help file for just about every function in there, so that'll probably help you too!

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Would you like to send keystrokes to an application?

send("This will send the keys to type this sentence ")
$x= "This will send the keys to type this sentence"
send($x)

That should print that string twice.

Now if you wanted to insert a carriage return between them. You'd write it like this:

send("This will send the keys to type this sentence ")
$x= "This will send the keys to type this sentence"
send("{enter}")
send($x)

I'm all drunk, didn't test any of that.

Edited by Xandy
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...