WinGetPos relies on missing assembly - System.Drawing.Primitives.

Issue #25 closed
Winter Laite created an issue

Test code (differs quite a bit from AHK):

if (WinExist("Untitled - Notepad"))
{
    sop := WinGetPos() ; Use the window found by WinExist.
    MsgBox("Notepad is at " sop["X"] "," sop["Y"])
}

The error thrown is:

The following errors occurred:ws_ks.ahk:: (142,9)-(142,18) - The type 'Rectangle' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Comments (5)

  1. Winter Laite reporter

    I just guessed at the parameters object, I thought “X”, “Y”, “Width”, “Height” would probably be correct for the object, but even if it is just “X” and “Y” I figured it would work.

    (I also tried adding a reference to System.Drawing.Primitives in VS 2022, but all I did was destroy the project.)

  2. Winter Laite reporter

    Tested fix of August 18, 2022 with this code:

    if (WinExist("Untitled - Notepad"))
    {
        sop := WinGetPos() ; Use the window found by WinExist.
        MsgBox("Notepad is at X: " sop["X"] ", Y: " sop["Y"] "`n Width: " sop["Width"] ", Height " sop["Height"])
    }
    

    Works. Please mark resolved and close. Thanks!

  3. Log in to comment