Page 1 of 1

put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 13:38
by kostakosGR
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!!

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

Posted: 05 Nov 2017, 13:51
by HIAC
These scripts look exactly the same or I must be blind.

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:05
by kostakosGR
HIAC wrote:These scripts look exactly the same or I must be blind.
oh yes i will chan5e one script

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:06
by kostakosGR
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!!

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:07
by kostakosGR
HIAC wrote:These scripts look exactly the same or I must be blind.
i already chan5ed the post

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:17
by kostakosGR
can you help me ??

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:25
by kostakosGR
guys help me post script code

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:29
by Exaskryz
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 )
}

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:31
by kostakosGR
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!

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 14:35
by kostakosGR
@Exaskryz no idont want to preserve both functions!

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 16:51
by kostakosGR
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

Re: put 2 cripts into a 1. help!

Posted: 05 Nov 2017, 19:30
by Exaskryz
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.

Re: put 2 cripts into a 1. help!

Posted: 06 Nov 2017, 08:17
by Guest
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 !!

Re: put 2 cripts into a 1. help!

Posted: 06 Nov 2017, 09:35
by Guest
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

Re: put 2 cripts into a 1. help!

Posted: 06 Nov 2017, 09:48
by Guest
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 )
}

Re: put 2 cripts into a 1. help!

Posted: 06 Nov 2017, 14:44
by Exaskryz
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.