Triggers

Ask gaming related questions (AHK v1.1 and older)
akirby803
Posts: 3
Joined: 25 Nov 2021, 22:52

Triggers

Post by akirby803 » 26 Nov 2021, 12:42

I used to play MUDs and they had a command where if a word appeared on the screen it would trigger an effect. Something like, "You are hungry" the trigger word I had setup was 'hungry' so with the program seeing that it would send out, "Eat pot pie." I have looked and maybe I am just not getting it, but I was wondering if autohotkey could do something like this in a script.
I found this thinking if the word 'content' was typed in that the msgbox would display Hello World, but could not get it to work:

If (Variable = "content") msgbox Hello World

Below is how I am trying to add it to my current script. Any help is much appreciated.

Code: Select all

If (Variable = "runscript") then loop 70 else return

{
random, delay1, 1200, 1250
random, delay2, 6000, 8000
send, {4}
send, {w down}
Sleep %delay1%
Send, {w up}
send, {4}
sleep, %delay2%
}
Esc::ExitApp
return
[Mod edit: [code][/code] tags added.]

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

Re: Triggers

Post by mikeyww » 27 Nov 2021, 08:05

Welcome to AHK!

Code: Select all

:X:content::MsgBox, 64, Message, Hello, world!
Explained: Hotstrings

It seems that AHK syntax has some differences from what you may already know. You could look at some simple examples of
Loop, If, and other commands here on the forum.

akirby803
Posts: 3
Joined: 25 Nov 2021, 22:52

Re: Triggers

Post by akirby803 » 28 Nov 2021, 14:36

Great, I have the keyword working thanks a bunch. Last part to the puzzle. With the script running is there a way when in game if the game or another player displays or says the keyword in the game textbox it will trigger the script to start automatically?

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

Re: Triggers

Post by mikeyww » 28 Nov 2021, 15:30

You would probably need a SetTimer-- a timed and recurring subroutine-- that would look for text in a control, such as through ControlGetText.

akirby803
Posts: 3
Joined: 25 Nov 2021, 22:52

Re: Triggers

Post by akirby803 » 28 Nov 2021, 19:48

I have tried controlgettext to no avail. I ran window spy and this was the results:

World of Warcraft
ahk_class GxWindowClass
ahk_exe WowClassic.exe
ahk_pid 21588

If the character says 'rez' the script will run, but I would like for another character to say 'rez' for the script to run. I have posted the script as I have it atm. Thank you for all your help.

Code: Select all

ControlGetText, OutputVar, rez, World of Warcraft, rez ; ControlGetText, OutputVar [, Control, WinTitle, WinText]
:X:rez::

loop 30

{
random, delay1, 1200, 1250
random, delay2, 6000, 8000
send, {4}
send, {w down}
Sleep %delay1%
Send, {w up}
send, {4}
sleep, %delay2%
}
Esc::ExitApp
return

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

Re: Triggers

Post by mikeyww » 28 Nov 2021, 21:38

Sorry I do not have a way to test your issue; perhaps I should not have replied. I probably misunderstood your initial post. Others may know more.

Post Reply

Return to “Gaming Help (v1)”