Search code examples
vb.netcircuit

How to handle and event from pushing a physical button?


Hello I am creating an application on vb.net which I want to launch an event whenever someone rings the doorbell. Can someone show me where I need to start looking? I know I need a circuit, but it should be very simple since I only want to push a button. Thanks


Solution

  • An interesting hardware question. My solution here without additional hardware/circuit.

    • Install Microsoft Speech SDK.
    • Configure your MIC to listen to your doorbell.
    • In your code, on distinguishing the doorbell, invoke a button click in your screen. See below code to invoke a button:

      'Imports System.Windows.Automation.Peers
      'Imports System.Windows.Automation.Provider
      If SpeechObject(DetectDoorBellRing) = True Then
          Dim peer As New ButtonAutomationPeer(btnExecute)
          Dim invokeProv As IInvokeProvider = TryCast(peer.GetPattern(PatternInterface.Invoke), IInvokeProvider)
          invokeProv.Invoke()
      End If