With the code below, I can click-through but I have to click on the form at the same time because I want a transparent form to click behind but I have to put a song when I click every time.
This is the code
Imports System.Runtime.InteropServices
Public Class GhostForm
Private InitialStyle As Integer
Private PercentVisible As Decimal
Public Property WS_EX_TRANSPARENT As Integer
Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As System.IntPtr, ByVal nIndex As Integer) As Integer
Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As System.IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal crKey As Integer, ByVal alpha As Byte, ByVal dwFlags As Integer) As Boolean
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitialStyle = GetWindowLong(Me.Handle, -20)
PercentVisible = 0.5
SetWindowLong(Me.Handle, -20, InitialStyle Or &H80000 Or &H20)
SetLayeredWindowAttributes(Me.Handle, 0, 255 * PercentVisible, &H2)
Me.TopMost = True
End Sub
Public Sub ClickHandler(sender As Object, e As MouseEventArgs) Handles Me.MouseClick, Label1.MouseClick, Button1.MouseClick
Label1.Text = String.Format("Clicked ""{0}"" with the {1} mouse button.", sender.name, e.Button.ToString.ToLower)
Select Case e.Button
Case MouseButtons.Left
Label1.Text = "Left"
Case MouseButtons.Right
Label1.Text = "Right"
Case MouseButtons.Middle
Label1.Text = "Middle"
Case Else
Label1.Text = "Some other button"
End Select
End Sub
Private Sub GhostForm_Click(sender As Object, e As EventArgs) Handles Me.Click
Console.Beep()
Dim sp As New System.Media.SoundPlayer("C:\WINDOWS\MEDIA\Ding.wav")
sp.Play()
sp.Dispose()
End Sub
End Class
How can I have a song when a click-through the form?
So I rephrase my question. I have touch screens and the supported drivers don't give me the "beep" option so I want to develop a small app that will allow to hear a beep every time the customer touches the touch screen. to do this I have to create a transparent form that will allow me to click on what is behind the form. What this code does perfectly, however, it does not support my click function because the click passes through it. so the question is: How can I get audio output when I click through the form?