0

我的代码截取屏幕截图,当它识别出某些单词时,应该打开一个新表单,但它只打开并在主表单位于前面时被带到前面。我希望能够最小化表单,当它检测到一个单词时,我希望它将新表单带到屏幕的前面,或者能够将所有表单带到前面。我当前的代码如下

 public void OpenAutoNotes(string Word,string Text, string Note,string Name)
    {
        if (Find(Word, Text))
        {
            AutoNotes AddNote = new AutoNotes(Note, Name);
            AddNote.Show();
            AddNote.BringToFront();
            
        }
    }

Find() 函数完美运行,它打开表单,但表单保持最小化或在当前窗口后面

我调用要打开的表单的方式是使用计时器,并且计时器的每个滴答声都会运行 OpenAutoNotes() 函数来检查是否找到了单词。这是其余的相关代码

public void InitTimer()
    {
        timer = new Timer();
        timer.Tick += new EventHandler(timer_Tick);
        timer.Interval = 3000;
        timer.Start();
    }
    private void timer_Tick(object sender, EventArgs e)
    {
        if (SwitchScan == true)
        {
            SearchKeyWords();
        }
    }
    public void SearchKeyWords()
    {
        Bitmap CurrentImage = SelectImageCapture(499, 499, 540, 200, 0, 0);
        pictureBox1.Image = CurrentImage;
        string MessageText = ImageToText(CurrentImage);
        
        OpenAutoNotes("car", MessageText, "Needs car rented", "TestforText");
        OpenAutoNotes("Car", MessageText, "Needs car rented", "TestforText");
        OpenAutoNotes("cot", MessageText, "Needs a cot", "TestforText");
        OpenAutoNotes("Cot", MessageText, "Needs a cot", "TestforText");
       
    }
4

1 回答 1

0

真正简单的改变,希望这可以帮助其他人,因为我在这里找不到类似问题的任何东西

if (Find(Word, Text))
        {
            AutoNotes AddNote = new AutoNotes(Note, Name);
            AddNote.TopMost = true;
            AddNote.Show();
            
            
            
        }
于 2021-01-29T22:55:11.007 回答