I created a smooth volume up / down code for my language. It's the simplest solution.
First declare this:
Private Declare Sub keybdevent Lib "user32"( ByVal bVk As Byte , ByVal bScan As Byte , ByVal dwFlags As Integer , ByVal dwExtraInfo As Integer )
Then create a timer and set its interval to 100. Add the following code to it:
For i As Integer = 1 To 100
Call keybdevent(Keys.VolumeUp,0,0,0)
Next
This will gradually increase the volume of the system.
To decrease the volume, just replace Keys.VolumeUp with Keys.VolumeDown.
You can simulate any key like this.
Hope this helps !!
Originally Posted by FLAMESABER
I created a smooth volume up / down code for my language. It's the simplest solution.
First declare this:
Private Declare Sub keybdevent Lib "user32"( ByVal bVk As Byte , ByVal bScan As Byte , ByVal dwFlags As Integer , ByVal dwExtraInfo As Integer )
Then create a timer and set its interval to 100. Add the following code to it:
For i As Integer = 1 To 100
Call keybdevent(Keys.VolumeUp,0,0,0)
Next
This will gradually increase the volume of the system.
To decrease the volume, just replace Keys.VolumeUp with Keys.VolumeDown.
You can simulate any key like this.
Hope this helps !!
Had to change
Private Declare Sub keybdevent Lib "user32"( ByVal bVk As Byte , ByVal bScan As Byte , ByVal dwFlags As Integer , ByVal dwExtraInfo As Integer )
to:
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
and:
[html] For i As Integer = 1 To 100
Call keybd_event(Keys.VolumeUp, 0, 0, 0)
System.Threading.Thread.Sleep(40)
Next[/html]
/Solved
Originally Posted by hejsan
Had to change
Private Declare Sub keybdevent Lib "user32"( ByVal bVk As Byte , ByVal bScan As Byte , ByVal dwFlags As Integer , ByVal dwExtraInfo As Integer )
to:
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
and:
[html] For i As Integer = 1 To 100
Call keybd_event(Keys.VolumeUp, 0, 0, 0)
System.Threading.Thread.Sleep(40)
Next[/html]
/Solved
Oh shit..I used my custom VB.NET wrapper and it ignored the underscore. Sorry for that.
+ The effective way would be setting the interval of the timer to match ya needs. Timers work asynchronously so the application won't hang !!