SW_HIDE问题对于Chrome没有用

时间:2014-03-19 17:53:38

标签: vb.net visual-studio-2010

我尝试了很多工作,但是没有机会。

我想在chrome中运行一个链接示例:www.yahoo.com但是在隐藏模式下使用sw_hide一段时间这是我的代码:

Imports System.IO

Imports Microsoft.Win32

Imports System.Runtime.InteropServices

Imports System.Diagnostics

Imports System.Threading

Module Module1

Const SW_HIDE As Integer = 0
Const SW_RESTORE As Integer = 9
Const SW_MINIMIZE As Integer = 6
Const SW_SHOWMINIMIZED As Integer = 2
Dim hWnd As Integer = 0
 <DllImport("User32")> Private Function ShowWindow(ByVal hwnd As Integer, ByVal       nCmdShow   As Integer) As Integer
End Function

Sub main()
    Threading.Thread.Sleep(3000)
    Dim ProcessProperties As New ProcessStartInfo
    ProcessProperties.FileName = "chrome"
    ProcessProperties.Arguments = "www.yahoo.com"
    Dim myProcess As Process = Process.Start(ProcessProperties)
    Threading.Thread.Sleep(5000)
    Call Chm()
    Threading.Thread.Sleep(10000)
    Call shwo()
    Threading.Thread.Sleep(1000)
End Sub
Sub Chm()
    Dim p As Process() = Process.GetProcessesByName("chrome")
    hWnd = p(0).MainWindowHandle.ToInt32
    Threading.Thread.Sleep(2000)
    ShowWindow(hWnd, SW_HIDE)
End Sub
Sub shwo()
    If Not hWnd.Equals(IntPtr.Zero) Then
        ' is app window found?
        ShowWindow(hWnd, SW_SHOWMINIMIZED)
    End If
End Sub
End Module

0 个答案:

没有答案