Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

VS 2010 Problem with my Skype tool (Mute button to mute skype).

$
0
0
Hi everyone.

I created a tool to register a hotkey (My keyboard's mute button) so when I press it, it will mute the sound (By default it does it) but also
mute my skype, so I created this (Full project's code):

Code:

Imports System.Runtime.InteropServices
Imports SKYPE4COMLib

Public Class Form1

    Public Const WM_HOTKEY As Integer = &H312
    Dim isMuted As Boolean = True
    Dim WithEvents oSkype As SKYPE4COMLib.Skype = New SKYPE4COMLib.Skype

    <DllImport("User32.dll")> _
    Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
    End Function

    <DllImport("User32.dll")> _
    Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RegisterHotKey(Me.Handle, 100, 0, Keys.VolumeMute)
        Try
            oSkype.Attach(8, True)
        Catch ex As Exception
            MsgBox("Can't attach to skype (not online).")
        End Try
    End Sub

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_HOTKEY Then
            Dim id As IntPtr = m.WParam
            Select Case (id.ToString)
                Case "100"
                    oSkype.Mute = isMuted
                    'MsgBox(isMuted)
            End Select
        End If
        MyBase.WndProc(m)
    End Sub

    Private Sub oSkype_Mute(ByVal Status As Boolean) Handles oSkype.Mute
        isMuted = Status
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        UnregisterHotKey(Me.Handle, 100)
        UnregisterHotKey(Me.Handle, 200)
    End Sub
End Class

I'm facing 2 problems now.
  • Because I'm using the mute button, it does not mute the sound anymore. Is there a way to fix it so both hotkeys will respond (Will mute skype AND mute sound).
  • For some reason, when I first press the mute button to test it, it does mute the microphone but the second time it doesn't unmute. The "isMuted" value stays true even though it should change (Look at the code).

Thanks for the help.

Viewing all articles
Browse latest Browse all 27201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>