示例#1
0
文件: Duiimage.cs 项目: qmgindi/Au
    //CONSIDER: add mouse xy like in Delm.
    //CONSIDER: add wnd Activate if pixels from screen.

    public Duiimage()
    {
        Title = "Find image or color in window";

        _noeventValueChanged = true;
        var b = new wpfBuilder(this).WinSize((410, 400..), (380, 330..)).Columns(160, -1);

        b.R.Add(out _info).Height(60);
        b.R.StartGrid().Columns(76, 76, 76, -1);
        //row 1
        b.R.AddButton("Capture", _bCapture_Click);
        b.AddButton(out _bTest, "Test", _Test).Disabled().Tooltip("Executes the code now (except wait/fail/mouse) and shows the found image");
        b.AddButton(out _bInsert, "Insert", _Insert).Disabled();
        b.Add(out _cbAction).Align("L").Width(140).Items("|MouseMove|MouseClick|MouseClickD|MouseClickR|PostClick|PostClickD|PostClickR|waitNot|new uiimageFinder").Select(2);
        //row 3
        b.R.AddButton("More ▾", _bEtc_Click).Align("L");
        b.StartStack();
        waitC = b.xAddCheckText("Wait", "1", check: true); b.Width(53);
        (waitnoC = b.xAddCheckText("Timeout", "5")).Visible = false; b.Width(53);
        b.xAddCheck(out exceptionC, "Fail if not found").Checked();
        b.xAddCheck(out exceptionnoC, "Fail on timeout").Checked().Hidden(null);
        b.End();
        b.End();
        //row 4
        b.R.AddButton("Window...", _bWnd_Click).And(-70).Add(out controlC, "Control").Disabled();
        b.xStartPropertyGrid();
        rectC    = b.xAddCheckText("Rectangle", "0, 0, ^0, ^0"); b.And(21).AddButton("...", _bRect_Click);
        wiflagsC = b.xAddCheckCombo("Window pixels", "WindowDC|PrintWindow");
        diffC    = b.xAddCheckText("Color diff", "10");
        skipC    = b.xAddCheckText("Skip");
        b.xAddCheck(out allC, "Get all", noR: true);
        b.xEndPropertyGrid(); b.SpanRows(2);

        b.Row(80).xAddInBorder(out _pict); b.Span(1);
        b.Row(-1).xAddInBorder(out _code);
        b.End();
        _noeventValueChanged = false;

        WndSavedRect.Restore(this, App.Settings.wndpos.uiimage, o => App.Settings.wndpos.uiimage = o);
    }
示例#2
0
文件: Dwnd.cs 项目: qmgindi/Au
    public Dwnd(wnd w = default, DwndFlags flags = 0, string title = "Find window")
    {
        _dontInsert   = flags.Has(DwndFlags.DontInsert);
        _noControl    = flags.Has(DwndFlags.NoControl);
        _checkControl = flags.Has(DwndFlags.CheckControl);
        _forTrigger   = flags.Has(DwndFlags.ForTrigger);

        Title = title;

        var b = new wpfBuilder(this).WinSize((500, 450..), (600, 430..)).Columns(-1);

        b.R.Add(out _info).Height(60);
        b.R.StartGrid().Columns(0, 76, 76, 0, 0, -1);
        _cCapture = b.xAddCheckIcon("*Unicons.Capture #FF4040", $"Enable capturing ({App.Settings.delm.hk_capture}) and show window/control rectangles");
        b.AddButton(out _bTest, "Test", _bTest_Click).Disabled().Tooltip("Executes the 'find' part of the code now and shows the rectangle");
        b.AddButton(out _bInsert, _dontInsert ? "OK" : "Insert", _Insert).Disabled(); if (!_dontInsert)
        {
            b.Tooltip("Insert code in editor");
        }
        b.Add(out _cbFunc).Items("find|findOrRun|runAndFind").Tooltip("Function").Width(90);         //rejected: |wndFinder. Rare, etc.
        _cbFunc.SelectionChanged += _cbFunc_SelectionChanged;
        b.Add(out _cActivate, "Activate").Tooltip("Activate the found window");
        b.Add(out _cException, "Fail if not found").Checked(!_forTrigger).Tooltip("Throw exception if not found");
        //cActivate.CheckChanged += (_, _) => { cException.Visibility = cActivate.IsChecked ? Visibility.Hidden : Visibility.Visible; }; //no, need for control too
        b.End();

        //window and control properties and search settings
        b.R.AddSeparator(false).Margin("B");
        b.Row(0);                                                   //auto height, else adds v scrollbar when textbox height changes when a textbox text is multiline or too long (with h scrollbar)
        _scroller            = b.xStartPropertyGrid("L2 T3 R2 B1"); //actually never shows scrollbar because of row auto height, but sets some options etc
        _scroller.Visibility = Visibility.Hidden;
        b.Columns(-3, 0, -1.2);
        //window
        b.R.Add <TextBlock>("Window").Margin("T1 B3").xSetHeaderProp();        //rejected: vertical headers. Tested, looks not good, too small for vertical Control checkbox.
        b.Row(0).StartGrid().Columns(70, -1);
        nameW     = b.xAddCheckText("name");
        classW    = b.xAddCheckText("class");
        programW  = b.xAddCheckTextDropdown("program");
        containsW = b.xAddCheckTextDropdown("contains");
        b.End();
        b.xAddSplitterV(span: 4, thickness: 12);
        b.StartGrid().Columns(44, -1);
        b.xAddCheck(out cHiddenTooW, "Find hidden too");
        b.xAddCheck(out cCloakedTooW, "Find cloaked too");
        alsoW = b.xAddCheckText("also", "o=>true");
        waitW = b.xAddCheckText("wait", "1", check: !_forTrigger);
        b.End();
        //control
        b.R.AddSeparator(false).Margin("T4 B0"); _sepControl = b.Last as Separator;
        b.R.Add(out _cControl, "Control").Margin("T5 B3").xSetHeaderProp();
        b.Row(0).StartGrid().Columns(70, -1); _gCon1 = b.Panel as Grid;
        nameC  = b.xAddCheckTextDropdown("name");
        classC = b.xAddCheckText("class");
        idC    = b.xAddCheckText("id");
        b.End().Skip();
        b.StartGrid().Columns(44, -1); _gCon2 = b.Panel as Grid;
        b.xAddCheck(out cHiddenTooC, "Find hidden too");
        alsoC = b.xAddCheckText("also", "o=>true");
        skipC = b.xAddCheckText("skip");
        b.End();
        b.xEndPropertyGrid();
        b.R.AddSeparator(false);

        if (_forTrigger)
        {
            _cActivate.Visibility  = Visibility.Hidden;
            _cException.Visibility = Visibility.Hidden;
            _cbFunc.Visibility     = Visibility.Hidden;
            waitW.Visible          = false;
        }

        //code
        b.Row(64).xAddInBorder(out _code, "B");

        //tree and window info
        b.xAddSplitterH(span: -1);
        b.Row(-1).StartGrid().Columns(-1, 0, -1);
        b.Row(-1).xAddInBorder(out _tree, "TR");
        b.xAddSplitterV();
        b.xAddInBorder(out _winInfo, "TL"); _winInfo.ZWrapLines = false; _winInfo.Name = "window_info";
        b.End();

        b.End();

        _InitTree();

        _con = w;

        b.WinProperties(
            topmost: true,
            showActivated: _dontInsert || w.Is0 ? null : false             //eg if captured a popup menu, activating this window closes the menu and we cannot get properties
            );

        WndSavedRect.Restore(this, App.Settings.wndpos.wnd, o => App.Settings.wndpos.wnd = o);
    }