Solution: Image occlusion fit to canvas automatically for Windows 10 (AutoHotKey needed)

To make the image you load from your clipboard in image occlusion you can make the image automatically fit to canvas (as long as you use a keyboard shortcut to open it, it is not enough to open the IO-window with your cursor.
Based on pressing the keyboard shortcut a mouse click in the middle-ish of the screen is initiated (with a 1-2 sec delay, depending on how fast or slow your loading time is, as it is not enough that the window opens, the image in the canvas has to fully load before the “Mouse click in center → f” for centering the canvas works.

I have ~^+O:: set to ~^E:: because I changed the Ctrl+Shift+O image occlusion shortcut in the add-on to Ctrl+E

Of course it would be better if there were an option for the add-on to do this automatically itself, but until then, this is an OK temporary solution.

#ifwinactive ahk_exe Anki.exe
~^E::
;You can increase/decrease this based on how fast your image occlusion window loads
winwait, Add ahk_exe anki.exe,, 0.4
if errorlevel
{
msgbox, window took too long to open 
return
}
;You can increase/decrease this delay based on how fast the image in the canvas loads
sleep, 2500

; ↓ You can edit the X_Pos / Y_Pos values ↓
WindowTitle := "Image Occlusion Enhanced - Add Mode"
;The title of the image occlusion window
                ;note: you can get this title with the Window Spy script/app which should come installed with AHK. 
                                
X_Pos := 800        ;The X position within the window you want to click
Y_Pos := 800        ;The Y position within the window you want to click

WinGet, WindowArray, List, %WindowTitle% 
;max 1 window with the given title
if !(WindowArray = 1)
{
    msgbox, % "More or less than one window found with the title: " WindowTitle "`Script will close now"
    exitapp
}
Window_UniqueID := WindowArray1
ControlClick, X%X_Pos% Y%Y_Pos%, ahk_id %Window_UniqueID%,,,, NA  

Text = f
Send %Text% 
return

Special thanks to ShambleS1980 on the AHK DIscord server. (and me, MedBooster :p)

Thanks for posting this, that’s a clever workaround! If you’re up for giving Anki 2.1.50 a try (not all add-ons are compatible yet, so beware), I just released v1.4.0 of IOE which should fix the auto-canvas-fitting: Image Occlusion Enhanced [Official Support Thread] - #53 by glutanimate

The fix is a bit hacky by necessity and I was only able to test it on a limited number of set-ups so far, so I would be interested to hear if it works for you.