I am having a lot of fun messing around with the scripts I have found and I thought I would like to make my own. Unfortunately, my method of scripting involves hacking apart existing scripts and trying to make them work for what I want to do. Sadly, I am unable to make any headway here with my lack of understanding of C#.
Could someone look at the below mess and point me in the right direction to accomplish my goal? I would like for the “scan” button to be pressed at an interval. Pressing the “V” (keyboard shortcut)key, would be great, also but, I couldn’t find anything that permits that.
EDIT: What is the board code for a “Code Block”? - ANSWERED; TY VIIR
Thanks!
//Run until stopped
while(true)
{
//Read Eve memory capture
var Measurement = Sanderling?.MemoryMeasurementParsed?.Value;
//Find Dscan window
var ?????? = Measurement?.WindowOther?.FirstOrDefault(w => (w?.Caption.RegexMatchSuccessIgnoreCase("Directional Scanner") ?? false) && (w?.isModal ?? false));
//Click SCAN button
var ConfirmButton = ConfirmWindow.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Scan") );
Sanderling.MouseClickLeft(YesButton);
}
// wait for ten seconds before repeating.
Host.Delay(10000);
Here try this little function /// Simple function to dscan no error checking
/// Default usage runs for 10 times with a delay of 10 seconds
void DScanner(int HowMany=9,int Delay=10)
{
while(0 < HowMany)
{
Sanderling.KeyboardPress(VirtualKeyCode.VK_V);
Host.Delay(1000*Delay);
HowMany–;
}
}
I’ve taken some shots in the dark to get it to work but, no luck. It seems like it is looking for something after the hyphen but, I can’t figure out what it is.
Believe it or not, that was one of my shots in the dark. I get happy green checks and the script runs to completion once (does not repeat)… but, does not appear to perform the job. I’m going to try and add a delay before it does it’s thing so that I can focus the Eve client and see if that works
Don’t know what is wrong it works fine with me One thing it could be … is it putting 'V’s in chat? You might want to replace the Keyboard press function with the actual mouse click. But that requires you to find the dscan window
which your code already has and click the Scan button.
My function was written quickly and needs a bath. I tested it for a couple iterations I called it like DScan(60);
so 60 iterations at 10 seconds each
Which ran perfectly while I was killing sleepers in a wormhole.
Thanks for the help - this is a nice and simple little bit of code that will be good for me to troubleshoot and learn.
I also want to definitely figure out how to do it via ‘finding the window’ and a mouse click. Once I have that knowledge, I can start customizing some more in small increments to build a perfect script for my needs
Thanks again!
EDIT: …and yes, the motivation for my script is to make life a little easier in the wormholes!
EDIT2: Oh, and no - it wasn’t entering anything in chat. It simply ran once (without appearing to do anything), no errors and did not run 9 more intervals, like was specified. I’ll try and figure it out, though. If it worked once - it can work again.
If you want to be sure that your script does not write “v” in the chat window, you can add something like that (it will left clic on your ship UI center (capacitor))
var ListSurroundingsButton =Sanderling?.MemoryMeasurementParsed?.Value?.ShipUi?.Center;
Sanderling.MouseClickLeft(ListSurroundingsButton);
if you put that in the “while” instruction it will do it at each call of DScan. If before, only once (witch might be enough)
/// Simple function to dscan no error checking
/// Default usage runs for 10 times with a delay of 10 seconds
void DScanner(int HowMany=9,int Delay=10)
{
var Capa=Sanderling?.MemoryMeasurementParsed?.Value?.ShipUi?.Center;
Sanderling.MouseClickLeft(Capa);
while(0 < HowMany)
{
Sanderling.KeyboardPress(VirtualKeyCode.VK_V);
Host.Delay(1000*Delay);
HowMany–-;
}
}`
Edit: I said a nonsense about x10000 for millisecondes…
I had a look at this problem.
I took the code posted by @Maniac and modified it to fix the problem you are seeing. Following is the complete code:
/// Simple function to dscan no error checking
/// Default usage runs for 10 times with a delay of 10 seconds
/// The following code is contained in a 'method' and only executed when this method is called ->
void DScanner(int HowMany=9,int Delay=10)
{
while(0 < HowMany)
{
Host.Log("I press the key now....");
Sanderling.KeyboardPress(VirtualKeyCode.VK_V);
Host.Delay(1000*Delay);
HowMany--;
}
}
DScanner(4, 10); // This is a method call
Ok, this is starting to make more sense to me. I need to get a better grasp of the syntax and the structure but, I think I am starting to understand the fundamentals. Thanks for that addition of the method call - that was a missing piece of the puzzle. I was never executing the function of the code section. It basically ran with no instructions - makes perfect sense.
Also, thanks for the “code block” reference… I must have overlooked it - I don’t want to look lazy
I’ve used the code that all 3 of you helped me with and it works perfectly. …in an effort to stay stealthy - I would like to invoke the random number generator to define a period of delay between scans (I have other uses planned for this as well). Basically, I would specify that I want the scan to operate every, for example, 5 to 15 seconds.
I added a few lines (which I borrowed from @kaboonus and it seems to function. I am confused, though, as to what the numbers in “void DScanner(int HowMany=9,int Delay=10)” and the “DScanner(4, 10);”, do.
With my current script, it runs 4 times and then stops. It seems as though my random lines are overriding the 10 second delay… which is fine. The void statement seems to have no effect, though.
/// Simple function to dscan no error checking
/// Default usage runs for 10 times with a delay of 10 seconds
/// The following code is contained in a 'method' and only executed when this method is called ->
var MinimDelayDscan = 5;//in seconds //random number range mimimun
var MaximDelayDscan = 15;//in seconds //random number range maximum
void DScanner(int HowMany=9,int Delay=10) //????
{
var Capa=Sanderling?.MemoryMeasurementParsed?.Value?.ShipUi?.Center; //find this bit of the UI
Sanderling.MouseClickLeft(Capa); //click this bit ^^
while (true)//(0 < HowMany) uncomment this and replace true to set number of cycles #1
{
Random rnd = new Random(); //random number code
int DelayTime = rnd.Next(MinimDelayDscan, MaximDelayDscan); //random number code
Host.Log("Dscan in : " + DelayTime+ " s "); //echo in log what is happening
Sanderling.KeyboardPress(VirtualKeyCode.VK_V); //virtual keyboard press "v"
Host.Delay(789*Delay); //time to wait between code runs
//HowMany--; uncomment this and replace 'true' to set number of cycles #2
}
}
// This is a method call
DScanner(10);//, 10); uncomment this and add ', 10);'to set number of cycles #3
Thanks again for your help and patience - I’m making small steps
EDIT: Do the variables in the method call override the variables in the void statement? I now have this:
DScanner(4); // This is a method call
…and it didn’t break
basicaly from your last post I understand that:
you click on center of shipui center.
while that is true, you take a random number between 5 and 15(delaytime)
you press V ( to scan system)
you wait 789*10 (delay ) => 7890 miliseconds = 7.8 sec.
so your random time have no impact.
for having an impact you have to have
Host.Delay(DelayTIme*1000) //=> delay of random generated in seconds
Hmm… I am not sure how, but it appears to be working with random generated pause between “V” presses
EDIT: Here is exactly what I am running right now:
/// Simple function to dscan no error checking
/// Default usage runs for 10 times with a delay of 10 seconds
// DScanner(19,3) will run 20 times at 3 second intervals
// DScanner(19) will run 20 times at Delay=10 intervals
// DScanner() will run 10 times at Delay=10 intervals
// the int HowMany=9 and int Delay=10 are placeholders for arguments they will
// default to 9 and 10 if they are not present
/// The following code is contained in a 'method' and only executed when this method is called ->
var MinimDelayDscan = 5;//in seconds //random number range mimimun
var MaximDelayDscan = 15;//in seconds //random number range maximum
void DScanner(int HowMany=9,int Delay=10) //????
{
var Capa=Sanderling?.MemoryMeasurementParsed?.Value?.ShipUi?.Center; //find this bit of the UI
Sanderling.MouseClickLeft(Capa); //click this bit to insure 'chat' is not focused ^^
while (true)//(0 < HowMany) uncomment this and replace true to set number of cycles #1
{
Random rnd = new Random(); //random number code
int DelayTime = rnd.Next(MinimDelayDscan, MaximDelayDscan); //random number code
Host.Log("Dscan in : " + DelayTime+ " s "); //echo in log what is happening
Sanderling.KeyboardPress(VirtualKeyCode.VK_V); //virtual keyboard press "v"
Host.Delay(789*Delay); //time to wait between code runs
//HowMany--; uncomment this to set number of cycles #2
}
}
// This is a method call
DScanner();//(10, 10); uncomment this to set number of cycles #3
OK, I see what you are saying. My counter is not accurate.
I’m going to change that and test it.
Edit: Ok, I understand now. By setting the host delay to 7.89 seconds - the code will never run faster than that.
I have changed Host.Delay(789Delay) —> Host.Delay(499Delay);
It seems to work perfect.
Great observation - thank you!!!
EDIT2: Hmm maybe I don’t have it figured out. Now the scan fires every 4.99. lol. I am a blind man in the china shop. I will figure it out, though