How to make a menu popup script to Send text? Topic is solved

Ask gaming related questions (AHK v1.1 and older)
mrrobogen
Posts: 4
Joined: 20 Jul 2021, 09:48

How to make a menu popup script to Send text?

Post by mrrobogen » 20 Jul 2021, 10:10

Hi,

So I play a game where you would have to type the same things a lot and there are a lot of same things to type and because of that I have run out of keys on my Numpad and I cannot add any more keys for AHK as there is a lot of other things going on at the time.
This is my previous script:

Code: Select all

SendInput, t/me Checks for the customer name on the blacklist.{enter}
sleep, 3000
SendInput, t/me Views the modview catalogue.{enter}
sleep, 3000
SendInput, t/me Grabs his PDA from his belt.{enter}
sleep, 2000
SendInput, t/me Creates an invoice and sends it to the customer using the LSC app.{enter}
sleep, 2000
SendInput, t/do would they sign it?{enter}
return
Now there are a lot of things which have occupied my numpad and sometimes I seem to forget that which button I need to press for the correct script to start.
What I need is a Menu script in which there will be list of names of multiple commands I want to execute.
For example: https://i.imgur.com/BwNhYuH.png

After pressing the "PDA" box, the above command executes, that way my numpad would be free, I would know what command I will be executing and It will also look clean.
I am a newbiew at scripting and AHK and would require some help.

Thank you.

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

Re: How to make a menu popup script to Send text?

Post by mikeyww » 20 Jul 2021, 10:40

Have you thought about using hotstrings? That is the point of them.

Code: Select all

SendMode Input
:CO:inv::t/me Creates an invoice and sends it to the customer using the LSC app.{Enter}
Menu approach:

Code: Select all

text := {Invoice: "t/me Creates an invoice and sends it to the customer using the LSC app."
       , More   : "More text here"}
For menuItem in text
 Menu, m, Add, %menuItem%
F3::Menu, m, Show

Invoice:
More:
SendInput % text[A_ThisLabel] "{Enter}"
Return

mrrobogen
Posts: 4
Joined: 20 Jul 2021, 09:48

Re: How to make a menu popup script to Send text?

Post by mrrobogen » 20 Jul 2021, 12:49

Yes, I know about hotstrings, but what about the sleep command? How am i going to execute it?
After typing "inv" I would want the whole script to work which i have typed above.
I need the delay to between each line of text that is why i used the sleep command.
To explain a bit more, I play GTA RP and for that I have to RP a lot of actions which means type alot, that is why i made this previous script to write 4 lines of text with seconds of delay, but now i want to do the same but this time with a menu.

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

Re: How to make a menu popup script to Send text?

Post by mikeyww » 20 Jul 2021, 13:19

Code: Select all

:C:inv::
text("t/me Checks for the customer name on the blacklist.")
text("t/me Views the modview catalogue.")
text("t/me Grabs his PDA from his belt.", 2000)
text("t/me Creates an invoice and sends it to the customer using the LSC app.", 2000)
text("t/do would they sign it?", 0)
Return

text(str, wait := 3000) {
 SendInput {Text}%str%
 SendInput {Enter}
 Sleep, wait
}
Or:

Code: Select all

Menu, m, Add, Invoice
F3::Menu, m, Show

Invoice:
text("t/me Checks for the customer name on the blacklist.")
text("t/me Views the modview catalogue.")
text("t/me Grabs his PDA from his belt.", 2000)
text("t/me Creates an invoice and sends it to the customer using the LSC app.", 2000)
text("t/do would they sign it?", 0)
Return

text(str, wait := 3000) {
 SendInput {Text}%str%
 SendInput {Enter}
 Sleep, wait
}
Or:

Code: Select all

Invoice := [["t/me Checks for the customer name on the blacklist.", 3000]
          , ["t/me Views the modview catalogue.", 3000]
          , ["t/me Grabs his PDA from his belt.", 2000]
          , ["t/me Creates an invoice and sends it to the customer using the LSC app.", 2000]
          , ["t/do would they sign it?", 0]]
Menu, m, Add, Invoice
F3::Menu, m, Show

Invoice:
text(%A_ThisLabel%)
Return

text(arr) {
 For k, v in arr {
  SendInput % "{Text}" v.1
  SendInput {Enter}
  Sleep, v.2
 }
}
Last edited by mikeyww on 20 Jul 2021, 13:31, edited 1 time in total.

mrrobogen
Posts: 4
Joined: 20 Jul 2021, 09:48

Re: How to make a menu popup script to Send text?

Post by mrrobogen » 20 Jul 2021, 13:28

Thank you so much, this is exactly what i needed

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

Re: How to make a menu popup script to Send text?

Post by mikeyww » 20 Jul 2021, 13:31

You are welcome. I added a third option, neither better nor worse.

mrrobogen
Posts: 4
Joined: 20 Jul 2021, 09:48

Re: How to make a menu popup script to Send text?

Post by mrrobogen » 20 Jul 2021, 14:50

Okay last thing,

If I want to add another menu with a different kind of text how will I be able to do that?
For example,

adding a "Battery Repair" menu consisting the code:

Code: Select all

SendInput, t/me Checks the battery of the vehicle.{enter}
sleep, 4000
SendInput, t/do would find the battery voltage level low.{enter}
sleep, 4000
SendInput, t/me takes wrench from belt and unlatches battery terminals.{enter}
sleep, 4000
SendInput, t/me rolls battery recharger over to car.{enter}
sleep, 4000
SendInput, t/me connects ground, then power cables.{enter}
sleep, 4000
Also thank you for helping me out here, I really appreciate it.

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

Re: How to make a menu popup script to Send text?  Topic is solved

Post by mikeyww » 20 Jul 2021, 16:08

Code: Select all

Invoice := [[3, "t/me Checks for the customer name on the blacklist."]
          , [3, "t/me Views the modview catalogue."]
          , [2, "t/me Grabs his PDA from his belt."]
          , [2, "t/me Creates an invoice and sends it to the customer using the LSC app."]
          , [0, "t/do would they sign it?"]]
Battery := [[4, "t/me Checks the battery of the vehicle."]
          , [4, "t/do would find the battery voltage level low."]
          , [4, "t/me takes wrench from belt and unlatches battery terminals."]
          , [4, "t/me rolls battery recharger over to car."]
          , [0, "t/me connects ground, then power cables."]]
Menu, m, Add, Invoice
Menu, m, Add, Battery
F3::Menu, m, Show

Invoice:
Battery:
text(%A_ThisLabel%)
Return

text(arr) {
 For k, v in arr {
  SendInput % "{Text}" v.2
  SendInput {Enter}
  Sleep, 1000 * v.1
 }
}

Post Reply

Return to “Gaming Help (v1)”