- Apr 25, 2015
- 1,845
- 2
- 2,199
- 327
THIS METHOD REQUIRES EXPLORER.EXE ~~~ a non-explorer.exe solution is available in next post.
With Windows 10 systems and others, you have to hook into the Windows system using DLL/API fanciness. It's really not that fancy and honestly looks like total trash.
I will provide an incredibly simple solution to setting a system's volume to 100 with a timer.
This should be pretty simple to add to a project. While I am not most happy this adds an extra timer to a project --- shit happens!
!!!IMPORTANT!!!
The timer named Timer1 has an Interval set to 10 and I have changed Enabled to True!
Looking to set the system volume to 0 or mute? Simply replace that Call line with:
If anyone wants to test this application, simply extract the vbproj.zip and run WindowsApp8.vbproj with Visual Studio 2017. If you run the test application, simply press Ctrl + F1 and you will notice the volume should adjust to maximum or minimum.
..........
This also is a PITA because it requires EXPLORER.EXE
Okay, I am going to scream... basically it is appearing without explorer.exe running, you may not adjust the volume of the system. What... the... fuck?! Do I need to code this in assembly and make my own OS too?
Hmm... hmmm... hmmm... NOPE.
With Windows 10 systems and others, you have to hook into the Windows system using DLL/API fanciness. It's really not that fancy and honestly looks like total trash.
I will provide an incredibly simple solution to setting a system's volume to 100 with a timer.
Code:
Public Class Form1
Dim Volx As Int32
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Const KEYEVENTF_KEYUP As Long = &H2
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Call keybd_event(Keys.VolumeUp, 0, 0, 0)
Volx += 1
If Volx = 50 Then
Timer1.Enabled = False
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Volx = 0
End Sub
End Class
This should be pretty simple to add to a project. While I am not most happy this adds an extra timer to a project --- shit happens!
!!!IMPORTANT!!!
The timer named Timer1 has an Interval set to 10 and I have changed Enabled to True!
Looking to set the system volume to 0 or mute? Simply replace that Call line with:
Code:
Call keybd_event(Keys.VolumeDown, 0, 0, 0)
If anyone wants to test this application, simply extract the vbproj.zip and run WindowsApp8.vbproj with Visual Studio 2017. If you run the test application, simply press Ctrl + F1 and you will notice the volume should adjust to maximum or minimum.
..........
This also is a PITA because it requires EXPLORER.EXE
Code:
Imports System.Runtime.InteropServices
Public Class Form1
Private Const VolUp As Integer = &HA0000
Private Const VolDn As Integer = &H90000
Private Const MsgNo As Integer = &H319
Declare Function SendMessageW Lib "user32" (ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
Private Sub Form1_Load() Handles MyBase.Load
Button1.Text = "UP"
Button2.Text = "DOWN"
Button3.Text = "Close"
End Sub
Private Sub Button1_Click() Handles Button1.Click
SendMessageW(Me.Handle, MsgNo, Me.Handle, New IntPtr(VolUp))
End Sub
Private Sub Button2_Click() Handles Button2.Click
SendMessageW(Me.Handle, MsgNo, Me.Handle, New IntPtr(VolDn))
End Sub
Private Sub Button3_Click() Handles Button3.Click
End
End Sub
Okay, I am going to scream... basically it is appearing without explorer.exe running, you may not adjust the volume of the system. What... the... fuck?! Do I need to code this in assembly and make my own OS too?
Code:
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Form1
Private Const APPCOMMAND_VOLUME_MUTE As Integer = &H80000
Private Const APPCOMMAND_VOLUME_UP As Integer = &HA0000
Private Const APPCOMMAND_VOLUME_DOWN As Integer = &H90000
Private Const WM_APPCOMMAND As Integer = &H319
<DllImport("user32.dll")>
Public Shared Function SendMessageW(ByVal hWnd As IntPtr,
ByVal Msg As Integer, ByVal wParam As IntPtr,
ByVal lParam As IntPtr) As IntPtr
End Function
'mute SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE))
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_UP))
SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, New IntPtr(APPCOMMAND_VOLUME_MUTE))
End Sub
End Class
Hmm... hmmm... hmmm... NOPE.
Attachments
Last edited: