Script/Macro

Ask gaming related questions (AHK v1.1 and older)
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Script/Macro

13 Jun 2017, 11:42

Hi
I need a script for one weapon:
[Automatic] QQ - 1ms - right click and repeat till suspend key pressed
Thanks
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

14 Jun 2017, 08:24

Does this code work for you?

Code: Select all

+LButton::		; Shift + LMB to start.
	Looping := 1
	While Looping
	{
		SEND, qq
		SLEEP 1	; Wait 1 ms (I reccommand 40, this is the time I use most of the time to simulate a human action. This is the least time I take to press a button.)
		SEND, {RButton}		; Simulate the Right mouse button click.
	}
	Return

!LButton::		; Alt + LMB to stop.
	Looping := 0
	Return
Hope this helps.
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

14 Jun 2017, 08:38

Also this code I made for someone else asking for the same combo. Are you playing the same game?
Advantage of this code is the use of just one hotkey.

Code: Select all

#MaxThreadsPerHotkey 2	; Makes pressing capslock while the loop is running possible/effective.
Capslock::
	If Comboing	; Executed on second Capslock press.
	{
		Comboing := 0	; The loop should stop now.
		Return
	}

	Comboing := 1
	While Comboing		; Start the loop.
	{
		SEND, qq
		SLEEP 1
		SEND, {RButton}
	}
	Return
#MaxThreadsPerHotkey 1
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

15 Jun 2017, 04:55

Yes this is for the same game, thank you so much!!
But can be added one thing? I mean when i press Capslock before all the work is doing script presses "3" and when the suspend key pressed it presses "1"?
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

15 Jun 2017, 06:11

So when you start the loop with Capslock you want to simulate the 3 button. And when the loop stops, after pressing Capslock again, Send a 1 keystroke.
If I understood well, this should do the trick.

Code: Select all

#MaxThreadsPerHotkey 2	; Makes pressing capslock while the loop is running possible/effective.
Capslock::
	If Comboing	; Executed on second Capslock press.
	{
		Comboing := 0	; The loop should stop now.
		Return
	}

	Comboing := 1
	
	SEND, 3
	
	While Comboing		; Start the loop.
	{
		SEND, qq
		SLEEP 1
		SEND, {RButton}
	}
	
	SEND, 1
	Return
#MaxThreadsPerHotkey 1

MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

15 Jun 2017, 10:45

I can stop this script
Capslock isnt working
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

15 Jun 2017, 13:04

Does it work with another hotkey. Like \:: instead of Capslock::.
Doesn't it work in the game? Have you tested it in notepad or something similar?

On my pc I get "3qq" and then a lot of context menu's from the Right mouse presses.
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

15 Jun 2017, 14:23

None of hotkeys is working
It doesn't work in notepad, in game
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

15 Jun 2017, 18:23

Capslock- looped - QQ 650ms/RButton 650ms
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

16 Jun 2017, 02:46

So the script is running and working only verry verry slow?
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

16 Jun 2017, 03:55

I need perfect timing to do a combo
This weapon is called storm giant warhammer, you can see on youtube how it works
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

16 Jun 2017, 04:58

If the script is working in chat but not working in the game itself there is verry less I can do.
This script works sycinificant slower but still fast. Maybe the game can keep up with this better.

Code: Select all

SendMode, Input
HumanDelay := 40

#MaxThreadsPerHotkey 2	; Makes pressing capslock while the loop is running possible/effective.
Capslock::
	If Comboing	; Executed on second Capslock press.
	{
		Comboing := 0	; The loop should stop now.
		Return
	}

	Comboing := 1
	
	SEND, {3 Down}
	SLEEP, HumanDelay
	SEND, {3 Up}
	SLEEP, HumanDelay
	
	While Comboing		; Start the loop.
	{
		SEND, {q Down}
		SLEEP, HumanDelay
		SEND, {q Up}
		SLEEP, HumanDelay
		
		SEND, {q Down}
		SLEEP, HumanDelay
		SEND, {q Up}
		SLEEP, HumanDelay
		
		SEND, {RButton Down}
		SLEEP, HumanDelay
		SEND, {RButton Up}
		SLEEP, HumanDelay
	}
	
	SEND, {1 Down}
	SLEEP, HumanDelay
	SEND, {1 Up}
	
	Return
#MaxThreadsPerHotkey 1
Have fun with further coding.
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

16 Jun 2017, 05:35

QQ too fast and Rbutton too slow :/
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

16 Jun 2017, 05:36

Maybe you can add RButton to this
Q::Send, QQ
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

16 Jun 2017, 05:48

QQ too fast and Rbutton too slow
That means the code is working? Only the speed must be adjusted? You can replace the "HumanDelay" words with any value in milliseconds. HumanDelay is now set to 40ms. You want it to go faster? Decrease it to 20 for example. Want it to go slower, increase it to 80 etc. This is most of the time a trial and error process.
Q::Send, QQ
Your code with the RButton:

Code: Select all

Q::Send, QQ{RButton}
MachinkaDoLudzi
Posts: 9
Joined: 11 Jun 2017, 10:59

Re: Script/Macro

16 Jun 2017, 07:04

How can i add sleep in Q::Send, QQ{RButton}?
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Script/Macro

16 Jun 2017, 07:17

Not in a controlled way. With "SetKeyDelay" the standard duration van be changed. But if you want to have differen delays between echt key you will need to type a SLEEP command after each SEND command. The SendInput mode does not read SetKeyDelay.

Code: Select all

Q::
SetKeyDelay, 50, 20 ; Sets the delay to 50ms and the pressd duration to 20ms.
Send, QQ{RButton}
Return
All manualy adjustible:

Code: Select all

q::
SEND, q
SLEEP, 50
SEND, q

SLEEP, 50
SEND, {RButton}
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 37 guests