Question

Windows Mobile C# Help

Asked by: ambush276

ok ive asked a few questions now but this is towards the end of my journey... Thanks for everyone that has helped.. truly i could have not done this without the community support:

ok basically when i compile the code below im getting 2 errors

1. Invalid Token Class ':' in class struct interface member declaration (line 70)

2. invalid token '('  in class struct interface memeber in line 72

ok now my part 2 of the question...


basically i want those 2 if commands at hte begining to run, if it comes up true i want it to then go down to the next setup (incoming:) goto place i setup...

then i want those 2 if commands to run...

if true then bam (and cycle that for 100 times to check if true)

if after 100 times still not true go to false, popup message and exit applicaiton?

is this setup correctly for that.. also for those errors thanks!

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.Status;
using System.Runtime.InteropServices;
 
 
namespace celldialer3
{
 
    public partial class CellDialer3 : Form
    {
        Microsoft.WindowsMobile.Telephony.Phone p;
        SystemState _PhoneCallTalking; // declare it here, so it won't fall out of scope
        SystemState _PhoneIncomingCall;
        const int KEYEVENTF_KEYUP = 0x2;
        const int KEYEVENTF_KEYDOWN = 0x0;
        const int KEYEVENTFF_KEYUP = 0x1;
 
        [DllImport("coredll.dll")]
        public static extern void keybd_event(Keys bVk, byte bScan, int dwFlags, int dwExtraInfo);
 
        public CellDialer3()
        {
            InitializeComponent();
            p = new Microsoft.WindowsMobile.Telephony.Phone();
            p.Talk("9497433374");
            InitializeComponent();
            _PhoneCallTalking = new SystemState(SystemProperty.PhoneCallTalking);
            _PhoneCallTalking.Changed += new ChangeEventHandler(_PhoneCallTalking_Changed);
            _PhoneIncomingCall = new SystemState(SystemProperty.PhoneIncomingCall);
            _PhoneIncomingCall.Changed += new ChangeEventHandler(_PhoneIncomingCall_Changed);
 
        }
        void _PhoneCallTalking_Changed(object sender, ChangeEventArgs args)
        {
            for (int i = 0; i <= 8; i++) 
            {
 
                if (SystemState.PhoneCallTalking == true)
                {
 
 
                    //F4 = red buton (hangup)
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
                    System.Threading.Thread.Sleep(1000);
                    goto Incoming;
                    
                }
                
                if (SystemState.PhoneCallTalking == false)
                {
                    MessageBox.Show("TESTING123XX1");
                    System.Threading.Thread.Sleep(2000);
                     Application.Exit();
                        
                }
 
            }
 
 
        }
Incoming: continue;
 
        System.Threading.Thread.Sleep(4000);
 
        void _PhoneIncomingCall_Changed(object sender, ChangeEventArgs args)
        {
         for (int i = 0; i <= 8; i++) 
         {
             if (SystemState.PhoneIncomingCall == true)
             {
              keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
              keybd_event(Keys.F4, 0, KEYEVENTFF_KEYUP, 0);
             System.Threading.Thread.Sleep(500);
                 Application.Exit();
             }
             { 
             if (SystemState.PhoneIncomingCall == false)
 
                 MessageBox.Show (" Could Not Recieve Server Connection");
             Application.Exit();
 
         }
         }
        }
    
    }
}

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-03 at 14:18:02ID24782869
Tags

c#

,

visual c#

,

windows mobile

Topics

Windows MobileProgramming

,

C# Programming Language

,

Microsoft Visual C#.Net

Participating Experts
2
Points
500
Comments
35

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Struct to Class
    Hey--- First i want to say this isnt for school or anything that is being graded, it has been graded already, i want this for my own educational purpose. i made a program that uses struct...it was supposed to been in classes and i never learned it yet. i am posting the ent...
  2. struct
    Hi, I saw code like this: struct CFoo:public CGoo { .... } Is there difference if was "class" and what?
  3. struct in C++ ......
    To C++ Expert, I got a code as follows : ------------------ struct A{ A(A* a_ptr){ cout << "woof" << endl;} } ; A* A(A* a_ptr){ cout <<"meow" << endl ;} struct A* a1=A(0) ; //line 1 struct A* a2 = new struct A(0) ; //li...
  4. Struct?
    struct header { int name; int address; } I was wondering is it possible to print the variable name on the struct? say for example in here print the name and the address? (NOT the value) but the variable name? without looking the header files?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: cookrePosted on 2009-10-03 at 16:43:43ID: 25487559

       }    <---- marks the end of the method


these are not in a method
Incoming:
continue;
 
        System.Threading.Thread.Sleep(4000);

 

by: ambush276Posted on 2009-10-03 at 17:14:43ID: 25487627

ok where should i put them for what i want to do?

 

by: ambush276Posted on 2009-10-03 at 20:41:12ID: 25488054

i tried to update the code a bit now i get an error

"no such label testER within the scope of the goto statement

i also get this label has not been refrenced)?

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.Status;
using System.Runtime.InteropServices;
 
 
namespace celldialer3
{
 
    public partial class CallKab : Form
    {
        Microsoft.WindowsMobile.Telephony.Phone p;
        SystemState _PhoneCallTalking; // declare it here, so it won't fall out of scope
        SystemState _PhoneIncomingCall;
        const int KEYEVENTF_KEYUP = 0x2;
        const int KEYEVENTF_KEYDOWN = 0x0;
        const int KEYEVENTFF_KEYUP = 0x1;
 
        [DllImport("coredll.dll")]
        public static extern void keybd_event(Keys bVk, byte bScan, int dwFlags, int dwExtraInfo);
 
        public CallKab()
        {
            InitializeComponent();
            p = new Microsoft.WindowsMobile.Telephony.Phone();
            p.Talk("9497433374");
            InitializeComponent();
            _PhoneCallTalking = new SystemState(SystemProperty.PhoneCallTalking);
            _PhoneCallTalking.Changed += new ChangeEventHandler(_PhoneCallTalking_Changed);
            _PhoneIncomingCall = new SystemState(SystemProperty.PhoneIncomingCall);
            _PhoneIncomingCall.Changed += new ChangeEventHandler(_PhoneIncomingCall_Changed);
 
        }
        void _PhoneCallTalking_Changed(object sender, ChangeEventArgs args)
        {
            for (int i = 0; i <= 8; i++) 
            {
 
                if (SystemState.PhoneCallTalking == true)
                {
 
 
                    //F4 = red buton (hangup)
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
                    System.Threading.Thread.Sleep(1000);
                    goto testER;
                    
                }
                
                if (SystemState.PhoneCallTalking == false)
                {
                    MessageBox.Show("TESTING123XX1");
                    System.Threading.Thread.Sleep(2000);
                     Application.Exit();
                        
                }
 
            }
 
 
        }
    
        
    
 
        void _PhoneIncomingCall_Changed(object sender, ChangeEventArgs args)
        {
           
testER:
        System.Threading.Thread.Sleep(4000);
        
            for (int i = 0; i <= 20; i++) 
         {
             if (SystemState.PhoneIncomingCall == true)
             {
              keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
              keybd_event(Keys.F4, 0, KEYEVENTFF_KEYUP, 0);
             System.Threading.Thread.Sleep(500);
                 Application.Exit();
             }
             { 
             if (SystemState.PhoneIncomingCall == false)
 
                 MessageBox.Show (" Could Not Recieve Server Connection");
             Application.Exit();
 
         }
         }
        }
    
    }
}
 
 
 
 
   
 
            
     
 
    
 
        
        
 
    
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:

Select allOpen in new window

 

by: alexey_gusevPosted on 2009-10-03 at 23:31:19ID: 25488333

you can reference labels only within the function, not between them

if you need to jump to that place then simply call _PhoneIncomingCall_Changed() at "goto" line.

in general, it should go to _PhoneIncomingCall_Changed() by itself since you're cancelling the call and therefore the system property (PhoneIncomingCall) should also change and fire the notification.

 

by: ambush276Posted on 2009-10-04 at 06:59:23ID: 25489205

so you are saying i dont even need the goto lines? it will automaticall skip to the next step if true?

 

by: ambush276Posted on 2009-10-04 at 07:09:33ID: 25489231

the other issue i am having is that the program will go to the second if statement automatically

so for example when the if phonecaltalking = true it works fine and connects / deconnects the call, but once hte call is disconnected it goes straight to the if phonecalltalking= false and brings up themessage...

first off, if the first if worked iw ant that to skip over that if statement go and straight to the next line of code...

second... whenever the text pops up either in phonecalltalking=false

or phoneincomingcal=false it will never go away. So if i press ok the on the text box it just stays there and does not exit the text box, so the application never exits...

one last thing (sorry for being nosy)...

in the if phoneincomingcall=true its not pressing down on the Yes or green button. Iits just staying put not answering the incomign call..

i have some cprog.exe questions but i will ask in anotehr post... thanks for al who are answering!

 

by: ambush276Posted on 2009-10-04 at 08:51:43ID: 25489548

it seems right now it automatically goes to the second (the 3 n 4th) if statements when for example if the second one (phonecalltalking=false) then the app should exit


also if the phonecalltalking = true, then it closes the phone... but then since the phone is closed it reads phonecalltalking=false.. i dont want it to do that, only read the false if the true is not satisfied, once the true is satisfied go to the next set of if commands...? is that makes sense?

 

by: alexey_gusevPosted on 2009-10-04 at 09:52:26ID: 25489738

well, I do believe in books :) , open ANY tutorial, printed or online, PLEASE ! :)

but seriously, until you understand the basics, it is kind of pointless to do anything else.

for instance, with the code you've posted, it has 2 callbacks defines and assigned (for Talking and IncomingCall changes) which will be called by SNAPI core when appropriate properties have been changed. So when you end the call (in 1st callback) you should see it arrives to your code in 2nd one.

Now regarding ifs - you can always use

if ()
{
}
else if ()
{
}
else if ()
{
}
... and so until you checked all conditions you wanted, ie 2nd "else if()" is checked only if 1st is not true etc.

 

by: ambush276Posted on 2009-10-04 at 11:08:32ID: 25490000

yea ive tried that before.. with the else if statements but it still goes to the second (phonecalltalking) regardless, so after the first concept is true or false it still goes to the false statement and popups up the "testing" box...


also it does not go to the second void or if statements..

i tried the goto commands but it did not work, and ive tried else if statements a nd it still goes to the second one..

i have the Microsoft mobile developer handbook and i have read it .. but i am still confused which is why i am asking on this forum? (;

unless u have another place better to ask?

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.Status;
using System.Runtime.InteropServices;
 
 
namespace celldialer3
{
 
    public partial class CallKab : Form
    {
        Microsoft.WindowsMobile.Telephony.Phone p;
        SystemState _PhoneCallTalking; // declare it here, so it won't fall out of scope
        SystemState _PhoneIncomingCall;
        const int KEYEVENTF_KEYUP = 0x2;
        const int KEYEVENTF_KEYDOWN = 0x0;
        const int KEYEVENTFF_KEYUP = 0x1;
 
        [DllImport("coredll.dll")]
        public static extern void keybd_event(Keys bVk, byte bScan, int dwFlags, int dwExtraInfo);
 
        public CallKab()
        {
            InitializeComponent();
            p = new Microsoft.WindowsMobile.Telephony.Phone();
            p.Talk("9497433374");
            InitializeComponent();
            _PhoneCallTalking = new SystemState(SystemProperty.PhoneCallTalking);
            _PhoneCallTalking.Changed += new ChangeEventHandler(_PhoneCallTalking_Changed);
            _PhoneIncomingCall = new SystemState(SystemProperty.PhoneIncomingCall);
            _PhoneIncomingCall.Changed += new ChangeEventHandler(_PhoneIncomingCall_Changed);
 
        }
        void _PhoneCallTalking_Changed(object sender, ChangeEventArgs args)
        {
            for (int i = 0; i <= 8; i++) 
            {
 
                if (SystemState.PhoneCallTalking == true)
                {
 
 
                    //F4 = red buton (hangup)
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
                    System.Threading.Thread.Sleep(1000);
                   
                    
                }
                
                else if (SystemState.PhoneCallTalking == false)
                {
                    MessageBox.Show("TESTING123XX1");
                    System.Threading.Thread.Sleep(2000);
                     
                     Application.Exit();
                        
                }
 
            }
 
 
        }
    
        
    
 
        void _PhoneIncomingCall_Changed(object sender, ChangeEventArgs args)
        {
           
        System.Threading.Thread.Sleep(4000);
        
            for (int i = 0; i <= 20; i++) 
         {
             if (SystemState.PhoneIncomingCall == true)
             {
              keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
              keybd_event(Keys.F4, 0, KEYEVENTFF_KEYUP, 0);
             System.Threading.Thread.Sleep(500);
             
             Application.Exit();
                 
             }
             
                 else if (SystemState.PhoneIncomingCall == false)
             {
                 MessageBox.Show (" Could Not Recieve Server Connection");
            
                 Application.Exit();
 
         }
         }
        }
    
    }
}
 
 
 
 
   
 
            
     
 
    
 
        
        
 
    
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:

Select allOpen in new window

 

by: alexey_gusevPosted on 2009-10-04 at 11:26:16ID: 25490067

well, let's see what you are doing in that code :)

first, you cancel the call, right? the very next iteration step will find Talking = false, won't it? So it's no surprise it goes to the "else if" block

second method is quite the same. Since each property you use is boolean, so if() {} else {} would do in this very case

 

by: ambush276Posted on 2009-10-04 at 17:00:22ID: 25491606

ok im somewhat slow but i was under the impression that if i use if, else if that only if the if statement is not satisfied (ok that sounds bad...)


ok basically the if =true then it should run what is in the { } and then go to the next Void segment (the phoneincomingcall)

if the 'if' statement is false, then it goes toelse if,  the popup message and exits app on the ok button of the message box....


but i do not want it to go to the else if statement if the first "if=true" statement is satisfied? does that clear it up?

the code is currently not doing that.

 

by: ambush276Posted on 2009-10-05 at 15:50:01ID: 25500568

?? any thoughts?

 

by: alexey_gusevPosted on 2009-10-05 at 16:19:58ID: 25500774

>>ok basically the if =true then it should run what is in the { } and then go to the >>next Void segment (the phoneincomingcall)

you are wrong here, it goes to the next iteration in the loop, so Talking is now FALSE and therefore it exits the application. just as you have written in the code.

let me guess basing on your previous posts that you intended to combine these 2 functions, so perhaps it is worth doing it in new thread (I omit all inter-thread UI stuff for simplicity now):

// Somewhere in the code, eg in Load event handler of the form put this
Thread thr = new Thread(new ThreadStart(tapiMonitorThread));
thr.Start();

...
// then define this function
void tapiMonitorThread()
{
// put your loops here
}

 

by: ambush276Posted on 2009-10-05 at 16:21:53ID: 25500781

ok... but still that does not solve the prolem of the next if statement..

i get creating a new thread? to check for what?

because if the true passes just like u said it checks for the false (which happens because the true drops the calll)...


so how is a new thread giong to change anything. That true false relationship is problematic?

or maybe im not understanding?

 

by: alexey_gusevPosted on 2009-10-05 at 16:33:48ID: 25500854

well, this is binary situation :)  as either I don't understand what you want or you don't :)

have you tried to run the code under debugger? you could see where it goes and when.

as for the thread, it would allow you to put all 4 conditions in the same function, so you'd have a common loop and could check there all "ifs" you ever wanted :)

 

by: ambush276Posted on 2009-10-05 at 16:38:19ID: 25500878

but wouldnt a goto command work>?


so like at hte bottom of the if statement (this code should be very basic) so if first = true

then goto the second if true command

if the if is false popup message and end program

if the if is true then false, pop up another box and close program...?

that is it?

right my quewstion shouldnt that be accomplished with just some basic code.. my question is what is that code ?

( i feel dense lol)..

 

by: alexey_gusevPosted on 2009-10-05 at 16:45:46ID: 25500914

goto can't jump between functions - that's it.

so if you want all 4 blocks to be available at one place - put them into one function and call it from somewhere, doesn't matter will it be a thread, _PhoneCallTalking_Changed() or whatever else.

you could remove for() loops, so then it would cancel phone call in Talking handler, then probably it would go to IncomingChanged handler since the call it terminated, and you get approximately what you want (in my interpretation, of course :) )

 

by: ambush276Posted on 2009-10-05 at 16:47:02ID: 25500919

ok so basically create the new thread like u said
have the first set of if commands in the first thread?

and have the second set in the second thread?


i still dont understand hwo that will stop the false from running>?

 

by: alexey_gusevPosted on 2009-10-05 at 16:55:18ID: 25500957

one thread it enough, put all if/else in one thread, loop forever or exit by some condition.

perhaps you could write down what you need in some pseudo-code, so it will be clearly stated. I have a feeling you won't need all those ifs. The latest code is kind of controversial, because eg when you terminate the call, PhoneIncomingCall property automatically becomes false, doesn't it? Well, it may take some short time, but finally it does.

 

by: ambush276Posted on 2009-10-05 at 16:57:41ID: 25500967

ok i will write it down kind of ... this style it will help you under stand what iw ant..


ok program starts...

void _PhoneCallTalking_Changed(object sender, ChangeEventArgs args)
        {
            for (int i = 0; i <= 8; i++)
            {

                if (SystemState.PhoneCallTalking == true)
                {


                    //F4 = red buton (hangup)
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                    keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
                    System.Threading.Thread.Sleep(1000);
                 
that loops 8 times or so...

then it that is satisfied it goes to this....

void _PhoneIncomingCall_Changed(object sender, ChangeEventArgs args)
        {
         
        System.Threading.Thread.Sleep(4000);
       
            for (int i = 0; i <= 20; i++)
         {
             if (SystemState.PhoneIncomingCall == true)
             {
              keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
              keybd_event(Keys.F4, 0, KEYEVENTFF_KEYUP, 0);
             System.Threading.Thread.Sleep(500);
             
             Application.Exit();




ok now if the program was not satifised (the phonecalltalking==false) then it goes to this..

 else (SystemState.PhoneCallTalking == false)
                {
                    MessageBox.Show("TESTING123XX1");
                    System.Threading.Thread.Sleep(2000);

                    Application.Exit();



and if the phonecalltalking==true and the phoneincomingcall==false then it goes to

else if (SystemState.PhoneIncomingCall == false)
             {
                 MessageBox.Show (" Could Not Recieve Server Connection");
           
                 Application.Exit();


that is the entire application.. (besides the first part stated earlier)...

 

by: alexey_gusevPosted on 2009-10-05 at 17:02:49ID: 25500996

well, after 1st iteration when you execute

if (SystemState.PhoneCallTalking == true)
{
    //F4 = red buton (hangup)
    keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
    keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
    System.Threading.Thread.Sleep(1000);
}

the property value of SystemState.PhoneCallTalking is false (again, it may take short time).

Am I missing something? Why do you need to loop 8 times?

 

by: ambush276Posted on 2009-10-05 at 17:04:49ID: 25501011

the loop needs to be that way to see if the call has gone out..

so like sometimes it takes a while for the call to connect .. so if its not connect that needs to loop..


if it connects.. then great goes onto second part of code, if not it fails and does text box..

how do i change it though to work like my previous post... its obviously not setup that way but how do ichange that?

 

by: ambush276Posted on 2009-10-05 at 17:05:19ID: 25501013

i knw this can be done better with tapi cause i have some cprog.exe questions im going to ask in another post but unless ur pro with tapi this is the only way i can code...

 

by: alexey_gusevPosted on 2009-10-05 at 17:15:35ID: 25501040

I think you don't need to loop at all if you can reliably terminate the call.

these handlers will be called when properties change their values (assuming SNAPI works as expected).

so suppose incoming call is received => it should hit the code in IncomingCall_Changed() where you can terminate it.

the same is true for Talking_Changed()

 

by: ambush276Posted on 2009-10-05 at 17:16:39ID: 25501048

ok how do i do that? just terminate the code and move on?

i dont need to loop
because wont it just got to the if(false) automatically dont iw ant to if true?

can u possibly show an example in  my code posted above it would be much easier to understand.,.. thanks!

 

by: alexey_gusevPosted on 2009-10-05 at 17:29:19ID: 25501092

something like that perhaps?

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.Status;
using System.Runtime.InteropServices;
 
namespace celldialer3
{
    public partial class CallKab : Form
    {
        Microsoft.WindowsMobile.Telephony.Phone p;
        SystemState _PhoneCallTalking; // declare it here, so it won't fall out of scope
        SystemState _PhoneIncomingCall;
        const int KEYEVENTF_KEYUP = 0x2;
        const int KEYEVENTF_KEYDOWN = 0x0;
        const int KEYEVENTFF_KEYUP = 0x1;
 
        [DllImport("coredll.dll")]
        public static extern void keybd_event(Keys bVk, byte bScan, int dwFlags, int dwExtraInfo);
 
        public CallKab()
        {
            InitializeComponent();
            p = new Microsoft.WindowsMobile.Telephony.Phone();
            p.Talk("9497433374");
            InitializeComponent();
            _PhoneCallTalking = new SystemState(SystemProperty.PhoneCallTalking);
            _PhoneCallTalking.Changed += new ChangeEventHandler(_PhoneCallTalking_Changed);
            _PhoneIncomingCall = new SystemState(SystemProperty.PhoneIncomingCall);
            _PhoneIncomingCall.Changed += new ChangeEventHandler(_PhoneIncomingCall_Changed);
 
        }
        void _PhoneCallTalking_Changed(object sender, ChangeEventArgs args)
        {
            // this should stop both incoming and outgoing voice calls
            if (SystemState.PhoneCallTalking == true)
            {
                //F4 = red buton (hangup)
                keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
                System.Threading.Thread.Sleep(1000);  
            }
            // I'd delete above Sleep() or make it shorter
            // otherwise I'm not sure what happens first - this handler is
            // called again with PhoneCallTalking = false
            // or the next one with IncomingCall = false when you close
            // incoming call
            else if (SystemState.PhoneCallTalking == false)
            {
                MessageBox.Show("TESTING123XX1");
                System.Threading.Thread.Sleep(2000);
                Application.Exit();
            }
        }    
 
        void _PhoneIncomingCall_Changed(object sender, ChangeEventArgs args)
        {
            // not sure if you need this waiting  
            System.Threading.Thread.Sleep(4000);
            // if we have incoming call, terminate it
            if (SystemState.PhoneIncomingCall == true)
            {
                keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                keybd_event(Keys.F4, 0, KEYEVENTFF_KEYUP, 0);
                System.Threading.Thread.Sleep(500);
             
                Application.Exit(); 
             }
             // this is probably unnecessary, 
             // or at least you can skip Exit() - depends on what you need
             else if (SystemState.PhoneIncomingCall == false)
             {
                 MessageBox.Show ("Could Not Receive Server Connection");
            
                 Application.Exit();
             }
         }
      } 
   }
}
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:

Select allOpen in new window

 

by: alexey_gusevPosted on 2009-10-05 at 17:30:19ID: 25501095

ah, and move p.Talk() to the end of constructor

 

by: ambush276Posted on 2009-10-05 at 19:13:32ID: 25501439

this seems much more on the track. im going to build it in a few hours .. just one more question


i can see in the incomingcall part you said to "terminate incoming call"

i want hte incomign call to be picked up..

so ok my next post (question/topic) will be about cprog.exe, but basically when the system sees an incoming call.. to hit the left soft key or accept the call... (and go straight to the dialer menu with the phone connected...) so the incoming call i do not want ot "edn call" but accept call automatically? does the script do that.. i think it does but in your description it says it doesnt?

 

by: alexey_gusevPosted on 2009-10-06 at 00:29:10ID: 25502529

since you're using Keys.F4 in each function then it will terminate the call, not accept it.
probably it was a reason for my confusion before :)

I think I've posted a link in one of your earlier questions where there was a key code for green button.

From winuserm.h of WM6 SDK file:

#define VK_TSOFT1   VK_F1               // Softkey 1
#define VK_TSOFT2   VK_F2               // Softkey 2
#define VK_TTALK    VK_F3               // Talk          
#define VK_TEND     VK_F4               // End          
#define VK_THOME    VK_LWIN             // Home        
#define VK_TBACK    VK_ESCAPE           // Back      

#define VK_TACTION      VK_RETURN       // Action      
#define VK_TRECORD      VK_F10          // Record
#define VK_TFLIP        VK_F17          // Flip
#define VK_TPOWER       VK_F18          // Power
#define VK_TVOLUMEUP    VK_F6           // Volume Up      
#define VK_TVOLUMEDOWN  VK_F7           // Volume Down      

so you should use Keys.F3 when you want to simulate a click on anwer button.

 

by: ambush276Posted on 2009-10-06 at 07:03:27ID: 25505089

ok so i compiled it last night and had the same problems...

when the call conencted on phonetalking it ended the call perfectly, but then after it still popuped up the "testing" textbox.???

???

 

by: alexey_gusevPosted on 2009-10-06 at 07:26:36ID: 25505387

correct, this is what I'm trying to get at :)

each handler is called when the property has been changed, eg from 0 to 1 or vice versa, from 1 to 0.
so, when you first enter to _PhoneCallTalking_Changed() the property = 1 and therefore you enter to the 1st block to terminate the call. the very next time (don't know what will happen first, PhoneIncomingCall changes or PhoneCallTalking in case of incoming call) you enter the same function with different value, so it goes to the 2nd block and shows you "testing" box.  You probably should add some variable to indicate that you have terminated the call from the code, set it in 1st block of each function and do nothing if it is set in 2nd clocks

 

by: ambush276Posted on 2009-10-06 at 09:28:03ID: 25506857

correct that is wht problem i have had the whole time...

i want it to skip from block one of the code.. If its True.. so if the first part is satisfied when then it automatically goes to the second void. THat false box with testing" is then will NEVER come up if the true pops up.. SO if True

then go to the second set of information automatically too that point...?

that is the ENTIRe problem i have been having lol... telling the code that if the first part is satsified then skip over that Else if statement of the false box (no matter what) and go to the second void...

how do i do that?

 

by: alexey_gusevPosted on 2009-10-06 at 13:01:25ID: 25509240

have a member where you store that the change was caused by your code (termination), so then

if (true)
{
    causedByYourCode = true;
}
else
{
    if (!causedByYourCode )
    {
     MessageBox.Show();
     ...
    }
}

 

by: ambush276Posted on 2009-10-06 at 15:21:51ID: 25510546

ok i dont understand the if(!cauesdby YourCode) can u jsut show me in one of for one my examples..

thanks (and then this question will be finished i promise) (((:

 

by: alexey_gusevPosted on 2009-10-06 at 23:20:08ID: 25512573

private bool wasTerminated = false;
...
void _PhoneCallTalking_Changed(object sender, ChangeEventArgs args)
        {
            // this should stop both incoming and outgoing voice calls
            if (SystemState.PhoneCallTalking == true)
            {
                //F4 = red buton (hangup)
                keybd_event(Keys.F4, 0, KEYEVENTF_KEYDOWN, 0);
                keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);
                wasTerminated = true;
                System.Threading.Thread.Sleep(1000);  
            }
            // I'd delete above Sleep() or make it shorter
            // otherwise I'm not sure what happens first - this handler is
            // called again with PhoneCallTalking = false
            // or the next one with IncomingCall = false when you close
            // incoming call
            else if (SystemState.PhoneCallTalking == false)
            {
                if (!wasTerminated)
                {
                    MessageBox.Show("TESTING123XX1");
                    System.Threading.Thread.Sleep(2000);
                    Application.Exit();
                }
                wasTerminated = false;
            }
        } 

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

Select allOpen in new window

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...