put 2 cripts into a 1. help! Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

put 2 cripts into a 1. help!

05 Nov 2017, 13:38

HI guys help me put this 2 scripts into a 1

1 script: this it's for ar weapon

End::Suspend
~RButton & ~LButton::
KeyWait LButton, T0.1
If (ErrorLevel = 1) {
While GetKeyState("LButton", "P") {
sleep, 110
Click
Setmousedelay 120
}
}
return

2 script:this script it's for ak weapon

#NoEnv
;#NoTrayIcon
#KeyHistory, 0
#SingleInstance, Force

SendMode, Input

Delete:: Suspend
Insert:: Reload

Y( a, y ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
X( b, x ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}

~RButton & ~LButton::
Loop {
Sleep, 40
Y( moveAmount, 24.2 )
X( moveAmount, -4.2 )
If Not GetKeyState( "LButton" ) {
Break
}
}
Return

PUT THIS 2 TO 1 !! AR TO F1 AK TO F2!!
Last edited by kostakosGR on 05 Nov 2017, 14:06, edited 1 time in total.
HIAC
Posts: 111
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: put 2 cripts into a 1. help!  Topic is solved

05 Nov 2017, 13:51

These scripts look exactly the same or I must be blind.
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:05

HIAC wrote:These scripts look exactly the same or I must be blind.
oh yes i will chan5e one script
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:06

kostakosGR wrote:HI guys help me put this 2 scripts into a 1

1 script: this it's for ar weapon

End::Suspend
~RButton & ~LButton::
KeyWait LButton, T0.1
If (ErrorLevel = 1) {
While GetKeyState("LButton", "P") {
sleep, 110
Click
Setmousedelay 120
}
}
return

2 script:this script it's for ak weapon

#NoEnv
;#NoTrayIcon
#KeyHistory, 0
#SingleInstance, Force

SendMode, Input

Delete:: Suspend
Insert:: Reload

Y( a, y ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
X( b, x ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}

~RButton & ~LButton::
Loop {
Sleep, 40
Y( moveAmount, 24.2 )
X( moveAmount, -4.2 )
If Not GetKeyState( "LButton" ) {
Break
}
}
Return

PUT THIS 2 TO 1 !! AR TO F1 AK TO F2!!
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:07

HIAC wrote:These scripts look exactly the same or I must be blind.
i already chan5ed the post
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:17

can you help me ??
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:25

guys help me post script code
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:29

You are going to need to define what you mean by combine.

You have two scripts that use the exact same hotkey. Do you want to preserve both functions? That would be something like this:

Code: Select all

#NoEnv
;#NoTrayIcon
#KeyHistory, 0
#SingleInstance, Force

SendMode, Input

Delete:: Suspend
Insert:: Reload
End::Suspend

~RButton & ~LButton::
KeyWait, LButton, T0.1
SetMouseDelay, 120
If ErrorLevel = 1 {
While GetKeyState("LButton","P") {
Sleep, 40
Y( moveAmount, 24.2 )
X( moveAmount, -4.2 )
If Not GetKeyState( "LButton" ) {
Break
}
Click
}
}
Return

; there are a couple pairs of optional brackets in here, but, that's OK


Y( a, y ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
X( b, x ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:31

Exaskryz wrote:You are going to need to define what you mean by combine.

You have two scripts that use the exact same hotkey. Do you want to preserve both functions? That would be something like this:

Code: Select all

#NoEnv
;#NoTrayIcon
#KeyHistory, 0
#SingleInstance, Force

SendMode, Input

Delete:: Suspend
Insert:: Reload
End::Suspend

~RButton & ~LButton::
KeyWait, LButton, T0.1
SetMouseDelay, 120
If ErrorLevel = 1 {
While GetKeyState("LButton","P") {
Sleep, 40
Y( moveAmount, 24.2 )
X( moveAmount, -4.2 )
If Not GetKeyState( "LButton" ) {
Break
}
Click
}
}
Return

; there are a couple pairs of optional brackets in here, but, that's OK


Y( a, y ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
X( b, x ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}




Np i dont want to preserve both functions!
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 14:35

@Exaskryz no idont want to preserve both functions!
kostakosGR
Posts: 9
Joined: 05 Nov 2017, 13:18

Re: put 2 cripts into a 1. help!

05 Nov 2017, 16:51

JUST I WANT THIS 2 SCRIPTS INTO A ONE WHEN I WILL PRESS F1 THE AR WEAPON SCRIPT WILL WORK QND F2 AK SCRIPT WILL WORK
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: put 2 cripts into a 1. help!

05 Nov 2017, 19:30

Then you'll probably want some #If control.

I'll give an example, and you can put your script into action. Just copy and paste as you please.

Code: Select all

#If ; these hotkeys always work:
F1::weapon:="ar"
F2::weapon:="ak"

#If (weapon="ar")
F3::MsgBox You have enabled AR

#If (weapon="ak")
F3::MsgBox You have enabled AK
Seriously, run my code so you understand what is going on. Then you can figure out what you want to do with your original scripts.
Guest

Re: put 2 cripts into a 1. help!

06 Nov 2017, 08:17

just send the code for this script f1 to ar code and f2 for ak code! and when i will press f1 ak script will be on and when i press f2 ar script will be on and ak script off !!
Guest

Re: put 2 cripts into a 1. help!

06 Nov 2017, 09:35

i have error in the line 41 can you help me

#If ; these hotkeys always work:
F1::weapon:="ar"
F2::weapon:="ak"

#If (weapon="ar")
F3::MsgBox You have enabled AR

#If (weapon="ak")
F3::MsgBox You have enabled AK

AR:
~RButton & ~LButton::
KeyWait LButton, T0.1
If (ErrorLevel = 1) {
While GetKeyState("LButton", "P") {
sleep, 110
Click
Setmousedelay 120
}
}
return

AK:
#NoEnv
;#NoTrayIcon
#KeyHistory, 0
#SingleInstance, Force

SendMode, Input

Delete:: Suspend
Insert:: Reload

Y( a, y ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
X( b, x ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}

~RButton & ~LButton::
Loop {
Sleep, 40
Y( moveAmount, 24.2 )
X( moveAmount, -4.2 )
If Not GetKeyState( "LButton" ) {
Break
}
}
Return
Guest

Re: put 2 cripts into a 1. help!

06 Nov 2017, 09:48

LIKE THAT???

#If ; these hotkeys always work:
F1::weapon:="ar"
F2::weapon:="ak"

#If (weapon="ar")
F3::MsgBox You have enabled AR

#If (weapon="ak")
F3::MsgBox You have enabled AK

#If (weapon="ar")
~RButton & ~LButton::
KeyWait LButton, T0.1
If (ErrorLevel = 1) {
While GetKeyState("LButton", "P") {
sleep, 110
Click
Setmousedelay 120
}
}
return

#If (weapon="ak")
#NoEnv
;#NoTrayIcon
#KeyHistory, 0
#SingleInstance, Force

SendMode, Input

Delete:: Suspend
Insert:: Reload

Y( a, y ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
X( b, x ) {
DllCall( "mouse_event", int, 1, int, x, int, y, uint, 0, uint, 0 )
}
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: put 2 cripts into a 1. help!

06 Nov 2017, 14:44

What you have is very close. For future reference, you can use [ code ] [ /code ](no spaces) tags to create:

Code: Select all

Code blocks
Your most recent code looks right. The only problem is you haven't included your second ~RButton & ~LButton:: hotkey. You fixed the duplicate hotkey error on Line 41 problem by putting in the #If (weapon="ar") and #If (weapon="ak") lines correctly.

So just add

Code: Select all

~RButton & ~LButton::
Loop {
Sleep, 40
Y( moveAmount, 24.2 )
X( moveAmount, -4.2 )
If Not GetKeyState( "LButton" ) {
Break
}
}
Return
To the very bottom and it should work.

There are a few other small problems, but they should not affect your script at all. The only other thing missing is your End::Suspend hotkey which you had in AR script; this should go underneath #If (weapon="ar") if you want to keep it.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, marypoppins_1 and 116 guests