Not logged inRybka Chess Community Forum
Up Topic Rybka Support & Discussion / Aquarium / Script to stop analysis/IDeA and exit Aquarium
- - By Checks Date 2017-09-12 21:46
Dear all,

is it possible to create a script to stop IDeA and exit Aquarium after a given amount of time?

I tried Windows shutdown.exe, but it seems all IDeA progress is lost if the computer shuts down without stopping IDeA before.

Thanks for your help.
Parent - - By Ghengis-Kann (***) [us] Date 2017-09-12 22:30
Hi Checks.

Sorry I can't answer your question because I know absolutely nothing about how scripting works in Aquarium.

Is there documentation anywhere that explains this functionality?
Parent - By Ghengis-Kann (***) [us] Date 2017-09-13 19:21
Thank you.
Parent - - By nebulus (****) [no] Date 2017-09-13 03:34 Edited 2017-09-13 03:42
You would have to use an external program, for example AutoHotkey.
AutoHotkey script bellow (save as .ahk) will wait for 5 seconds and then click on Stop IDeA button, so it requires that Home-IDeA tab is open. In other words that the Start/Stop/Abort button is visible. Window can be minimized.
[hl=plain]
if WinExist("ahk_exe Aquarium.exe")   ; check if Aquarium is open
{
    Sleep, 5000   ; 5 sec, given amount of time to wait
    WinActivate   ; activate window
    SetControlDelay -1   ; avoids holding the mouse button during the click
    GroupAdd, Stop, Stop IDeA
    ControlClick, Stop, Aquarium ahk_class TfmRPlayMain   ; click Stop IDeA button
    WinWaitActive, Stopping IDeA ahk_class TIDeAStopScheduleDlg, , 10   ; wait for Stopping IDeA dialog, max 10 seconds
    ControlClick, OK, Stopping IDeA ahk_class TIDeAStopScheduleDlg   ; click OK
    WinActivate, Aquarium ahk_class TfmRPlayMain   ; activate main window
    GroupAdd, Start, Start IDeA
    Loop
    {
        ControlGet, x, Visible, , Start, Aquarium ahk_class TfmRPlayMain   ; check if Start IDeA is visible, i.e. minimax has finished
        if x > 0
            break   ; terminate the loop
    }
    Sleep, 5000   ; wait 5 seconds, just in case
    WinClose, Aquarium ahk_class TfmRPlayMain   ; close Aquarium
}
Parent - - By Checks Date 2017-09-13 22:10
Thank you very much nebulus! Really amazing, what a perfect solution. It works just fine!

What code do I need to add, if I want to shutdown my computer afterwards?

I also got a second use case:

I run infinite analysis.
After a given amount of time, I want to stop the engine and save the hash file.
Then wait 5 minutes to be sure that it is properly saved, close aquarium and shutdown the computer.
Parent - - By nebulus (****) [no] Date 2017-09-14 00:23 Edited 2017-09-14 00:44

> What code do I need to add, if I want to shutdown my computer afterwards?


Shutdown, 1

See Shutdown

> I run infinite analysis.
> After a given amount of time, I want to stop the engine and save the hash file.
> Then wait 5 minutes to be sure that it is properly saved, close aquarium and shutdown the computer.


So, you right-click in the status bar and select Save hash to file, similar to the image bellow, right?



That would be a bit more complicated since control has no name. You could use Click (you can get relative coordinates with Window Spy / Active Window Info that comes with Autohotkey), but then the script would be dependent on your resolution. You should also maximize the window before executing clicks.

BTW, what engine are you using?

EDIT: There's a project called Macro Creator that could come in handy. It generates AHK scripts. Just make sure you uncheck mouse moves in recording options, otherwise the script gets unnecessarily huge and more difficult to edit.
Parent - - By Checks Date 2017-09-14 21:44
Thanks, shutdown also works perfectly. I added another sleep 5000 before it, just to be sure.

The process for saving Hash is exactly as you described.

I use asmFish, so the relevant command is "TTSave".

I tried to create a script with your recommendation Macro Creator which works quite well.

Sleep, 5000
WinActivate, Aquarium ahk_class TfmRPlayMain
Click, 16, 723 Right, Down
Click, 16, 723 Right, Up
Send, {Up}
Send, {Up}
Send, {Up}
Send, {Enter}
Sleep, 300000    ; this is important to give enough time to save the hash
WinClose, Aquarium ahk_class TfmRPlayMain
Sleep, 5000
Shutdown, 1

Could you maybe add the code for stopping the engine, before saving hash?
Parent - By nebulus (****) [no] Date 2017-09-14 23:02
Since Esc stops infinite analysis (see keyboard shortcuts), the easiest would be to just send Esc (see SendInput).
For example:

WinActivate, Aquarium ahk_class TfmRPlayMain
SendInput {Esc}


Or:

if WinExist("ahk_exe Aquarium.exe")
{
    WinActivate
    SendInput {Esc}
}


The later will work if the window is minimized.
Up Topic Rybka Support & Discussion / Aquarium / Script to stop analysis/IDeA and exit Aquarium

Powered by mwForum 2.27.4 © 1999-2012 Markus Wichitill