Ok I made a Windows Applications that makes the computer beep at a certain frequency when you press a letter key. Problem is, it doesn't do anything when it i out of focus. How do I make it continue to beep whether it is in focus or not. Here is the code: - Public Class Form1
-
-
Private Sub e_KeyDown(ByVal sender As Object, _
-
ByVal e As KeyEventArgs)
-
' If the 'E' key is pressed,
-
'plays 500 hertz sound for 50 milliseconds
-
If e.KeyCode = Keys.E Then
-
Console.Beep(500, 50)
-
End If
-
End Sub
-
-
-
Private Sub a_KeyDown(ByVal sender As Object, _
-
ByVal a As KeyEventArgs) Handles Button1.KeyDown
-
-
If a.KeyCode = Keys.A Then
-
Console.Beep(650, 50)
-
End If
-
End Sub
-
-
-
Private Sub b_KeyDown(ByVal sender As Object, _
-
ByVal b As KeyEventArgs) Handles Button1.KeyDown
-
-
If b.KeyCode = Keys.B Then
-
Console.Beep(200, 50)
-
End If
-
End Sub
-
-
Private Sub c_KeyDown(ByVal sender As Object, _
-
ByVal c As KeyEventArgs) Handles Button1.KeyDown
-
-
If c.KeyCode = Keys.C Then
-
Console.Beep(5020, 50)
-
End If
-
End Sub
-
-
Private Sub d_KeyDown(ByVal sender As Object, _
-
ByVal d As KeyEventArgs) Handles Button1.KeyDown
-
-
If d.KeyCode = Keys.D Then
-
Console.Beep(720, 50)
-
End If
-
End Sub
-
-
-
Private Sub f_KeyDown(ByVal sender As Object, _
-
ByVal f As KeyEventArgs) Handles Button1.KeyDown
-
-
If f.KeyCode = Keys.F Then
-
Console.Beep(1000, 50)
-
End If
-
End Sub
-
-
Private Sub g_KeyDown(ByVal sender As Object, _
-
ByVal g As KeyEventArgs) Handles Button1.KeyDown
-
-
If g.KeyCode = Keys.G Then
-
Console.Beep(1280, 50)
-
End If
-
End Sub
-
-
Private Sub h_KeyDown(ByVal sender As Object, _
-
ByVal h As KeyEventArgs) Handles Button1.KeyDown
-
-
If h.KeyCode = Keys.H Then
-
Console.Beep(1120, 50)
-
End If
-
End Sub
-
-
Private Sub i_KeyDown(ByVal sender As Object, _
-
ByVal i As KeyEventArgs) Handles Button1.KeyDown
-
-
If i.KeyCode = Keys.I Then
-
Console.Beep(705, 50)
-
End If
-
End Sub
-
-
Private Sub j_KeyDown(ByVal sender As Object, _
-
ByVal j As KeyEventArgs) Handles Button1.KeyDown
-
-
If j.KeyCode = Keys.J Then
-
Console.Beep(70, 50)
-
End If
-
End Sub
-
-
Private Sub k_KeyDown(ByVal sender As Object, _
-
ByVal k As KeyEventArgs) Handles Button1.KeyDown
-
-
If k.KeyCode = Keys.K Then
-
Console.Beep(701, 50)
-
End If
-
End Sub
-
-
Private Sub l_KeyDown(ByVal sender As Object, _
-
ByVal l As KeyEventArgs) Handles Button1.KeyDown
-
-
If l.KeyCode = Keys.L Then
-
Console.Beep(7095, 50)
-
End If
-
End Sub
-
-
Private Sub m_KeyDown(ByVal sender As Object, _
-
ByVal m As KeyEventArgs) Handles Button1.KeyDown
-
-
If m.KeyCode = Keys.M Then
-
Console.Beep(848, 50)
-
End If
-
End Sub
-
-
Private Sub n_KeyDown(ByVal sender As Object, _
-
ByVal n As KeyEventArgs) Handles Button1.KeyDown
-
-
If n.KeyCode = Keys.N Then
-
Console.Beep(605, 50)
-
End If
-
End Sub
-
-
Private Sub o_KeyDown(ByVal sender As Object, _
-
ByVal o As KeyEventArgs) Handles Button1.KeyDown
-
-
If o.KeyCode = Keys.O Then
-
Console.Beep(712, 50)
-
End If
-
End Sub
-
-
Private Sub p_KeyDown(ByVal sender As Object, _
-
ByVal p As KeyEventArgs) Handles Button1.KeyDown
-
-
If p.KeyCode = Keys.P Then
-
Console.Beep(2152, 50)
-
End If
-
End Sub
-
-
Private Sub q_KeyDown(ByVal sender As Object, _
-
ByVal r As KeyEventArgs) Handles Button1.KeyDown
-
-
If r.KeyCode = Keys.R Then
-
Console.Beep(2012, 50)
-
End If
-
End Sub
-
-
Private Sub r_KeyDown(ByVal sender As Object, _
-
ByVal r As KeyEventArgs) Handles Button1.KeyDown
-
-
If r.KeyCode = Keys.R Then
-
Console.Beep(201, 50)
-
End If
-
End Sub
-
-
Private Sub s_KeyDown(ByVal sender As Object, _
-
ByVal s As KeyEventArgs) Handles Button1.KeyDown
-
-
If s.KeyCode = Keys.S Then
-
Console.Beep(101, 50)
-
End If
-
End Sub
-
-
Private Sub t_KeyDown(ByVal sender As Object, _
-
ByVal t As KeyEventArgs) Handles Button1.KeyDown
-
-
If t.KeyCode = Keys.T Then
-
Console.Beep(7052, 50)
-
End If
-
End Sub
-
-
Private Sub u_KeyDown(ByVal sender As Object, _
-
ByVal u As KeyEventArgs) Handles Button1.KeyDown
-
-
If u.KeyCode = Keys.U Then
-
Console.Beep(512, 50)
-
End If
-
End Sub
-
-
Private Sub v_KeyDown(ByVal sender As Object, _
-
ByVal v As KeyEventArgs) Handles Button1.KeyDown
-
-
If v.KeyCode = Keys.V Then
-
Console.Beep(2502, 50)
-
End If
-
End Sub
-
-
Private Sub w_KeyDown(ByVal sender As Object, _
-
ByVal w As KeyEventArgs) Handles Button1.KeyDown
-
-
If w.KeyCode = Keys.W Then
-
Console.Beep(725, 50)
-
End If
-
End Sub
-
-
Private Sub x_KeyDown(ByVal sender As Object, _
-
ByVal x As KeyEventArgs) Handles Button1.KeyDown
-
-
If x.KeyCode = Keys.X Then
-
Console.Beep(1520, 50)
-
End If
-
End Sub
-
-
Private Sub y_KeyDown(ByVal sender As Object, _
-
ByVal y As KeyEventArgs) Handles Button1.KeyDown
-
-
If y.KeyCode = Keys.Y Then
-
Console.Beep(1705, 50)
-
End If
-
End Sub
-
-
Private Sub z_KeyDown(ByVal sender As Object, _
-
ByVal z As KeyEventArgs) Handles Button1.KeyDown
-
-
If z.KeyCode = Keys.Z Then
-
Console.Beep(711, 50)
-
End If
-
End Sub
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-
End Sub
-
End Class
Any ideas? I've heard you need to tell it to continue even when not in focus. How do I do this? This is for a harmless prank, but nothing dangerous.
1 1329
Hi,
You dont have to write so many Sub Procedures for each Key..
First make Form's property KeyPreview=True,
and in Form's Key Down or Key press, Use a Select Case to Find out the Key, and Fire the beep..
If done for Form, it will automatically fire for all the control's key press...
Regards
Veena
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alan Walkington |
last post by:
Folks:
How can I get an /exec'ed/ process to run in the background on an XP box?
I have a monitor-like process which I am starting as
'exec("something.exe");' and, of course the exec function...
|
by: Greg Bryant |
last post by:
I'm doing some work for a company that has an auction site running in
coldfusion. They're not real happy with it, and it needs a major overhaul,
so I'm looking at redoing it, and while I'm at it,...
|
by: pokémon |
last post by:
Ok, I want to implmement a "backgound process", but the catch is this:
I want to control it via a Web Service, that is to say, the Web Service will
be its API.
What type of application should...
|
by: Marian Dvorsky |
last post by:
I would like to create an application that will be running in the background
and will have an icon in the Notify bar in the lower-right corner of Windows
desktop. For Windows NT+ I will probably...
|
by: Ganesh |
last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a
process without have access to the process code.
regards
Ganesh
|
by: Ed |
last post by:
Is there a way to run an application in the background other than through a
service.
As I understand it when creating a service it is best practice not have any
kind of user interface. My...
|
by: Mrinal Kamboj |
last post by:
Hi ,
Doubt may be bit trivial , but i wanted to know , what are the exact
benefits derived while we run a background process as an NT service in
windows , we can as well achieve the...
|
by: David Lozzi |
last post by:
Howdy,
I wrote a web service in .Net for my customer. My customer has another
vendor who now has to consume it but they are not using Visual Studio. Most
of their pages are jsp, and they said...
|
by: giloosh99 |
last post by:
Exec, shell_exec, system, popen functions all run the process in the
background.
how can i get it to run the process normally.
my code looks like this:
<?
exec("batch_file.bat");
?>
am i...
|
by: Reddy |
last post by:
I am running process.sart to run gpg.exe to encrypt files. It's working fine
with console application. When i use same code in windows service. It's not
working. It's not even throwing...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |