[SOLVED] How do I restart manila in C# or C++? - Windows Mobile Development and Hacking General

Hi.
Can someone tell me how to restart manila programatically? I'm writing an app that requires it to restart in order to show some changes and am struggling with this.
I thought it would be a simple case of getting a handle, closing the process and then running manila.exe again, but this doesn't want to work.
Any advice would be appreciated.
Solved!
See this post...
http://forum.xda-developers.com/showpost.php?p=5627550&postcount=13

Hi
You can try TFDetacher :
http://www.codeplex.com/TFDetacher
Sorry if I don't understand your question, I'm french
Good Luck

You could use MichaRefresh too.
http://forum.xda-developers.com/showthread.php?t=583034

simply mortscript
Code:
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 0
RedrawToday
whatever
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 1
RedrawToday

Thanks for the answers guys, but I'm trying to do this in an app that I'm writing, so the suggestions for apps are unfortunately no good for me.
bgumble - the registry entry changes are fine, but I don't know what MortScript actually does when you use the "RedrawToday" command. I won't be using MortScript (my app is being developed in C#), so I'm 1/2 way there now, thanks
Can anyone point me in the right direction with this?

johncmolyneux said:
Thanks for the answers guys, but I'm trying to do this in an app that I'm writing, so the suggestions for apps are unfortunately no good for me.
bgumble - the registry entry changes are fine, but I don't know what MortScript actually does when you use the "RedrawToday" command. I won't be using MortScript (my app is being developed in C#), so I'm 1/2 way there now, thanks
Can anyone point me in the right direction with this?
Click to expand...
Click to collapse
..how about kill manila.exe?

cyron_at said:
..how about kill manila.exe?
Click to expand...
Click to collapse
That was my first thought, and it seemed like the most likely thing, but it doesn't work. First off, I couldn't terminate the process in C#, so I tried it with dotfred's task manager. It doesn't seem to want to terminate at all. It still appears to be running, but then the desktop is screwed, as if it's not being redrawn. Running manila.exe afterwards just doesn't help and you need to restart the device.
Any advice?

Might be some goodies here, don't have time to test I'm afraid : http://msdn.microsoft.com/en-us/library/bb416484.aspx
Dave

if you have mortscript use this

DaveShaw said:
Might be some goodies here, don't have time to test I'm afraid : http://msdn.microsoft.com/en-us/library/bb416484.aspx
Dave
Click to expand...
Click to collapse
Thanks Dave. It doesn't help, but it's an interesting read nonetheless
bnm7bnm said:
if you have mortscript use this
Click to expand...
Click to collapse
Thanks, but I'm doing this in C# and don't want to require the end user to have any extra software installed.

bgumble said:
simply mortscript
Code:
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 0
RedrawToday
whatever
regWriteDword HKLM, Software\Microsoft\Today\Items\HTC Sense, Enabled, 1
RedrawToday
Click to expand...
Click to collapse
I haven't tested this with Manila but instead of RedrawToday the following call might be good:
PostMessage:GetDesktopWindow(), WM_WININICHANGE, 0xF2, 0);

RAMMANN said:
I haven't tested this with Manila but instead of RedrawToday the following call might be good:
PostMessage:GetDesktopWindow(), WM_WININICHANGE, 0xF2, 0);
Click to expand...
Click to collapse
Thanks RAMMANN - I'll give that a try and let you know.

BIG THANKS to bgumble, RAMMANN and MichelDiamond. I'm putting the code here for both my future reference and for anyone who stumbles across this whilst looking for the same solution...
Code:
using Microsoft.Win32;
using System.Runtime.InteropServices;
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("coredll.dll", SetLastError = true)]
static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private static void RestartManila()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey
("Software\\Microsoft\\Today\\Items\\HTC Sense", true);
key.SetValue("Enabled", 0);
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, (IntPtr)0xF2, (IntPtr)0);
// This is required or manila is enabled before it's fully disabled,
// so doesn't restart
System.Threading.Thread.Sleep(1000);
key.SetValue("Enabled", 1);
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, (IntPtr)0xF2, (IntPtr)0);
}

johncmolyneux said:
BIG THANKS to bgumble, RAMMANN and MichelDiamond. I'm putting the code here for both my future reference and for anyone who stumbles across this whilst looking for the same solution...
Code:
using Microsoft.Win32;
using System.Runtime.InteropServices;
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
private static void RestartManila()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(
"Software\\Microsoft\\Today\\Items\\HTC Sense", true);
key.SetValue("Enabled", 0);
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
// This is required or manila is enabled before it's fully disabled,
// so doesn't restart
System.Threading.Thread.Sleep(1000);
key.SetValue("Enabled", 1);
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
Click to expand...
Click to collapse
I'd reccommend using PostMessage instead of SendMessage.
I wrote the WeatherCityEditor that is used for Sense 2.1 and Sense 2.5.
Joe Wilcox sent me code very similar to this to Stop and Start Touch Flo 3D. He wrote the app that was used with Manila 2.0 and earlier.
When Sense came along, I tried just changing the TouchFLO 3D part to HTC Sense like what is posted.
Sometimes, it workded great, but some users reported hangs on start. I did not reproduce immediately, but eventually it started happening for me too. Very rarely right after a soft reset, but after leaving the phone alone for hours.
When it would hang, it might hang for up to 5 minutes.
Switching to Post message, and adding a 1 or 2 second delay took care of it.
SendMessage waits for things to be processed. PostMessage does not wait.

JVH3 said:
Sometimes, it workded great, but some users reported hangs on start. I did not reproduce immediately, but eventually it started happening for me too. Very rarely right after a soft reset, but after leaving the phone alone for hours.
When it would hang, it might hang for up to 5 minutes.
Switching to Post message, and adding a 1 or 2 second delay took care of it.
SendMessage waits for things to be processed. PostMessage does not wait.
Click to expand...
Click to collapse
Thanks for the advice mate. I was aware of the difference between the 2 methods but didn't realise that it could cause a problem. I chose to use SendMessage because it waits for a response, thinking that it may negate the need for the sleep inbetween the 2 calls, but if you've experienced it causing problems as you described then I'll definitely use PostMessage instead!
Thanks mate

Related

tip: how to vibrate

Code:
#include <windows.h>
#include <nled.h>
// from the platform builder <Pwinuser.h>
extern "C" {
BOOL WINAPI NLedGetDeviceInfo( UINT nInfoId, void *pOutput );
BOOL WINAPI NLedSetDevice( UINT nDeviceId, void *pInput );
};
void LedOn(int id)
{
NLED_SETTINGS_INFO settings;
settings.LedNum= id;
settings.OffOnBlink= 1;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &settings);
}
void LedOff(int id)
{
NLED_SETTINGS_INFO settings;
settings.LedNum= id;
settings.OffOnBlink= 0;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &settings);
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
for (int i=0 ; i<10 ; i++)
{
LedOn(1);
Sleep(400);
LedOff(1);
Sleep(200);
}
return 0;
}
led '0' is the radio led
led '1' is the vibrator
Thanks for this tip!
I was just looking for a way to make the phone vibrate. We're doing applications for the deaf community so vibration is absolutely necessary!
/Christer
With settings.LedNum=0 i can do the things with the Radio LED.
But my MDA 2 has a third LED for Bluetooth. And when i query Device Info i get a count of two(starting at 0). But i canĀ“t do something with the 3rd LED. Somebody knows why?
I also would like to know hot the let the first LED flash green and not Red?
Ok this thread is ancient, but I am resurrecting it to ask a relevant question. This is the method that I am currently using to vibrate. The problem is that when the cpu is being used for other tasks, this will tend to make it vibrate longer than expected. For instance if I switch screen orientation and they try this the vibration will be longer because other threads are doing some processing. The following:
LedOn(1);
Sleep(400);
LedOff(1);
is not a reliable method because if the CPU is busy more than 400ms may elapse between the two calls. Sometimes a lot more. Is it possible to use the blink mode for the vibrator, as in using 2 for the OffOnBlink value as in this msdn article?
http://msdn.microsoft.com/en-us/library/ms905326.aspx
So far all I can get it to do is vibrating without stopping. Any help would be appreciated. Thanks.
JKingDev said:
Ok this thread is ancient, but I am resurrecting it to ask a relevant question. This is the method that I am currently using to vibrate. The problem is that when the cpu is being used for other tasks, this will tend to make it vibrate longer than expected. For instance if I switch screen orientation and they try this the vibration will be longer because other threads are doing some processing. The following:
LedOn(1);
Sleep(400);
LedOff(1);
is not a reliable method because if the CPU is busy more than 400ms may elapse between the two calls. Sometimes a lot more. Is it possible to use the blink mode for the vibrator, as in using 2 for the OffOnBlink value as in this msdn article?
http://msdn.microsoft.com/en-us/library/ms905326.aspx
So far all I can get it to do is vibrating without stopping. Any help would be appreciated. Thanks.
Click to expand...
Click to collapse
actually putting the thread to sleep is kinda not recommended, i usually create another thread to vibrate and set it to sleep then stop the vibration and exit the thread.
maybe i can create a class for that, but it will be a C# class, not C++
anaadoul said:
actually putting the thread to sleep is kinda not recommended, i usually create another thread to vibrate and set it to sleep then stop the vibration and exit the thread.
maybe i can create a class for that, but it will be a C# class, not C++
Click to expand...
Click to collapse
I am not exactly sure what you mean by this. Do you do the exact same thing but all in another thread? Or do you start the vibration, create a new thread that just sleeps then stop the vibration when the thread returns? I got even worse results when trying it all in another thread.
Is there no other way to do this than start vibration then stop it after sleeping? There is no way to give it the duration you want?

Simulate Button Click

Hi,
I am trying to simulate a PictureBox.Click event. I have searched these forums and the ones on MSDN with many different combinations of search terms.
However I cannot find anything!
Basically what I am trying to achieve is to fire the picturebox's click event from within my code. What I have read so far seems to indicate that I need to make a call to SendMessage (COM interop?) to actually make windows perform the click.
This is for the compact framework version 1.0.
Any help you can give would be great because this is all very new to me, I'm a web application developer by trade so i'm a fish out of water on this one!
OK, the other method that I am investigating is the use of the mouse_event as demonstrated in this article by Daniel Moth.
However I am struggling to find the namespace Win32Api anywhere in the framework so I'm struggling with that also.
*Update*
I have been able to simulate a click using mouse_event in a call to the coredll using the following code:
Code:
[DllImport("coredll")]
static extern bool SetCursorPos(int X, int Y);
[DllImport("coredll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
bool tempVal = SetCursorPos(x, y);
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
however I have one outstanding problem (that I know of!).
I am struggling to capture the corrext X and Y co-ordinates of the control. I have tried many different methods and they all return values of 0 for both axis.
How do you guys do it?
Many Thanks
I haven't answered till now since I don't know .NET
But since you found your way to using native APIs I think I can help you.
This is how I would do it in C/C++:
Code:
RECT wndRect; //this is a structure that contains window top, left, bottom and right coordinates.
GetWindowRect(FindWind(L"[I]window class[/I]", L"[I]window name[/I]"), &wndRect);
x = wndRect.left + 1; //add 1 to window position to make sure the click is inside
y = wndRect.top + 1;
GetWindowRect returns the window position in screen coordinates for top left and bottom right corners.
For FindWindow to work you need to know the class and name of the window you want to find. You can find them using a utility called SPY++ which comes with any Microsoft C++ compiler.
The class is window type (so it will probably be something like 'PictureBox' or 'Image') and window name is most likely blank.
Hope this helps.
Thanks fo your help
I don't know if your code would have done the trick or not but I managed to work my way through the different class definitions to find what i needed.
Code:
int x = selectedButton.PointToScreen(selectedButton.Bounds.Location).X + 2;
int y = selectedButton.PointToScreen(selectedButton.Bounds.Location).Y + 2;
This still doesn't work but I really don't have time to work out why, all I know is that the call to SetCursorPos() returns false. I know the mouse_event code works because if I position the cursor over the Start button it opens the menu.
Time is of an essence so for now I'm just going to have to drop this and pray that I have time to finish this when towards the end of my project.
/me thinks writing my first Mobile 5.0 application in 4 days (I'm a web application developer by trade) was bad planning on the management's fault anyway
Thanks for your input though
use this method signature:
[DllImport("coredll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
int instead of uint or long.
For me it worked.

idea for a small application... any help?

Ok, when I'm in my office I have poor signal issues that drain my battery and miss calls. If I switch to Roaming Only in my phone settings, then everything is just peachy. Problem is, its a lot of menus to click through every single time I come in to my office (Start, settings, phone, services, roaming, get settings, roaming only).
And then when I'm leaving, I want to turn the romaing settings back to automatic, once again its a lot of clicking.
I would imagine it would not be too difficult to write an app that could toggle that setting. Then it could be one click, or someone could even map the app to a hardware button for the ultimate ease of use.
I'm sure there are others who can see how useful such an app would be. Many of us do something like this all the time.
So, what do you think? Anyone willing to help develop this?
Sounds like a do-able program that would be very useful even for people not in your situation. Of course, I don't know how to, I'm just endorsing this idea.
In for this
GREAT!
Now, who can actually help figuring out how to code this? Can that sort of data even be accessed from standard APIs?
MortScript
Ok folks, until I have the time to find out what actually goes on behind the scenes when roaming settings are changed, I think our best bet is to write a script of keypresses/mouseclicks using mortscript.
Mortscript, in case you didn't know, is a simple batch process program, which lets you assign a series of commands to a script, sort of like a macro.
This will essentially be a script to go through the menus and click through options to do what we would do by hand. It will speed things up a bit, but it won't be as simple as a standalone app.
playing with mortscript now, I'll keep you guys posted.
EDIT: Anyone who wants to take a crack at this as well, by all means, mortscript is free! I'm just learning how to use it now, but if anyone has any experience with it, hit me up with suggestions! Or better yet, write a script and show me how it works!
Can anyone tell me what registry changes are made when you switch from roaming to automatic?
I can't seem to compare registry backups taken with PHM RegEdit (some propietary format, and no export to text option!)
Mortscript to the rescue....
This is still not the most ideal solution, but it works for me.
I wrote two Mortscript scripts that simulate the key taps automatically. The downside to this is that you can't toggle it on/off, you need to run one program to force roam, and another one to put it back to automatic.
USE THESE AT YOUR OWN RISK!
If you have any bugs/questions/comments, let me know.
Requirements
MortScript:
You need to install the mortscript interpreter first.
http://www.sto-helit.de/downloads/mortscript/MortScript-4.0.zip
The zip file attached below contains two .mscr files:
Roam
Roam-NO
Pretty self explanatory what does what. You can rename them if you want, this just works for me.
Dishe said:
I wrote two Mortscript scripts that simulate the key taps automatically. The downside to this is that you can't toggle it on/off, you need to run one program to force roam, and another one to put it back to automatic.
Click to expand...
Click to collapse
If you wanted to, you could write a temp file or reg key to check if the setting is on or off. In fact, the file wouldn't even need any data in it, you could just check for it's existence. That way you only need one script. Hope that helps you out.
I havent been able to find (or pull) the ril.dll file from a Mogul Wm6 installation, but once you have that file, you should be able to dump the exports and use the RIL_* functions by ordinal. This has been done on GSM phones.
I haven't had time yet, but I believe someone has dumped the files from the newest update rom.
Dishe,
I took your script and applied my suggestion to it. I also wrapped it up in a standalone package, so if anyone else wants to run it, they won't need MortScript installed as the exe is in here. If you already have MortScript installed, you can just run the .mscr file instead of the .exe of the same name.
What it will do is run the prog, then check for the existence of the file "roam" in the script path. If it's not there, it will run your roam function and then create the file. If it already exists (meaning you turned on roaming only), then it run your function to turn off roaming and delete the temp file. Hope it helps you out.
EDIT: If for some reason the key presses do the wrong thing, you can just set your phone back to automatic and delete the "roam" file in the script path if it's there, then you're back in business.
EDIT2: Added a longer wait time (5 secs) for the Comm Manager, should allow it to work with more graphic intensive Comm Managers (like the Kaiser 10-button, tested).
Vinny75 said:
I havent been able to find (or pull) the ril.dll file from a Mogul Wm6 installation, but once you have that file, you should be able to dump the exports and use the RIL_* functions by ordinal. This has been done on GSM phones.
I haven't had time yet, but I believe someone has dumped the files from the newest update rom.
Click to expand...
Click to collapse
I know, qouting myself, but.. you don't need the ordinal, you can get the function by name from the dll, so far I am able to use RIL_Initialize and RIL_GetRoamingMode to call my pfResultCallback, but the value I am getting in reutrn isn't making sense, so have to figure that out. I am using a modified tstril util. I can post the changes if anyone wants to take a look.
Got the following for RIL_GetRoaming Mode
Mode Value
Sprint Only 0x00000001
Automatic 0x000000FF
Roaming Only 0x000000FE
Now using RIL_SetRoamingMode, I can set the Sprint Only mode, the other two throw a 0x80004005 HRESULT, I can use 0x00000002 and 0x0000003 (constants defined if you search the internet), and they don't throw an error, but they dont actually change any settings...
You can get tstril from here:
http://wiki.xda-developers.com/index.php?pagename=RIL
Expanded ril.h (not sure how accurate):
http://www.xs4all.nl/~itsme/projects/xda/ril/ril.h
Replace the DoRIL function in tstril.cpp with this code to test:
Code:
typedef HRESULT (*pfnRIL_Initialize)(DWORD, RILRESULTCALLBACK, RILNOTIFYCALLBACK, DWORD, DWORD, HRIL*);
typedef HRESULT (*pfnRIL_GetRoamingMode)(HRIL);
typedef HRESULT (*pfnRIL_SetRoamingMode)(HRIL, DWORD);
//HRIL g_hRIL;
HINSTANCE g_hDLL;
HRESULT g_hResult;
DWORD
DoRIL(LPVOID lpvoid)
{
HRESULT result;
DWORD dwNotificationClasses = 0xFF0000;
LRESULT lresult;
TCHAR szString[256];
SendMessage(g_hwndEdit, LB_RESETCONTENT, 0, 0);
lresult = SendMessage(g_hwndEdit, LB_GETHORIZONTALEXTENT, 0, 0);
SendMessage(g_hwndEdit, LB_SETHORIZONTALEXTENT, 1000, 0);
//result = RIL_Initialize(1, ResultCallback, NotifyCallback,
// dwNotificationClasses, g_dwParam, &g_hRil);
//wsprintf(szString, L"RIL Handle: %08X, result %08X", g_hRil, result);
//SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
g_hRil = NULL;
g_hDLL = LoadLibrary(L"ril.dll");
//HRESULT hResult = 0;
if (g_hDLL != NULL)
{
pfnRIL_Initialize lpfnRIL_Initialize = (pfnRIL_Initialize)GetProcAddress(g_hDLL, L"RIL_Initialize");
if (lpfnRIL_Initialize)
{
result = (lpfnRIL_Initialize)(1, ResultCallback, NULL /*NotifyCallback*/, 0 /*dwNotificationClasses*/, 0 /*g_dwParam*/, &g_hRil);
if (result == S_OK)
{
wsprintf(szString, L"Initialize RIL Handle: %08X, result %08X", g_hRil, result);
SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
pfnRIL_GetRoamingMode lpfnRIL_GetRoamingMode = (pfnRIL_GetRoamingMode)GetProcAddress(g_hDLL, L"RIL_GetRoamingMode");
if (lpfnRIL_GetRoamingMode)
{
g_hResult = (lpfnRIL_GetRoamingMode)(g_hRil);
wsprintf(szString, L"GetRoamingMode RIL Handle: %08X, g_hResult %08X", g_hRil, g_hResult);
SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
}
//pfnRIL_SetRoamingMode lpfnRIL_SetRoamingMode = (pfnRIL_SetRoamingMode)GetProcAddress(g_hDLL, L"RIL_SetRoamingMode");
//if (lpfnRIL_SetRoamingMode)
//{
// g_hResult = (lpfnRIL_SetRoamingMode)(g_hRil, 254);
// wsprintf(szString, L"SetRoamingMode RIL Handle: %08X, g_hResult %08X", g_hRil, g_hResult);
// SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
//}
}
}
//FreeLibrary(g_hDLL);
}
// while(1) {
// Sleep(100);
//// wsprintf(szString, L"%s",L"...");
//// SendMessage(g_hwndEdit, LB_ADDSTRING, 0, (LPARAM) szString);
// }
return 0;
}
Thanks for the work on those Mort Scripts!
Thank you!
wow, I haven't checked this thread in a while...
Vinny75, I haven't had time to play with this, but it looks like you've been making some progress... how far have you gotten with this?
The following values you should work for the second parameter of the RIL_GetRoamingMode and RIL_SetRoamingMode functions... they appeared to work on my phone
Mode RIL_GetRoamingMode RIL_SetRoamingMode
Sprint Only 0x00000001 0x00000001
Automatic 0x000000FF 0x00000004
Roaming Only 0x000000FE 0x00000005
I found the RIL_SetRoamingMode value in the following Registry Key
[HKEY_LOCAL_MACHINE\SOFTWARE\OEM\PhoneSetting\NetworkService]
Vinny75 said:
The following values you should work for the second parameter of the RIL_GetRoamingMode and RIL_SetRoamingMode functions... they appeared to work on my phone
Mode RIL_GetRoamingMode RIL_SetRoamingMode
Sprint Only 0x00000001 0x00000001
Automatic 0x000000FF 0x00000004
Roaming Only 0x000000FE 0x00000005
I found the RIL_SetRoamingMode value in the following Registry Key
[HKEY_LOCAL_MACHINE\SOFTWARE\OEM\PhoneSetting\NetworkService]
Click to expand...
Click to collapse
So would editing the registry be sufficient to change the roaming mode of the phone?
Did you compile an app to do this?
slightly off topic, but i think vinny75 might know the answer. id like to modify my alltel-based rom to give sprint only, automatic, roaming only options (alltel gives home only and automatic.) is ril.dll all that is needed from the sprint rom?
Dishe said:
So would editing the registry be sufficient to change the roaming mode of the phone?
Did you compile an app to do this?
Click to expand...
Click to collapse
I just compiled a quick and dirty app to test the values... the source is in my previous posts

[REQ]Remapping Camera shot key to volume button?

Hi there,
First of all I tried searching on google and also in this forum itself but I cant find anything related and so i decided to create a new thread on this.
If there anyway via tweaking the registry that i can make use of the volume key on the blackstone to take pictures instead of using the touchscreen? I believe this is possible
I find taking picture using a touchscreen is really difficult.
I read from http://wiki.xda-developers.com/index.php?pagename=HTC_Blackstone_Overview that this is possible by remapping the volume rocker.
Does any know how?
Will anyone be able to help?
I'm requesting this also. HTC should have made an option for us to choose for this from the beginning.
Request also here!
Sorry, I added this "remap volume rocker Solution" because I thought it was possible, but I actually didn't try it. So let's keep this thread to find a way to do it.
Remapping keys is through AE Button Plus or MobileMagic.
Right now we only have the choice of "touch" or "touch and hold" the virtual on-screen button to "auto-focus + shot".
We need to find out if there is any keyboard shortcut associated to that function.
I tried to use the "enter key" fonction remaped to Volume Up with AE Button Plus, but it didn't work.
Does the HTC Touch Pro have HTC's Camera application? maybe they know a keyboard shortcut? Let's ask.
I guess it will be possible.... just that we need the experts here to show us how to...
[APP] CameraButton
To solve this problem. I thought of a very simple solution:
Instead of us clicking the on-screen camera button, we need an application "CameraButton", which will click on the screen for us, then we just need to map a hardware button to that application.
Simple isn't it?
So here is the C# code for the CameraButton application:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace CameraButton
{
class Program
{
[System.Runtime.InteropServices.DllImport("coredll.DLL", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[System.Runtime.InteropServices.DllImport("coredll.DLL", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern bool SetForegroundWindow(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("coredll.dll")]
static extern bool SetCursorPos(int X, int Y);
[System.Runtime.InteropServices.DllImport("coredll.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
static void Main(string[] args)
{
IntPtr cameraHandle;
cameraHandle = FindWindow(null, "Camera");//search camera app
if (cameraHandle == IntPtr.Zero)// cannot find it then launch it
{
Process cam = Process.Start(new ProcessStartInfo("Camera.exe", ""));
//cameraHandle = cam.MainWindowHandle;
}
else // can find it then set position then click
{
//SetForegroundWindow(cameraHandle);// we assume we already have the focus on the camera app
SetCursorPos(240, 750 );//set position to the on-screen camera button
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
}
}
}
}
Why do I give the code rather than the binary?
Because unfortunately this code doesn't work (yet).
Let me explain a bit more:
This application doesn't need to keep running in the background, it just can do 2 things. Start the camera app if it's not already started, or just click at a specifically chosen position.
If I set the position to (0,0), my program will click at the upper-left corner of the screen, and hit the start button, therefore the start menu appears.
However if I try to click on the camera application, it doesn't have any effect!
Actually if I click somewhere else than the on-screen camera button, it should still react to the click: the little cross should move to the clicked place as part of the Touch Focus feature of HTC's camera app.
But here again, nothing happen.
Since it's my first app on WiMo, I might have done a mistake somewhere, but I can't see where.
Any XDA-developer can spot what's wrong with my code?
please see http://forum.xda-developers.com/showthread.php?t=471321
The Problem is the HTC Application, it blocks any keydown event
I did it Application released soon!
http://www.scilor.com/leocameraanykey.html

[Q] Need help with a program.

public void click(View view) {
String one = "one";
EditText et = (EditText)findViewById(R.id.editText1);
String entered_text = et.getText().toString();
if(et.getText().toString() == one){
TextView tv1 = (TextView)findViewById(R.id.textView1);
tv1.setText("Correct!");
}
else{
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText(one+entered_text); }
}
This is a code snippet extracted from my program, i didn't post the whole program because it wasn't necessary, as the program runs fine without any runtime exceptions.
So, the program when executed on eclipse doesn't show any errors and runs fine, but when run the "if" condition "et.getText().toString() == "one"" always returns false even when the "entered_text" is "one" i.e.; it never prints "correct!" and the code always prints "one+entered_text" that is the statement in the else clause. And the interesting thing is, if you enter "one" the output will be "oneone", that is the else statement.
Please help me where i went wrong.
Thanks in advance.
You're passing view argument in function so try initialize edit text with (EditText)view.findViewById(R.id.edittext);
panwrona said:
You're passing view argument in function so try initialize edit text with (EditText)view.findViewById(R.id.edittext);
Click to expand...
Click to collapse
Thanks for the reply.
I did what you said and got a runtime exception.
You're running it in fragment or activity?
panwrona said:
You're running it in fragment or activity?
Click to expand...
Click to collapse
Activity.
Are you initializing it in oncreate or somewhere else?
That's easy. Instead of == use text.equals(one)
String are not compared by mathematical signs
Sent from my XT1033 using XDA Premium 4 mobile app

Categories

Resources