最小化除我的应用程序之外的所有其他应用

时间:2015-08-24 12:38:35

标签: vb.net windows window

我想尽量减少除我自己以外的所有应用程序,但是使用下面的代码,我的应用程序不再显示。

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LWIN = &H5B


Sub minimizeAllOthers()
Me.WindowState=WindowState.Minimized
keybd_event(VK_LWIN, 0, 0, 0)
keybd_event(77, 0, 0, 0)
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)

While Me.WindowState=WindowState.Minimized
Me.WindowState=WindowState.Normal
Me.windowstate=WindowState.Maximized
Threading.Thread.Sleep(400)
End Sub

2 个答案:

答案 0 :(得分:1)

要检测表单何时被最小化,here's是一个很好的解决方案(请阅读"在&#34之后做出"解决方案的一部分)。

所以这是一个有效的代码:

Dim Minimizing As Boolean = False
Dim Normalizing As Boolean = False

Sub minimizeAllOthers()
    Minimizing = True
    keybd_event(VK_LWIN, 0, 0, 0)
    keybd_event(77, 0, 0, 0)
    keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    minimizeAllOthers()
End Sub

Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
    If Minimizing AndAlso Me.WindowState = FormWindowState.Minimized Then
        Me.WindowState = FormWindowState.Normal
        If Normalizing Then
            Minimizing = False
        End If
        If Normalizing Then Normalizing = False Else Normalizing = True
    End If
End Sub

我希望它能帮助我,并且我已经正确地理解了你的问题...

答案 1 :(得分:0)

您可以尝试这个^ _ ^

protected $table = '';
protected $req = '';
protected $post = false;


public function postHandler(Request $req, $table=''){
    try {
        $table = strtolower(e($table));
        $this->table = $table;
        $this->req = $req;
        $this->post = $req->isMethod('post') ? true : false;
        $methods = [
            "users" => function(){ return $this->users(); },
            "mailtemplates" => function(){ return $this->mailtemplates(); },
            "countries" => function(){ return $this->countries(); },
            "pages" => function(){ return $this->pages(); },
            "blocks" => function(){ return $this->blocks(); },
            "pagecategories" => function(){ return $this->pagecategories(); },
            "avatar" => function(){ return $this->avatar(); },
            "access" => function(){ return $this->access(); },
            "moduletypes" => function(){ return $this->moduletypes(); },
            "roles" => function(){ return $this->roles(); },
            "test" => function(){ return $this->test(); }
        ];
        if(array_key_exists($this->table, $methods)) return $methods[$this->table]();
        else $this->warn($this->msg['notInRequest']);
    } catch (\Throwable $th) {
        return $this->error($th->getMessage());
    } 
}