Switch Radio on&off from .NET - Windows Mobile Development and Hacking General

Hi, I'm a .NET developer and I want to start to develop mobile apps.
My last device is a KJAM that need pen-tap to toggle radio on & off and this is a little frustrating for me (especially when it rains). So I decided to develop a simple (!) app so I can switch my phone on and off simply pressing the "red" button (for example).
Now I found how to bind the red-button-press event to my app but I really not yet found the (damn) method that let me to switch the phone (radio) on and off.
Can someone give me PInvoke samples to use in my C# app?
thnks

At least I can point you to an application, that does what you want.
read the thread http://forum.xda-developers.com/viewtopic.php?t=34831&highlight=
See my posts there (Conchas), and the .exe turned available by Koksie.
The same .exe toggles between enable/disable.
It is really great

thanks a lot ...
even if I wish to develop this app by myself (to start to "surf" the PInvoke hell) of course your advice will help me to reduce my frunstration switchin on my phone

You can always PM Koksie, asking for the function call he used.

I'll do it but he downloaded the program ... in the meantime ... the hardware button "4" now switch my radio on and off

Related

[New Release] Egg-Timer

Hi,
after purchasing Visual Studio 2005 i have finished the first release (and the first program!) of an Egg-Timer. I have removed the need of CF2.0 - it should work now on every PDA without any additional download.
Some comments on it?
Feature Plan:
- Switch off screen during count down to save battery power
- save user settings
- customize layout: change backgroud color and color of buttons
- add more counter to stop time in parallel
- save entire recipes which can direcly be loaded to the counter
Revision History
v1.4
- Second Sound just before the countdown ends (15 seconds)
- Remove the requirement of the .net CF2.0
- implemented a stop watch
v1.3
Major functionality included in the progi:
- PDA prevent from switching off during countdown
- Sound stops by pressing either Stop or Start button
v1.2
- Some Bugfixes
- fixed: Scrollbars removed
- About Menu included
- Start Button is usable from right softkey
v1.1
- wave file is selectable now
- thumbfriendly
- Some Default suggestions
- Speed up the timer by menu to get an enhanced accuracy
- Options Menu included
Let me know if it works on your device.
Looks great! Will test it soon!
This i like. But this is really a prog u need to make thumbfriedly! I mean minutes and secons. and also have a memory so u just can press for instance the usuall 3 minutes.
frewys said:
This i like. But this is really a prog u need to make thumbfriedly! I mean minutes and secons. and also have a memory so u just can press for instance the usuall 3 minutes.
Click to expand...
Click to collapse
Thumbfriendly - hmm - thats a good improvement. I will put it on my todo list. I have some good ideas. This issue is very easy to implement. Let me see if i can release a new version in short time. Nevertheless: Do you know that you can just tap on one of the NumericUpDownCounter with a thumb and control it via the DPAD? That is also comfortable....
The other idea with a memory is also a good idea but it is more tricky to implement. I have to read in more detail of programming. Maybe some registry storing or an ini file will be ok. At a first i will implement some hardcoded suggestions. This is easy to implement.
Thank you for the good ideas.
Bubisch said:
Looks great! Will test it soon!
Click to expand...
Click to collapse
Let me know, if it works on your device, especially the sound :?
EggTimer gives an error.
EggTimer needs a newer version of .NET Compact Framework than is installed on the device.
I’m getting a “InvalidProgramException”.
I’m using ROM 2.01a.64WWE; WM5.0 OS 5.1.195 (Build 14847.2.0.0) so I do have the newest version?
Or isn’t it a standard part of the OS?
If not, where can I get a newer version of .NET Compact Framework?
topcaser said:
frewys said:
This i like. But this is really a prog u need to make thumbfriedly! I mean minutes and secons. and also have a memory so u just can press for instance the usuall 3 minutes.
Click to expand...
Click to collapse
Thumbfriendly - hmm - thats a good improvement. I will put it on my todo list. I have some good ideas. This issue is very easy to implement. Let me see if i can release a new version in short time. Nevertheless: Do you know that you can just tap on one of the NumericUpDownCounter with a thumb and control it via the DPAD? That is also comfortable....
The other idea with a memory is also a good idea but it is more tricky to implement. I have to read in more detail of programming. Maybe some registry storing or an ini file will be ok. At a first i will implement some hardcoded suggestions. This is easy to implement.
Thank you for the good ideas.
Click to expand...
Click to collapse
Like what u have done with it. Glad I can be of some use. Like the idea of regfile. so there is as little extra files as possible.
Regards
Fredrik
Re: EggTimer gives an error.
Dodger said:
EggTimer needs a newer version of .NET Compact Framework than is installed on the device.
I’m getting a “InvalidProgramException”.
I’m using ROM 2.01a.64WWE; WM5.0 OS 5.1.195 (Build 14847.2.0.0) so I do have the newest version?
Or isn’t it a standard part of the OS?
If not, where can I get a newer version of .NET Compact Framework?
Click to expand...
Click to collapse
You need the CF 2.0 and can download it here:
http://www.microsoft.com/downloads/...6b-356b-4a2c-857c-e62f50ae9a55&DisplayLang=de
But if you can wait some time i will release a version without the needs of the CF 2.0 ...
I just tried your eggtimer and its really good! But just rememered that i tried something like this before..
the problem is u want to turn off the device so that i reserves power.. but the timer doesnt work than. Two possible workarounds ( im no programmer so bare with me) either have a buttan that swithes of the display OR maybe its possible to check the realtime clock and activate the alarm after the right amount of time?.. just a sugestion.. if possible
Regards
Good job topcaser come along way since the first release.
I like the fact the backlight stays on so you can keep an eye on the time, when cooking your egg, so an optional light/screen on/off would be a good idea.
When i tried it on my wizard alarm kept going off even when i closed the program hope that can be fixed.
Maybe an idea to startup with the standard 3 minutes (default) and have an option to change.
Thanks again, i shall return
p.s. great you released without the net, boy do i hate that thing fills up your memory!?!?
Find attached 2 egg timer images - perhaps that can be made into an ico file for your exe - a high profile program like yours needs an icon
Will give this ago when I get AS back on my PC...
Thanks
Terran
When I start it, it closed down :?:
I have net installed using it on a rx 3715 with WM2003SE
Not sure if you are still developing it or not. I like it very much. Just hope it get better.
1. Make it save the state when exiting (stopwatch or not, timer preset data).
2. Move the bigger buttons (start/stop/proceed) to the bottom, so that it can be easily touched by thumb.
3. If the stopwatch doesn't start from zero, I still didn't find a way to reset it to zero.
Palm has a freeware: stopwatch, which is very easy to use:
Pic
Palm also has a good freeware for timer: bigwatch, in which touching the min/hour/sec upper part will increase 1, touching the lower part will decrease 1, very concenvient.
bigclock
Good luck!

starting a process on incoming call and stopping when the call is answered

Hi,
I am trying to write a small application for my WM6 phone device.
What I intend to do is :
- write the application in c#
- it will be a background application (daemon)
- starting to blink leds of my phone (I have a dll which I know how to call from within a C# app)
- stopping this process when the call is answered or the ringing state is passed
- no forms will be used (as it will be a background application which will only play with leds)
- when the exe is called a second time , it should disable itself
Unfortunately, I could not succeed a few months ago as seen here :
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2454023&SiteID=1
Then , I had some other issues to deal with and left the project. Now I want to start over, fresh...
However, I am not sure of what is the most acceptable solution for this.
As I do not want to load the CPU or memory with unneccessary processes, I want to be able to do it correctly.
Could someone show me the path ?
Please take a look at the thread that I gave the URL above. At that time we discussed this but I couldn't achieve it.
Thanks for any help, comments...
SystemState class seems to only work if you have a form based application. Which is silly I know. Basically the only solution is do dump the daemon idea and have a form based app but hide the form.
thanks for your reply.
what do you mean by "dump the daemon idea" ? do you mean I shouldn't use it ?
if I create a form based app and hide the form, which method should I use to start the process when phone starts ringing ?
p.s : english is not my native language so I may misunderstand some phrases.
yes he means forget the daemon..and i recommend using C++ as it uses less system resources plus its fast .. im currently developing my first Kitchen in C++ if u want i can work with you also
I agree with you; of course c++ is faster but it's not as easy as c#.
what do you mean by kitchen ?
I would like to work with you but my intention is just creating a simple application. This is not my job, you see ?
A kitchen is a place where you can cook your OWN ROM for your Windows Mobile Device..currently its for Himalaya Only ..check it out here
http://forum.xda-developers.com/showthread.php?t=378498
for me its not a JOB also its just my hobby ..im also a student in 12th grade
thanks for your kind offer. however, I wouldn't like to take your time for my very simple application
If you tell me the correct and easiest method to invoke my application and start its process, I can write the application. I'd just consult you if I'm stuck.
If you are also interested in this app. I can always send you the source code.
sure sure..send me the source....i am not doing much at the moment any way..except for re-writing the tools in C++..i have another useful suggestion..u can use MortScript to this but then it will be different
if you pm me your email address , I can send you the current source code.
But I am not sure if what I wrote is the best way of doing it.
by "best" I mean least cpu power used.
ather90,
did you receive my email ?
yeah i got the source..but there is a problem..you have built this on WM6 Pro SDK..not on WM5..i dnt have WM6 SDK..so i couldnt work yet..but will download it today..its better if you can switch it to WM5 SDK ( it will be same for WM6/6.1 i guess).
I don't know how to convert it to WM5 SDK.
If you tell me I can switch...
NO probs..the SDK is almost downloaded..i figured i might as well download the SDK caz i will need later
ok; waiting for your update...
any updates ?

locking down hardware buttons

Hi Guys
Wondered if anyone knew of a way of locking down all the hardware buttons with a registry change on WM5?
Or at least specific ones?
Reason being I'm developing a flash lite data driven app for a device specific service with issued handsets to users during a corporate event - they need to be "locked down" to stop the user activating the phone using the "make call" buttons etc.
Although I can make the Flash app run "full screen" I can't stop the other buttons switching to other apps.
Regards
Derek
2 suggestions.
1 if you are trying to gain lock out control A_C's S2U2 program accomplashes this. If you need something other than his program I recommend that you PM him and asked him out he accomplished it with his lock.
2 you may want to try a program like hbutton. It would allow you to assign controls of the buttons to certain actions. One of the action options could be to do nothing. You could set them all to that.
Try using GXOpenInput();
it will redirect all input screen/keys to your app and then you can ignore then if you want.
Chris
chrisstavrou
I've just googled that command and found this page...
http://msdn.microsoft.com/en-us/library/ms831632.aspx
Seems like a good solution - only problem is, I'm not a .Net developer, so how would I pass this into the Flash Lite App as a .swf is loaded on the handset?
is there a way of passing this system variable in almost like a command-line before the app is opened?
Or would I need an executable on the PocketPC to somehow pass that in opening flashlite and the .swf in one go?
Thanks
Thanks for all the useful suggestions, I'm now following them up - cheers guys!

Possible solution for TF3D Qvga Standby issue, dev needed

Hi there,
cause most of you know the problem with TF3D Qvga and StandBy.
Could anyone here with knowledge of coding write a small app that acts like the standby timer in Windows Mobile?
I thought about something like that:
If no user action is recognize for time x, then deactivate TF3D (HKLM","\Software\Microsoft\Today\Items\TouchFLO 3D","Enabled","0")
and device goes to standby.
If device wakes up (or pressing power button) TF3D will be enabled again.
I think for someone with knowledge in development it shouldn't be mouch action, but it would be great to have a fully working TF3D and i think driver development still will need some time.
So, if someone is able to do that, please, please, please
I will test everything.
that should only be a few lines of mortscript, no ?
No itried this by myself (it's anywhere here in this forum) and i talked to Mort, too.
But there is no possibility in the actual version to recognize user actions.
The rest you can easyli write in MortScript, but not the user recognation.

New audio switch program for skype and others.

This program is an evolution of the first I made. It will route the audio to the earpiece when an certain program is running.
I put the program here because I have test it in wizard, if people test this in others phones and it works, please post here and maybe move this this thread to an more "generic" forum.
the program MUST be under "\($program files)\audioswitch" folder, you must unzip the contents to this folder.
the configuration file (command.txt) is under this format:
1000
skype
fring
etc
the first line is the delay(in miliseconds) in witch the program will "look" if a program in the list is in the top level window, faster phone, smaller delays, I recommend 1000 ms.
the next 20 lines are the programs you want the audio to be routed to the earpiece(max 20 lines for now).
Again the program is under the "do it on your own risk" and "I am not responsible for anything" licence. And,of course, it is free!! Do not sell it!
It is manly intended for little expert users, as it is still in "beta" fase, hehehe.
How it works:
the program runs in an eternal loop and look for the title of the current window that is displayed for the user in a time interval.
When the program mach the title window with one of the names user configured it it will switch the audio, when the program is not running anymore, the audio will swich back.
Do not launch two or more instances of the program at the same time, could really mess things up. -- se the forum (thanks tucahara)
To stop the program, u must use a process manager.
it would be good if someone could make a cab to install it. -- done see the forum (thanks tucahara)
this is still a beta, I intend to make ajustments as people give feedback.
Thanks,
hope u like.
-----first update---
now, an file called "audioswitch_error.txt" in the root directory will hold the error messages.
------------ List - Working ------------
wizard - I tested
P3301 or P3300 - I tested
att tilt - I tested
touch 3452 and 3450
touch dual
touch cruise
touch HD
Sony Ericsson Xperia X1
BenQ E72
Titan --> see the forum
------------ List - NOT working ------------
T-Mobile Diamond
HTC Touch by Sprint
Samsung SGH-i780
------------------------------------------------------------------------------------
check the new thread at:
http://forum.xda-developers.com/showthread.php?t=502361
new aproach to do the switch and now open source, even with an class that others can improve and put in other apps...
Some people complain about me not openning the source of the app, I have just made this way because there was proprietary code inside and I had no time to rewrite it without the proprietary code.
I have made the best I could, and now I had some time and rewrite the app in open source, to those who only complain about it, get the code and make it better instead of complaining!
Thanks for all that encourage me to continue the work and helped the development.
will retire this project for while...
thanks u all.
Audioswitch for Skype
On HTC Touch by Sprint (CDMA, also known as Vogue), audioswitch does switch the audio in the Skype 2.5 windows mobile PPC from external speaker to handset. Unfortunately, the microphone is then also disabled. I hope you'll be able to tweak your audioswitch to resolve this.
Thank you so much for developing this wonderful applet. I'm sure you will have the gratitude of many frustrated Skype windows mobile users.
What really happens is that when the sound output is switched in some phones, the microphone gain changes too. This happens because the phone thinks it is a "normal call".
Most of the times the mic gain increases, but in your phone it must be decreasing. Try to figure out in registry where the mic gain controls are recorded and chage all of then to the same value. I had this issue with my P3301 and solved this way, but there is quite a time now and I do not remenber where are the reg keys to change, but I have found the information here in the forum.
I will try to figure out for other "hack" to solve this issue... thanks for reply.
doesn't work at T-Mobile Compact IV (aka Diamond)
Sound went to loudspeaker....
PS: fring last version working fine with sound at mine phone (without any additional programms). Sound is going to correct destination automatically
I just tried the latest version of Fring, which automatically switches audio to earpiece when call is connected.
The same issue occurs with the new Fring as I described above with your audioswitch program: I can hear audio through earpiece, but microphone doesn't work (or is inaudible).
I couldn't find a tweak or registry hack to correct this. Any help would be greatly appreciated.
MarceloFB said:
This program is an evolution of the first I made. It will route the audio to the earpiece when an certain program is running.
I put the program here because I have test it in wizard, if people test this in others phones and it works, please post here and maybe move this this thread to an more "generic" forum.
the program MUST be under "\($program files)\audioswitch" folder, you must unzip the contents to this folder.
the configuration file (command.txt) is under this format:
1000
skype
fring
etc
the first line is the delay(in miliseconds) in witch the program will "look" if a program in the list is in the top level window, faster phone, smaller delays, I recommend 1000 ms.
the next 20 lines are the programs you want the audio to be routed to the earpiece(max 20 lines for now).
Again the program is under the "do it on your own risk" and "I am not responsible for anything" licence. And,of course, it is free!! Do not sell it!
It is manly intended for little expert users, as it is still in "beta" fase, hehehe.
How it works:
the program runs in an eternal loop and look for the title of the current window that is displayed for the user in a time interval.
When the program mach the title window with one of the names user configured it it will switch the audio, when the program is not running anymore, the audio will swich back.
it would be good if someone could make a cab to install it.
this is still a beta, I intend to make ajustments as people give feedback.
If someone like this program and wants to make an donation...
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4WLQVA6LTKWSL&lc=GB&item_name=marcelofb&item_number=marcelofbxdadonations&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG_global%2egif%3aNonHosted
Thanks,
hope u like.
Click to expand...
Click to collapse
I have an idea. Rather than regularly polling to see what the current windows is, why not use a windows hook to monitor windows messages. When you see a message indicating a window has come to the foreground test it against your list of windows and enable/disable audio switch as necessary. Use SetWindowsHookEx and hook for WH_CBT messages. If you are unfamiliar with using SetWindowsHookEx I could supply you with the hooking code and all you would need to do is insert the code to check the window names, enable the audio switch, and disable the audio switch. Or you could send me the enable/disable routines.
Another tip, I noticed that skype places an icon in the notification area during a call. If there is someway of detecting the notification icon that could be another great way to trigger the switch.
Great program though. Works beautifully.
OOOH
If this program works on the new BenQ E72 I'm getting in a couple of days I'll certainly donate!
THANKYOUTHANKYOUTHANKYOU
hello,
it does not work on hermes (tytn).
by the way "troca2" does work on hermes! - maybe you guys want to work together?
baal_zebub said:
hello,
it does not work on hermes (tytn).
by the way "troca2" does work on hermes! - maybe you guys want to work together?
Click to expand...
Click to collapse
hehhehe, I made troca2, I will see if the switch code is the same or if I have made some mistake...
are u sure you have put the program in the correct directory?? I will make some modifications to have an error feedback. So u can see if something is wrong...
JKingDev said:
I have an idea. Rather than regularly polling to see what the current windows is, why not use a windows hook to monitor windows messages. When you see a message indicating a window has come to the foreground test it against your list of windows and enable/disable audio switch as necessary. Use SetWindowsHookEx and hook for WH_CBT messages. If you are unfamiliar with using SetWindowsHookEx I could supply you with the hooking code and all you would need to do is insert the code to check the window names, enable the audio switch, and disable the audio switch. Or you could send me the enable/disable routines.
Another tip, I noticed that skype places an icon in the notification area during a call. If there is someway of detecting the notification icon that could be another great way to trigger the switch.
Great program though. Works beautifully.
Click to expand...
Click to collapse
It is a good idea to use hook, I have not think of it!
I use a proprietary code included in a lib at the company I work for to make the "switch" but it is not different of what u find here in the forum.
Maybe we can make an effort to re-make it with hooks...
so this program must run all the time? after every softreset you have to start it?
is it not easier with mortscript (for example) to make an shortcut that opens skype as well as the audioswitch program? and closes the audioswithc program when you close skype?
I am using it right now and it seems to work perfect:
i used this script after installing mortscript (http://www.sto-helit.de/):
run( "\Windows\SkypeSoundSwitch.exe" )
runwait( "\Program Files\Skype\Skype.exe" )
close( "troca2" )
(see that in my case i downloaded your original program and renamed it to skypesoundswitch.exe and put it in the windows map)
I renamed it so i could remember what the purpose the file had.. changed nothing but the name!
Thanks for the program by the way! it always worked perfect!!
so to sum up the way i have it now (most files included) on my xperia x1:
1) installed skype
2) installed mortscript
3) add skypesoundswitch to \windows\....
3) add skype.mscr to \.... (root)
4) overwrite skype.lnk with the new skype.lnk in \windows\start menu\programs\..
in the way whenever i open skype(.lnk), it opens skype.mscr, this opens skypesoundswitch.exe and than skype.exe... when you close skype.exe it closes skypesoundswitch.exe...
it seems to work perfect.. but hey maybe i am doing something totally wrong here.. than just shout!
by the way, the .mscr and the .lnk files are offcourse edit-able .. so you can put the files everywhere you like..
madhijs said:
so this program must run all the time? after every softreset you have to start it?
is it not easier with mortscript (for example) to make an shortcut that opens skype as well as the audioswitch program? and closes the audioswithc program when you close skype?
I am using it right now and it seems to work perfect:
i used this script after installing mortscript (http://www.sto-helit.de/):
run( "\Windows\SkypeSoundSwitch.exe" )
runwait( "\Program Files\Skype\Skype.exe" )
close( "troca2" )
(see that in my case i downloaded your original program and renamed it to skypesoundswitch.exe and put it in the windows map)
I renamed it so i could remember what the purpose the file had.. changed nothing but the name!
Thanks for the program by the way! it always worked perfect!!
Click to expand...
Click to collapse
That works great too. The advantage of this new program is that it will only reroute the audio when skype is in the foreground. You could minimize skype and leave it running, and audioswitch will automatically restore your sound. Get a call and open up skype and your sound goes back to the earpiece.
I will create the code to do it with a windows hook when I get a chance MarceloFB. Please pm me your email address. All you will have to do is insert the code to read the config file, check the window names, and when necessary enable or disable the switch. Or please show me where to find details on how to code this myself. Thanks!
Hat off to both of you and really glad that we will have a much improved solution.
JKingDev said:
That works great too. The advantage of this new program is that it will only reroute the audio when skype is in the foreground. You could minimize skype and leave it running, and audioswitch will automatically restore your sound. Get a call and open up skype and your sound goes back to the earpiece.
I will create the code to do it with a windows hook when I get a chance MarceloFB. Please pm me your email address. All you have to do is insert the code to read the config file, check the window names, and when necessary enable or disable the switch.
Click to expand...
Click to collapse
okay! I only used skype to make calls and than get offline so this way did the trick for me! but i have to admit it would be much better when i can keep skype online!
this new program does the trick indeed! it changes the output back when i minimize skype!
But still my question above, you have to start this program on every startup isn't it? what does it do with the battery?
madhijs said:
okay! I only used skype to make calls and than get offline so this way did the trick for me! but i have to admit it would be much better when i can keep skype online!
this new program does the trick indeed! it changes the output back when i minimize skype!
But still my question above, you have to start this program on every startup isn't it? what does it do with the battery?
Click to expand...
Click to collapse
Yes it must be run at startup but placing a link in your startup folder will make everything transparent to the user. I don't think there will be an effect at startup. In it's current form it must check every second (or whatever you set the timeout to), but its only a little bit of code. I am not really sure if that will really have an effect. The more often it checks the faster it will switch when you open skype, but also the more processor use. Check less often and it uses less processor, but there might be a delay in switching the audio. I proposed doing it by hooks though because this would use even less processor. The app will only check when a new window takes focus, rather than just periodically checking. This way it only checks when it needs to and will always switch instantly.
I am glad u liked the program.
I will try to answer most of the questions...
1- JKingDev:
I have though in your idea of using hooks, but if I use a hook, the program will have a loop anyway to check for the messages(hidden loop ;-) ), and it would have to have an "fake window" or something to process the messages. This way we have only one loop, in a very simple command line program with high optimization, so we have to think what is really the best way of doing it... I will pm u as soon I have any time to "program" again. hehe
2- people that uses mortscript with the old "troca2"
I will try to make a way to make this program work the same way as troca2, maybe with an "argc argv", wait the next update.
3- the battery life??
if u notice any battery life decreasing with the usage of the program, configure a bigger delay, maybe 5000ms, it is a matter of adjust the "timming" for each processor. Post your results here so others can find the optimum value for the delay in their phones.
4- have to start the program every reset?
yes, just put it in the startup folder.
maybe someone can make an cab that put the program in the right place and a link in the startup, it would be cool! I dont have an easy program to deal with cabs, and the vs projects for cabs.... I really cant make that thing work!!
well it is only the batterylife i was worried about. but i'll try running the phone this weekend with the program running and doing some skype.. lets see how it turns out!
For folks who have issues of mic on using this program, there is a quick solution for this problem. You can try sjphone. It provides a internal mic volume control. However, the major setback is that it's only working in wm5.
my 2 cents
weekendli said:
For folks who have issues of mic on using this program, there is a quick solution for this problem. You can try sjphone. It provides a internal mic volume control. However, the major setback is that it's only working in wm5.
my 2 cents
Click to expand...
Click to collapse
will check this, but people reported that worked in xperia... and it is running in my P3301... anyway, will check and post an wm6 build if it is the case... check the error file and see if it tells anything.
Other thing, this program uses low level api`s, so your windows MUST be fully unlocked for it to work in wm6.

Categories

Resources