macro script h

Ask gaming related questions (AHK v1.1 and older)
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

macro script h

29 Mar 2017, 02:07



is it possible to just send a certain key once when u hold the macro activation key ? for example , 2a a a a a a a a a a a . when i hold the macro button it will send 2 once only and after i release and press it again it will do the same.Another thing , how can i make it so that as long as i hold the macro key , it will also hold right click until i release it.Also how to make it reach maximum speed at 16.1

here is my script:

#InstallMouseHook
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
if not A_IsAdmin
{
MsgBox, You are running this script with no administrator rights. It may not work.
}

$*MButton::
;ensuring that the player doesn't interfere with the macro
Send {SC011 Up} ;W
Send {SC01E Up} ;A
Send {SC01F Up} ;S
Send {SC020 Up} ;D
;the actual inputs
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {2 Down}
Send {Click Right Down}
Send {Space Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {2 Up}
Send {SC020 Down}
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {Space Up}
Send {SC020 Up}
;ensuring that the macro doesn't interfere with the player
if GetKeyState("SC011","P")
Send {SC011 Down}
if GetKeyState("SC01E","P")
Send {SC01E Down}
if GetKeyState("SC01F","P")
Send {SC01F Down}
if GetKeyState("SC020","P")
Send {SC020 Down}
DllCall("kernel32.dll\Sleep", "UInt", 350)
if GetKeyState("RButton","P")
Send {Click Right Down}
else
Send {Click Right Up}
return
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

31 Mar 2017, 00:52

#InstallMouseHook
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
if not A_IsAdmin
{
MsgBox, You are running this script with no administrator rights. It may not work.
}

$*v::
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {4 Down}
Loop
{
;ensuring that the player doesn't interfere with the macro
Send {SC011 Up} ;W
Send {SC01E Up} ;A
Send {SC01F Up} ;S
Send {SC020 Up} ;D
;the actual inputs
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Space Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {4 Up}
Send {SC020 Down}
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Space Up}
Send {SC020 Up}
;ensuring that the macro doesn't interfere with the player
if GetKeyState("SC011","P")
Send {SC011 Down}
if GetKeyState("SC01E","P")
Send {SC01E Down}
if GetKeyState("SC01F","P")
Send {SC01F Down}
if GetKeyState("SC020","P")
Send {SC020 Down}
DllCall("kernel32.dll\Sleep", "UInt", 350)
if GetKeyState("RButton","P")
Send {Click Right Down}
else
Send {Click Right Up}
}
return

$*Ins::Suspend



is this correct? i tried it and yes it works with spamming 4 d d d d d d but it work stop even thought i stopped holding the button.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: macro script h

31 Mar 2017, 04:33

No, a Loop is totally different to a while (GetKeyState(A_ThisHotkey)){

Also, DllCall("kernel32.dll\Sleep", "UInt", 16.1) 16.1 is not an integer. Why use a DLLCall for a sleep anyway?
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

31 Mar 2017, 07:31

evilC wrote:No, a Loop is totally different to a while (GetKeyState(A_ThisHotkey)){

Also, DllCall("kernel32.dll\Sleep", "UInt", 16.1) 16.1 is not an integer. Why use a DLLCall for a sleep anyway?

to make it faster using DLLCall since it can send in millisecond ?what should the script be to achieve the maximum speed for 62.5fps game .this is button that the macro should click "4 d " .i wan it to be "4 d d d d d d d d d d d d d d d d "" when i hold the button.this is the trick for this macro https://www.youtube.com/watch?v=jeaFqdDXIx4 . the key is space+a+space(the a+space should be click together if not it wont work). thx
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: macro script h

31 Mar 2017, 07:47

bryantan179 wrote:to make it faster using DLLCall since it can send in millisecond ?
AHK's sleep command uses milliseconds Sleep 16

My point was that Sleep takes WHOLE NUMBERS ("Integers") eg 10, 25 or 33.

It DOES NOT take decimals ("Floating point") eg 1.5, 2.3 etc

When you issue the command DllCall("kernel32.dll\Sleep", "UInt", 16.1), you will be sleeping for 16, not 16.1
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

31 Mar 2017, 08:44

ok . no big difference :D
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

31 Mar 2017, 08:53

evilC wrote:No, a Loop is totally different to a while (GetKeyState(A_ThisHotkey)){

Also, DllCall("kernel32.dll\Sleep", "UInt", 16.1) 16.1 is not an integer. Why use a DLLCall for a sleep anyway?

so how do i loop ''4'' to make it 4 d d d d d d d d d d d d d d d d ??
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: macro script h

31 Mar 2017, 10:43

Using the GetKeyState method that I showed you, replace 2 with 4 and a with d:

Code: Select all

F12::
	Send 4
	while (GetKeyState(A_ThisHotkey)){
		Send d
		Sleep 10
	}
	return
Loops for ever, never stops.

Code: Select all

F12::
	Loop {
		...
	}
Loops until you release F12:

Code: Select all

F12::
	while (GetKeyState(A_ThisHotkey)){
		...
	}
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

02 Apr 2017, 07:55

is it possible to macro a script mash the activation button instead of holding it ?i wan the ahk to be press at fast speed instead of holding it when i hold the button because when i hold the button , its too slow ,instead when i spam the button it can react faster . :) . maybe i can give this script a name and write Send { (Script Name) Down } .. , { (Script Name) Up } ??

here is the script:
#InstallMouseHook
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
if not A_IsAdmin
{
MsgBox, You are running this script with no administrator rights. It may not work.
}

$*MButton::
;ensuring that the player doesn't interfere with the macro
Send {SC011 Up} ;W
Send {SC01E Up} ;A
Send {SC01F Up} ;S
Send {SC020 Up} ;D
;the actual inputs
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {2 Down}
Send {Click Right Down}
Send {Space Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {2 Up}
Send {SC020 Down}
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {Space Up}
Send {SC020 Up}
;ensuring that the macro doesn't interfere with the player
if GetKeyState("SC011","P")
Send {SC011 Down}
if GetKeyState("SC01E","P")
Send {SC01E Down}
if GetKeyState("SC01F","P")
Send {SC01F Down}
if GetKeyState("SC020","P")
Send {SC020 Down}
DllCall("kernel32.dll\Sleep", "UInt", 350)
if GetKeyState("RButton","P")
Send {Click Right Down}
else
Send {Click Right Up}
return
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

03 Apr 2017, 02:25

i dont really understand. can you make 1 script for me using the loop ? the buttoon for macro is ''v'' and the macro should click 4 {s down} {space down} {s up} {space up } {a down} {space down} {a up} {space up} and hold right click when i hold ''v'' and right click will be released when ''v'' is released .the macro should be like this 4s a s a s a s a s a s a s a s a when i hold down the ''v'' button.
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

03 Apr 2017, 06:16

evilC wrote:

Code: Select all

F12::
	Send 2
	while (GetKeyState(A_ThisHotkey)){
		Send a
		Sleep 10
	}
	return

i dont really understand. can you make 1 script for me using the loop ? the button for macro is ''v'' and the macro should click 4 {s down} {space down} {s up} {space up } {a down} {space down} {a up} {space up} and hold right click when i hold ''v'' and right click will be released when ''v'' is released .the macro should be like this 4s a s a s a s a s a s a s a s a when i hold down the ''v'' button.

where is the space and the button s ? just give me the full script . the button for macro is ''v'' and the macro should click 4 {s down} {space down} {s up} {space up } {a down} {space down} {a up} {space up} and hold right click when i hold ''v'' and right click will be released when ''v'' is released .the macro should be like this 4s a s a s a s a s a s a s a s a when i hold down the ''v'' button.

as i said i dont understand anything because i am new to this thing.
bryantan179
Posts: 74
Joined: 29 Mar 2017, 01:55

Re: macro script h

03 Apr 2017, 06:22

evilC wrote:

Code: Select all

F12::
	Send 2
	while (GetKeyState(A_ThisHotkey)){
		Send a
		Sleep 10
	}
	return

the button for macro is ''v'' and the macro should click 4 {s down} {space down} {s up} {space up } {a down} {space down} {a up} {space up} and hold right click when i hold ''v''

as i said before the ''s'' and ''space'' have to be click together and after that ''a'' and ''space'' have to be clicked together .
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: macro script h

03 Apr 2017, 07:34

You were asking me how you achieved a certain logic in AHK, and I showed you.
You said you wanted it to send a certain key sequence (2 once, followed by a repeated)

If you now require different keys, adjust the code accordingly.
just give me the full script
You do not come to a forum like this and get uppity when we do not do your work for you.
The main goal of this forum is to help people learn how to code, not a free code-writing service.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 78 guests