Re6 script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re6 script

Post by Raiden96 » 23 Oct 2021, 07:20

Hello, I have this code

Code: Select all

XButton2::
Suspend, permit
if (State = 0)
{
	Soundbeep 3000, 300
	State++
}
Else
{
   State := 0 
   SoundBeep 2000, 300
   Sleep -1
   SoundBeep 2000, 300
}
Suspend, Toggle

rbutton up:: send {lbutton 10}
SetKeyDelay 800, 800
Return
It's supposed to press lbutton after pressing or holding rbutton for a specified number of times. What bothers me really is the fact that after activating the script using mouse5 left click is being immediately pressed making my character do a random kick which is not supposed to. At least not immediately after activating the script. It should do what it's supposed to only after pressing rbutton which is the trigger that should be followed by 10 lbutton presses.

Also also, i read that some games have a delay so using the default delay offered by send or setkeydelay is way to short for a game to even register it. So i suppose i need to adjust that as well.
So my question is : What would be the minimum delay i should start experimenting from? I'm still new to do this so i apologize for the silly questions.

Thanks alot!

Rohwedder
Posts: 7622
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Re6 script

Post by Rohwedder » 23 Oct 2021, 09:35

Hallo,
perhaps? (I added a Return and replaced SetKeyDelay with SetMouseDelay)

Code: Select all

XButton2::
Suspend, permit
if (State = 0)
{
	Soundbeep 3000, 300
	State++
}
Else
{
	State := 0
	SoundBeep 2000, 300
	Sleep -1
	SoundBeep 2000, 300
}
Suspend, Toggle
Return ; added
rbutton up::
SetMouseDelay 100
send {lbutton 10}
Return

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Re6 script

Post by mikeyww » 23 Oct 2021, 09:39

Another:

Code: Select all

XButton2::
on := !on
SoundBeep, 1000 + 500 * on
Return
#If on
~RButton Up::Send {LButton 10}
#If

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Re6 script

Post by Raiden96 » 23 Oct 2021, 11:31

@mikeyww It seems this is what i was looking for. Thanks alot! Any ideas how should i change the sound beep line to make a better distinction between the script being on off? I don't fully understand that line.
Also, i've googled to find sound files i could use instead of beeps. Like sounds saying activated/deactivated or on/off. Any idea where i can find some? Or do i have to buy?

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Re6 script

Post by mikeyww » 23 Oct 2021, 13:50

The beep parameter is the sound frequency. You could increase 500 to a higher number (e.g., 800). Currently, when on = True (1), sound frequency = 1000 + 500 * 1 = 1500; otherwise (on = 0), it is 1000 + 500 * 0 = 1000. You can always record your own voice files, and then just play them instead of the beep. Another approach is to provide a visual cue, such as an on-screen display, tooltip, or tray tip.

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Re6 script

Post by Raiden96 » 24 Oct 2021, 05:11

Thanks again @mikeyww for your answer. I've checked the SoundPlay method and i couldn't figure out a way to use the 2 sounds i've found for turning the script on and off without messing up with the script's functionality. I just can't seem to make it work. Also the sound files have the .ogg extension. I've seen people using only .wav files but i suppose these could work as well. But then again, i could be wrong. Also also, if i want a delay between my mouse clicks i suppose using SetMouseDelay is better than using SetKeyDelay isn't it? I know this question is a no-brainer but i've been using SetKeyDelay all this time and i think i shouldn't have.

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Re6 script  Topic is solved

Post by mikeyww » 24 Oct 2021, 06:55

An example is below. You can use a separate player for OGG, as shown here. SetMouseDelay is fine for this.

Code: Select all

soundDir = D:\pathToSounds ; Change as needed

#MaxThreadsPerHotkey 2
XButton2::
If on := !on
     play(soundDir "\01-Say_Goodbye_to_Hollywood.ogg", "mpc") ; Change as needed
Else play(soundDir "\06-What's_Good.mp3"             , "mpc")
Return
#If on
~RButton Up::
SetMouseDelay, 100
Click, 10
Return
#If

play(sound, player := "") {
 /* Use a media program to play a sound file ------------
 Parameters:
  sound  : Full path to the sound file
  player : "vlc" or "mpc" (for VLC player, or Media Player Classic)
           If null, play via AHK SoundPlay
 --------------------------------------------------------
 https://www.videolan.org/
 https://www.videohelp.com/software/Media-Player-Classic-Home-Cinema
 https://www.videohelp.com/software/OGG-Vorbis-ACM-Codec
 http://codecguide.com/download_k-lite_codec_pack_basic.htm
 https://www.autohotkey.com/board/topic/4734-soundplay-and-ogg-vorbis/
 https://www.autohotkey.com/boards/viewtopic.php?f=18&t=95930
 Disable VLC tray tip: Tools -> Preferences -> Interface -> Show media change popup -> Never
 --------------------------------------------------------
*/
 Static vlc := ProgramFiles "\VideoLAN\VLC\vlc.exe"
      , mpc := "d:\utils\MPC-HC\mpc-hc64.exe" ; Change as needed
 If !FileExist(sound)
  Return
 SoundPlay, ""
 Switch player {
  Case "vlc": Run, %vlc% --one-instance --qt-start-minimized "%sound%"
  Case "mpc": Run, %mpc% "%sound%" /minimized /play /close
  Default   : SoundPlay, %sound%
 }
}

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Re6 script

Post by Raiden96 » 24 Oct 2021, 10:16

Thanks for the code @mikeyww.

Code: Select all

soundDir = C:\Users\Quickstall\Desktop\RE6
#MaxThreadsPerHotkey 2
XButton2::
If on := !on
     play(soundDir\c1.ogg, "mpc")
Else play(soundDir\c2.ogg, "mpc")
Return
#If on
~RButton Up::
SetMouseDelay, 100
Click, 10
Return
#If
I can't for the life of me figure out why i'm getting the error that the leftmost character above is illegal in an expression for this line

Code: Select all

play(soundDir\c1.ogg, "mpc")
. I've tried to fix it but to no avail. I hate being such a headache but can you enlighten me as to what i'm doing wrong here? I just don't see it. I've tried everything that has come to my mind but nothing.

User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Re6 script

Post by mikeyww » 24 Oct 2021, 10:59

Yep. Use the format that I showed. It has quotation marks.

Raiden96
Posts: 38
Joined: 23 Oct 2021, 07:03

Re: Re6 script

Post by Raiden96 » 24 Oct 2021, 13:04

Thanks a lot @mikeyww for your help! I finally reached the point where i wanted the script to be. Cheers!

Post Reply

Return to “Gaming Help (v1)”