Blue Eye Macro
http://blueeye-macro.com/

Is there a way to have BEM select from options in a script?
http://blueeye-macro.com/viewtopic.php?f=122&t=34725
Page 1 of 1

Author:  adeptzeno [ Tue May 28, 2019 3:58 pm ]
Post subject:  Is there a way to have BEM select from options in a script?

Hey again, still trying to figure some new stuff out lol.
So atm I am working on a logout macro that detects if a Direct message has been sent, selects the chat box, types out a message and then exits the game.
So far I have
Code:
 begin
     // Exit game if PM'ed
     if  Color.Pixel pattern can be located on screen("231,160,47,4,3,230,155,45,4,3,255,255,255,5,-4,230,157,46,3,-1,237,183,59,5,0,231,159,47,4,0,251,251,251,4,2,255,255,255,3,3,255,255,255", "10")
          begin
               Function.Execute("Exit")
          end
 end
function("Exit")
     begin
          Mouse.Click at pixel pattern("14,14,16,-2,-3,55,56,58,1,-3,55,55,58,3,-1,55,55,58,2,2,55,56,58,28,1,55,56,58,2,0,13,14,16,2,0,13,14,16,14,0,55,56,58,2,0,20,21,24,16,0,13,14,16,2,0,13,14,16,2,0,55,55,58,0,2,20,21,24,6,0,14,14,16", "10", "no", "Left")
          Function.Execute("Human Pause3")
          Keyboard.Type text("Sorry was just heading out ttyl")
          Macro.Pause("300")
          Keyboard.Press key("{<enter>}")
          Function.Execute("Human Pause3")
          Keyboard.Press key("{<esc>}")
          Function.Execute("Human Pause")
          Mouse.Click at coordinate("955", "630", "Left")
          Macro.Abort all macros()
     end
function



So far this works great with no issues.. But what I need to know is if there is a way for BEM to select from a group of options to use 1. Right now it will always write ("Sorry was just heading out ttyl"). So if the same person PM's me they will get the same exact message as last time.

Is there a way to set stuff like
1. Sorry was just heading out ttyl
2. G2g sorry
3. About to leave for work
and so on.

and then when
Code:
begin
     // Exit game if PM'ed
     if  Color.Pixel pattern can be located on screen("231,160,47,4,3,230,155,45,4,3,255,255,255,5,-4,230,157,46,3,-1,237,183,59,5,0,231,159,47,4,0,251,251,251,4,2,255,255,255,3,3,255,255,255", "10")
          begin
               Function.Execute("Exit")
          end
 end

Gets triggered it will select a random option?

Sorry if im not explaining this well.

Author:  Syrifina [ Tue May 28, 2019 4:32 pm ]
Post subject:  Re: Is there a way to have BEM select from options in a scri

Yea (more than one way to do it). You could either have a separate file with lines for what you want to say (for instances when they are either longer or you have a lot of them) or just write them out as separate functions. Then use a random number generator to pick either the function or line depending on what route you took. Like this:
Code:
 begin
     Variable.Set random number("x", "1", "3")
     Function.Execute("{x}")
 end

function("1")
     begin
          Window.Display message box("message one", "yes")
     end
function

function("2")
     begin
          Window.Display message box("message two", "yes")
     end
function

function("3")
     begin
          Window.Display message box("message three", "yes")
     end
function

...Of course replace "window.display" with your "type text" message

Other option is to use "read line" (viewtopic.php?f=163&t=330) if your pulling from a file. You also don't need to make it random either, you could go in order. To do that just use "increment variable" instead of choosing a random number. Additionally, you could add code so you don't get duplicates (if you go that route do a forum search for examples).

Author:  adeptzeno [ Tue May 28, 2019 4:35 pm ]
Post subject:  Re: Is there a way to have BEM select from options in a scri

Oh this is perfect, thanks a bunch.

Author:  Syrifina [ Tue May 28, 2019 5:02 pm ]
Post subject:  Re: Is there a way to have BEM select from options in a scri

The way above will add many lines to your macro, especially if you have a lot of responses. Here's an example of reading from a file:
Code:
 begin
     Variable.Set random number("x", "1", "4")
     File.Read line("C:\Users\Syrifina\Desktop\example.txt", "{x}", "result")
     Window.Display message box("{result}", "yes")
 end
Much shorter; you just need to create/save a file first.

You can copy/paste/run this one, just create a file and insert your path instead of the one I used and change the number of choices to the number of lines/responses in your file.

Author:  adeptzeno [ Thu May 30, 2019 7:54 am ]
Post subject:  Re: Is there a way to have BEM select from options in a scri

Syrifina wrote:
The way above will add many lines to your macro, especially if you have a lot of responses. Here's an example of reading from a file:
Code:
 begin
     Variable.Set random number("x", "1", "4")
     File.Read line("C:\Users\Syrifina\Desktop\example.txt", "{x}", "result")
     Window.Display message box("{result}", "yes")
 end
Much shorter; you just need to create/save a file first.

You can copy/paste/run this one, just create a file and insert your path instead of the one I used and change the number of choices to the number of lines/responses in your file.



It's beautiful , thanks for all the help and advice.
Code:
function("Exit")
     begin
          Mouse.Click at pixel pattern("14,14,16,-2,-3,55,56,58,1,-3,55,55,58,3,-1,55,55,58,2,2,55,56,58,28,1,55,56,58,2,0,13,14,16,2,0,13,14,16,14,0,55,56,58,2,0,20,21,24,16,0,13,14,16,2,0,13,14,16,2,0,55,55,58,0,2,20,21,24,6,0,14,14,16", "10", "no", "Left")
          Function.Execute("Human Pause3")
          Variable.Set random number("x", "1", "18")
          File.Read line("D:\Documents\BlueEye\p1pms.txt", "{x}", "result")
          Keyboard.Type text("{result}")
          Keyboard.Press key("{<enter>}")
          Function.Execute("Human Pause3")
          Keyboard.Press key("{<esc>}")
          Function.Execute("Human Pause")
          Mouse.Click at coordinate("955", "630", "Left")
          Macro.Abort all macros()
     end
function



Thats what I ended up with, so I didn't change much , just added your part. But now I will know for future macros I make thanks to you :D.

Author:  Syrifina [ Sun Jun 02, 2019 2:55 am ]
Post subject:  Re: Is there a way to have BEM select from options in a scri

No problem; glad you got it working!

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/