VB.NET如何弹出游戏安全通知?

时间:2014-12-16 22:02:52

标签: vb.net notifications toast

我如何在VB.NET中在屏幕上显示通知,例如这将是“游戏安全的”。

例如:“只剩下30分钟,直到你将被退出!”。

通知不应该从游戏中获得焦点(例如“窃取输入”),通知应该只显示5-10秒,然后自行消失。

在谈论反热时,通知也应该是安全的,如Punkbuster,VAC等。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我不知道“游戏安全”,因为我不知道那些游戏正在寻找什么来触发警报。

您可以做的是覆盖ShowWithoutActivation()并返回true,以便您的表单在显示时不会获得焦点。此外,您可以设置WS_EX_TRANSPARENT扩展窗口样式,以便所有鼠标消息直接通过您的表单。下面的应用程序甚至不知道您的表单是否存在。最后,设置不透明度,以便您可以部分地看到它。哦......计时器在十秒钟后关闭它:

Public Class frmNotification

    Private WithEvents Tmr As New System.Windows.Forms.Timer

    Private Sub frmNotification_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Opacity = 0.5 ' Make it so you can see thru it partially

        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None

        ' make it appear in the bottom right of the screen
        Me.StartPosition = FormStartPosition.Manual
        Dim rc As Rectangle = Screen.GetWorkingArea(Me)
        Me.Location = New Point(rc.Right - Me.Width, rc.Bottom - Me.Height)

        Tmr.Interval = TimeSpan.FromSeconds(10).TotalMilliseconds
        Tmr.Start()
    End Sub

    Private Const WS_EX_TRANSPARENT As Integer = &H20

    ' Make all mouse events PASS RIGHT THRU IT:
    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
            Return cp
        End Get
    End Property

    ' Show it without activating it:
    Protected Overrides ReadOnly Property ShowWithoutActivation() As Boolean
        Get
            Return True
        End Get
    End Property


    Private Sub Tmr_Tick(sender As Object, e As EventArgs) Handles Tmr.Tick
        Me.Close()
    End Sub

End Class