WindowTelecom , Huston I have a problem (solved)


#1

Hello and thank you for your work and help . Actually I’m glad to be here.
So , after I successfully ( more or less) to make some modifications at ABOT , I’m stuck at this window dialogue. Once I warp to anomaly, this window come and i cannot close the window.
In framework with one of my scripts, its work like a charm, but not in Abot.
this is my code ( and I’m null at coding stuffs)
at var Closebutton = …; i take an ArgumentNullException

Blockquote
var memoryMeasurementAtTime = bot?.MemoryMeasurementAtTime;
var memoryMeasurementAccu = bot?.MemoryMeasurementAccu;
var memoryMeasurement = memoryMeasurementAtTime?.Value;
var WindowTelecom = memoryMeasurement?.WindowTelecom?.FirstOrDefault(w => (w?.Caption.RegexMatchSuccessIgnoreCase(“Information”) ?? false));
var CloseButton = WindowTelecom.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase(“Close”));
if (CloseButton != null)
yield return new BotTask { Effects = new[] { CloseButton.MouseClick(BotEngine.Motor.MouseButtonIdEnum.Left) } };

Blockquote

Thank for your help


#2

here is the code for Sanderling, and is working. Somebody cant tell me why i take argument null exception this this 2 var in ABOT and how I can make it work?
Sanderling.Parse.IMemoryMeasurement Measurement => Sanderling?.MemoryMeasurementParsed?.Value;
var WindowTelecom = Measurement?.WindowTelecom?.FirstOrDefault(w => (w?.Caption.RegexMatchSuccessIgnoreCase(“Information”) ?? false));
var CloseButton = WindowTelecom.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase(“Close”) );
if(CloseButton != null)
Sanderling.MouseClickLeft(CloseButton);


#3

With the code you showed, an exception can be thrown if your WindowTelecom is null.

To fix this, replace
WindowTelecom.
with
WindowTelecom.?


#4

Thank you Viir, you saved my life :)) its working now

Id like to put a delay after each retreat task , there are options to do that?
I tried like in framework, and it didn’t work.
Tried with thread sleep and task delay, but is complicated and it seems its not working ( at least for me)
I investigated the option to play a file ( music , *wav) before push undock button for 1-5 min but its asking for file permissions…
thank you


#5

@kaboonus


#6

after what i read over net and look in bot, it seems thread sleep it could work; but from my side, playing a sound is nice and easy. but it ask for special permissions to files or to soundplayer. my lvl in coding is null also


#7

news :slight_smile: I followed the theories to learn something by try and fail…
until now, i tried with thread.sleep . it load an reload the line before this command ( in my case i put an audio before undock) and UI froze :d :))
better method it is by using task.delay but is async … dunno how i can implement that ; something like : private async void button1_Click(object sender, EventArgs e)
{
textBox1.Text += “\r\nThread Sleeps!”;
await Task.Delay(3000);
textBox1.Text += “\r\nThread awakens!”;
}

next and it seems the way used in bot is using timers ( sleep it seems be used 3-4 times because the bot must wait to load some data’s from game interface)
i found an example using timers ( is used 10-15 times in bot, actually after each step and mouse click). I dont know how he implemented timers, but i found an example over net:
0
down vote

By adding using System.Timers; to your program you can use this function:

private static void delay(int Time_delay)
{
int i=0;
// ameTir = new System.Timers.Timer();
_delayTimer = new System.Timers.Timer();
_delayTimer.Interval = Time_delay;
_delayTimer.AutoReset = false; //so that it only calls the method once
_delayTimer.Elapsed += (s, args) => i = 1;
_delayTimer.Start();
while (i == 0) { };
}

Delay is a function and can be used like:

delay(5000);

so, how can we put that in our code?