Very new and want to write a script but don't know how...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Very new and want to write a script but don't know how...

30 Dec 2018, 13:27

Hello, so i am very new to autohotkey. I also do not know much about scripts or any programing... I would like to create a script that types a word for instance " testing" and sends in x amount of time lets say like 20 times. Can someone help me with this...
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 14:05

Welcome to the forum!
Have you worked through the beginner's tutorial? Your script seems quite doable with even basic knowledge...

Look into the commands loop, send and sleep... there are examples in the docs.

If it doesn't work, show the code you tried and explain what didn't work.
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:07

The only thing i am not seeing anywhere is anything about looping...? i think those are the only other things i need.
Last edited by matthewd253 on 30 Dec 2018, 15:13, edited 1 time in total.
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:13

matthewd253 wrote:
30 Dec 2018, 15:07
The only thing i am not seeing anywhere is the symbol for enter, and anything about looping...? i think those are the only other things i need.
Look into the commands loop, send...
Send says:
Key Names: The following table lists the special keys that can be sent (each key name must be enclosed in braces):
[...]
{Enter} Enter key on the main keyboard
From the tutorial - section 3:
The gigantic table on the Send page shows pretty much every special key built-in to AHK. For example: {Enter} and {Space}.
Last edited by gregster on 30 Dec 2018, 15:16, edited 1 time in total.
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:14

thank you, i just found the enter thing now im looking through loop. thank you!
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:24

Okay so i am very confused with the whole loop thing....

Loop, 3

{^x::
Send, testing one {Enter}
}
return

This is what i have..... the loop wont work and i don't know what i did wrong...
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:26

I assume you want to do this:

Code: Select all

^x::   		 ; Ctrl + x
Loop, 3
{
	Send, testing one {Enter}
}
return
The key combo has to go to the top of a hotkey definition.
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:33

Yes!!! thank you, i just ran into a slight issue with it though.... it types to quickly so it sends it as
testing one
esting one
ting one.
how could i fix this?
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:36

It is probably caused by the receiving application. Try other send modes, like Sendinput instead of send.
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:42

Okay that worked, with the loop being three it only sent it twice. so i changed it to 10 and it sent it 6 times with it only messing the word up once. so getting very close here lol. what could be causing this issue??
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:46

That's weird... where are you posting it?
Perhaps add a sleep between the lines...

Code: Select all

^x::   		 ; Ctrl + x
Loop, 10
{
	SendInput, testing one {Enter}
	sleep 50		; sleep 50 ms
}
return
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:47

I posting it in a message on facebook. and okay ill try that.
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 15:49

well i added the sleep but now it sent 7 times with two of them being 1 letter..
getting closer but also farther away.
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 16:00

I don't use Facebook, I cannot check... perhaps some javascript is messing up the edit field on the website.
Someone else might chime in.
matthewd253
Posts: 9
Joined: 30 Dec 2018, 13:23

Re: Very new and want to write a script but don't know how...

30 Dec 2018, 20:45

hope so, i would like to figure this out.
hymal7
Posts: 66
Joined: 14 Sep 2016, 05:37

Re: Very new and want to write a script but don't know how...

02 Jan 2019, 12:00

you may need to define where this code will send the text to:
For example if it is a notepad, it goes like this:

Code: Select all

^x::   		 ; Ctrl + x
Loop, 10
{
	winactivate ahk_exe notepad.exe		;assuming you are sending this code to notepad. 
	SendInput, testing one {Enter}
	sleep 100		; sleep 50 ms
}
return
If it is in a specific location in a web browser, e.g. google chrome, then:

Code: Select all

^x::   		 ; Ctrl + x
Loop, 10
{
	winactivate ahk_exe chrome.exe		;assuming you are sending this code to chrome. 
	MouseClick, left, 250, 300		;sending left-click on x,y co-ordinates in the browser.
	SendInput, testing one {Enter}
	sleep 100		; sleep 50 ms
}
return
https://autohotkey.com/docs/commands/WinActivate.htm
https://autohotkey.com/docs/commands/MouseClick.htm

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: pgeugene, Sean24, SmithyZoomZoom and 174 guests