Click here to Skip to main content
15,893,790 members
Articles / Mobile Apps

Own your phone - Taking back control of your mobile phone

Rate me:
Please Sign up or sign in to vote.
4.85/5 (15 votes)
2 Jan 2009CPOL8 min read 47.5K   415   56  
We'll build a call management application for Windows Mobile 5.x/6.x which can programatically ignore, send to voicemail, or SMS-respond to unwanted calls.
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports Microsoft.WindowsMobile
Imports Microsoft.WindowsMobile.Status
Imports Microsoft.WindowsMobile.PocketOutlook
Imports System.Runtime.InteropServices
Public Class Form1
    Private StateNotificationList As New ArrayList()
    Const KEYEVENTF_KEYUP = &H2
    Const KEYEVENTF_KEYDOWN = &H0
    <DllImport("coredll.dll", CharSet:=Runtime.InteropServices.CharSet.Unicode)> _
              Private Shared Sub keybd_event(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
    End Sub
    Public Shared Sub BounceCall()
        keybd_event(115, 0, KEYEVENTF_KEYDOWN, 0)
        keybd_event(115, 0, KEYEVENTF_KEYUP, 0)
    End Sub
    Private Sub ChangeOccurred(ByVal sender As Object, ByVal args As ChangeEventArgs)
        If SystemState.PhoneIncomingCall = True And chkIgnoreAllCalls.Checked = True Then
            BounceCall()
        End If
        If SystemState.PhoneIncomingCall = True And SystemState.PhoneIncomingCallerNumber = txtIgnoreThisNumber.Text Then
            BounceCall()
        End If
    End Sub
    Private Sub MonitorNotifications()
        Dim s As SystemState
        s = New SystemState(SystemProperty.PhoneIncomingCall)
        AddHandler s.Changed, AddressOf ChangeOccurred
        StateNotificationList.Add(s)
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MonitorNotifications()
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
BrainThump is my outlet for "fun projects" outside of what I do for a living. It started in 2004 when I first developed a .NET Compact Framework application for a U.S. Navy customer and I decided I really liked it so started doing it for fun after work.

By day I work as a software engineer for a defense/government contractor developing solutions for customers like the U.S. Navy and the FAA. By night I like to develop software for Windows Mobile devices.

I'm also heavily involved with the .NET/Geek community. I love Code Camps, user groups, and the interaction with the whole community. For my efforts in supporting the community I've been recognized as a Microsoft MVP(Device Application Development), an INETA Community Champion, and inducted to the Community-Credit.com Hall of Fame.

Comments and Discussions