Please help me write the code

Ask gaming related questions (AHK v1.1 and older)
Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 07:28

Help me write the code. This code copies the numbers after Name_Surname[id]: 25 - the code below will copy the number 25, and I need the code to copy the number that is in [id]
Example:
Ivan_Ivanov[25]: help
I need the code to copy 25
help me please

Code: Select all

Numpad1::
FileRead, Str, %chatlog%
StringReplace, Str, Str, `r`n, `n, 1
StringReplace, Str, Str, `r, `n, 1

RegExMatch("`n" Str "`n", "i).*\n\[\d+:\d+:\d+]\s*\ .*?\[.*?] : \s*(/` *.*?(\d+)\s.*?)\n", Match)
SendMessage,0x50,,0x4190419,,A
SendInput, {F6}/sp %match2%{Enter}
return
[Mod edit: [code][/code] tags added.]

User avatar
boiler
Posts: 16955
Joined: 21 Dec 2014, 02:44

Re: Please help me write the code

Post by boiler » 22 Jan 2022, 09:39

I'm not sure why you have all the other stuff if all you need is the number that appears inside[25]:. You don't need to worry about replacing/stripping newline characters or anything like that. This will do it:

Code: Select all

Str =
(
some chat
Ivan_Ivanov[25]: help
some other chat
some more chat
)

RegExMatch(Str, "(?<=\[)\d+(?=]:)", Match)
MsgBox, % Match

If there is more than one line that has a number enclosed like that inside your captured chat string, it will grab the first one. If you want it to grab the last one, change it to this:

Code: Select all

Str =
(
some chat
Ivan_Ivanov[25]: help
Boris_Borisov[58]: no way
some other chat
some more chat
)

RegExMatch(Str, ".*\[\K\d+(?=]:)", Match)
MsgBox, % Match

Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Re: Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 12:41

I don't have specific strings to input Str. I have a chat where many players ask for help, so I need a code to fix exactly the number inside [ ], these numbers are developed from the players, that is, when entering the game, the player has his own identifier, which is found in [ ] and visited by the player until he leaves the game. I need to open the chat by F6 and enter this very player ID
@boiler

User avatar
boiler
Posts: 16955
Joined: 21 Dec 2014, 02:44

Re: Please help me write the code

Post by boiler » 22 Jan 2022, 12:49

You mean you want the numbers for all the players in the chat who typed just the word "help"?

Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Re: Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 13:01

no, I am an administrator and I help players who write to the report. I need a code to take a number from [ ].
the player can write not only the word "help", but absolutely any text

Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Re: Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 13:01

here is an example from the chat
https://yapx.ru/u/QPJzf

Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Re: Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 13:15

@boiler
https://imgur.com/a/UWB2zfE - screenshot of the player's message from the chat

User avatar
boiler
Posts: 16955
Joined: 21 Dec 2014, 02:44

Re: Please help me write the code

Post by boiler » 22 Jan 2022, 13:19

So I don’t know what you’re asking. I showed you code to get the number from inside the [ ] once you have the chat text captured in a variable. Are now you asking how to capture the chat text into a string?

Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Re: Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 13:27

I need a code to take the number from [ ], open the chat in the game (F6) and enter this number into the chat from [ ]
@boiler

User avatar
boiler
Posts: 16955
Joined: 21 Dec 2014, 02:44

Re: Please help me write the code

Post by boiler » 22 Jan 2022, 13:36

I showed how to get the number from inside the [ ] once you have the chat text inside the variable Str.

You send F6 like this:

Code: Select all

Send, {F6}

You send the number captured from the RegExMatch I showed like this:

Code: Select all

Send, % Match

Vladik2304
Posts: 24
Joined: 20 Jan 2022, 15:58

Re: Please help me write the code

Post by Vladik2304 » 22 Jan 2022, 13:44

I don't have a specific chat. I have real people playing, it's impossible to predict. Players have problems and they write to the administration for help, that is, I do not have a specific text or chat
@boiler

User avatar
boiler
Posts: 16955
Joined: 21 Dec 2014, 02:44

Re: Please help me write the code

Post by boiler » 22 Jan 2022, 13:56

You don't have to predict a specific chat. You just need to capture the chat text to a string and it pulls the number from the [ ].

You started this thread saying "I need the code to copy 25" from some text you showed. Are you now you're saying you need someone to write a script to monitor and capture chat from some window that has a bunch of chat boxes going at once? That's more a lot more involved, and not something I have time for.

Post Reply

Return to “Gaming Help (v1)”