Posts: 24
Threads: 11
Joined: Jan 2018
Hi everyone,
I need some help creating a macro.
Everytime I hit the hotkey, I want it to go through a list of lets say 20 different line of text and RANDOMLY or in ORDER pick one of them to paste out! For example:
"Hi"
"Hello"
"Bye"
"Okay"
So it would randomly or in order pick one of these and paste or type out once I hit the hotkey.
Would really appreciate it if anyone could help me with this!
Thanks in advance
Posts: 39
Threads: 14
Joined: Nov 2011
See below. I'm sure it can be done much smaller with an array, but here is a simple way to achieve what you are asking.
Macro
Random Message
str messageText = ""
int i = 0
i=RandomInt(1 20)
if (i = 1)
,messageText = "A"
if (i = 2)
,messageText = "B"
if (i = 3)
,messageText = "C"
if (i = 4)
,messageText = "D"
if (i = 5)
,messageText = "E"
if (i = 6)
,messageText = "F"
if (i = 7)
,messageText = "G"
if (i = 8)
,messageText = "H"
if (i = 9)
,messageText = "I"
if (i = 10)
,messageText = "J"
if (i = 11)
,messageText = "K"
if (i = 12)
,messageText = "L"
if (i = 13)
,messageText = "M"
if (i = 14)
,messageText = "N"
if (i = 15)
,messageText = "O"
if (i = 16)
,messageText = "P"
if (i = 17)
,messageText = "Q"
if (i = 18)
,messageText = "R"
if (i = 19)
,messageText = "S"
if (i = 20)
,messageText = "T"
out messageText
Posts: 1,336
Threads: 61
Joined: Jul 2006
02-24-2018, 03:00 AM
(This post was last modified: 02-24-2018, 04:52 AM by Kevin.)
this might be closer to what you are trying to do.
Function
randomize_or_choose_text_
Trigger
Sz
ARRAY(str) messageText="Random[]a[]b[]c[]d[]e[]f[]g[]h[]i[]j[]k[]l[]m[]n[]o[]p[]q[]r[]s[]t[]u[]v[]w[]x[]y[]z"
;;the above array is just for this demo. Change to whatever text you would like. each line of
;;text needs to have [] after it except last item
;; example ARRAY(str) messageText="Random[]Hi[]Hello[]Bye[]Goodbye[]Okay[]OK"
str result=messageText;;convert array to a string so we can display it in the ListDialog
int i=ListDialog(result);
sel i
,case 0
,ret
,case 1;;Random selected
,int ii=RandomInt(2 27);;set number range from 2-27 since 0 means cancel button clicked and 1 is for random
,out messageText[ii-1];;send to qm output window random item
,case else;; any other selected item
,out messageText[i-1];;send to qm output window selected item
Posts: 24
Threads: 11
Joined: Jan 2018
Hi, thanks for the help guys but none of these helped me unfortunately (maybe because im stupid)
The first one gave nothing in output, did not paste out anything anywhere upon press
The second one brings up a dialog I dont need, I just need it to paste or write out a random message from a list of messages.
Posts: 12,073
Threads: 140
Joined: Dec 2002
Macro
Macro2948
str messages=
;Zero
;One
;Two
;Three
;Four
;Five
;Six
;Seven
;Eith
;Nine
ARRAY(str) a=messages
paste a[RandomInt(0 a.len-1)]
#ret
;area for testing