[Q] how to ping a host whether is up or down - IDEs, Libraries, & Programming Tools

Hello
Dear Friends,
In my app there is a textbox and button. i want to apply a code behind the button clicking, that whether the host is written in textbox is "up or down" before browsing it, in next activity.
If the host is up then, my next activity will open the host, there is a webview that will show the host, that is written in textbox. The host should be reachable otherwise a toast message will appear and show the host is unreachable or down.
Thanks and regards
Your truly
Hasnain Ahmad

Related

Simulate touchscreen tap, or add ShortCut key.

Hello,
I have such a problem. But first I will explain why I have that problem.
In company we are using a PocketPC with Windows Mobile 2002. And have only one apllication for work.
When connecting to Server we need to tap the left bottom corner of the screen.
Many of workers tap with diferent objects like cutters, pens, not with Stylus, so the left bottom corner become bad in 1-2 months, till the time I can't do nothing, just changing the screen.
So. There is a posibility to implement somehow a ShortCut to that menu, to avoid taping that part of screen? (Because after that in program we use only buttons.)
(Note: I have no source code for tha app.)
Any kind of help will be apreciate.
Thank you much!
It's easy to simulate screen tap by code.
Do you have experience programming in C/C++?
If so all you have to do is write a little app that does the following:
Code:
HWND hWnd; //window handle
hWnd = FindWindow(L"BUTTON", L"Connect to server"); //this text is just an example
SendMessage(hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(5, 5)); //actually simulates the click
Then you can assign this app to a hardware button using device settings or put a shortcut to is in the start menu.
I don't know of any ready apps to just simulate a click, but there was a thread around here somewhere on a virtual mouse app for PPC. It's free so try searching for that. (Sorry, don't remember the link).
Good luck.
Thank you man.
I'll try this...
levenum said:
It's easy to simulate screen tap by code.
Do you have experience programming in C/C++?
If so all you have to do is write a little app that does the following:
Code:
HWND hWnd; //window handle
hWnd = FindWindow(L"BUTTON", L"Connect to server"); //this text is just an example
SendMessage(hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(5, 5)); //actually simulates the click
Then you can assign this app to a hardware button using device settings or put a shortcut to is in the start menu.
I don't know of any ready apps to just simulate a click, but there was a thread around here somewhere on a virtual mouse app for PPC. It's free so try searching for that. (Sorry, don't remember the link).
Good luck.
Click to expand...
Click to collapse
So I have not so many experience in C++ and nor in Visual Studio.
Can you provide me with full c++ code for Visual Studio 2005?
Thank you in advance.
Here is another way. Just create a simple project in vis studio ( I am not using 2005 so I cant tell you what its called, if all else failes use the "hello world" option). Open the main .cpp file and after the includes delete everything. Paste this in....
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE,61439,1638,0,NULL);
return 0;
}
Then build the exe. Make a shortcut to the exe on your device and place it in the windows\start menu folder. When the user taps the shortcut the cordinates specified will get a mouse down message, not all ppc programs will rspond to this message but most bought software I have do.
As it is, this will hit the close button on a 240*320 display. To vary the target location see this from the documentation:
If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner.
...So you may need to play with it to hit the spot.
If that fails then just replace the
mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE,61439,1638,0,NULL);
with levenum's code putting the name of the window you are talking about in instead of "Connect to server" to send the normal WM_LBUTTONDOWN message to that window.
OdeeanRDeathshead, your method seems to work. I did it and application works proprely on my Magician.
But now the question is: I need that program for a PocketPC 2002 platform. How to do this in VS2005, can explain me anyone?
Thank you in advance.
Actually, you can't write apps for WM2002 using VS2005.
You need eMbedded Visual C++ 3. It is available free from Microsoft, just search the site. You will also need to install Pocket PC 2002 SDK. (also free on MS site)
levenum said:
Actually, you can't write apps for WM2002 using VS2005.
You need eMbedded Visual C++ 3. It is available free from Microsoft, just search the site. You will also need to install Pocket PC 2002 SDK. (also free on MS site)
Click to expand...
Click to collapse
Ok.. all this I installed.
I will try to do the program there. But problem become more complicated.
My PDA's are not HTC. They are modified by SYMBOL company. So.. I realized that i have no HARD BUTTON.
In start menu I can't let the application, only because START is not accessible. The only program is that for work and it's full screen.
The PDA have a keyboard.
The question is: it is possible to do in program a HOT_KEY combination, and run MOUSEEVENTF_LEFTDOWN only when HOT_KEY combination was pressed.
I understand that program must remain in memory to intercept that.
Do you mean that there are no buttons on your device, only a keyboard?
Doesn't matter really because as far as windows is concerned keystrokes from device buttons and full keyboard are handled the same.
Sorry I am not really familiar with setting up hot keys, I think your app window needs to have input focus for that to work.
There is a function called SetWindowsHookEx that lets you hook all keyboard events so they will pass through your function. You can then have a small app in background (without UI) that will monitor any key combination you want and simulate the tap when necessary.
levenum said:
Do you mean that there are no buttons on your device, only a keyboard?
Click to expand...
Click to collapse
Yeah.... it looks like this http://www.symbol.com/PDT8100
I do not know if you can throw some cash at your problem but SKScHeMa from www.s-k-tools.com can wait for an application to start then execute a script. In the script you can simulate both tap and tap and hold actions.
Hope that helps.
Regards cjb.
One of those buttons must correspond to the buttons on the normal ppc. It would be overkill too write an app to run constantly just to redirect one tap. Do you have the opportunity to ever start the unit without the fullscreen program running, if so you could experiment with the button assignments to find the correct one. If the author of the custom software on the thing was half good they could have disabled those buttons assignments while its running, but if they didn't thats the best solution.
If that fails perhaps a program to run after powerup and ask if the user wants to connect to the server could work. It could show for 10 seconds then end. There was a thread here somewhere about programs starting on powerup but I can't seem to find it now.
edit:
I read the specs and it has two "side scan keys", I bet they are your buttons waiting to be reassigned!
OdeeanRDeathshead said:
One of those buttons must correspond to the buttons on the normal ppc. It would be overkill too write an app to run constantly just to redirect one tap. Do you have the opportunity to ever start the unit without the fullscreen program running, if so you could experiment with the button assignments to find the correct one.
Click to expand...
Click to collapse
No one of that buttons corespond to CALENDAR or CONTACTS or CAMERA or RECORD button.
I can start the device without work program. Also I don't need to simulate tap, because I own my PDA and have knoweledge how to use it.
Users don't know much... for that i disables all. Only Work program in fullscreen mode without START MENU.
I read the specs and it has two "side scan keys", I bet they are your buttons waiting to be reassigned!
Click to expand...
Click to collapse
This is a PDA with barcode scanner. That 2 buttons named "side scan keys" are only for SCANNER and are not programable.
TO ALL: Thank you for your support![/quote]
cjb said:
I do not know if you can throw some cash at your problem but SKScHeMa from www.s-k-tools.com can wait for an application to start then execute a script. In the script you can simulate both tap and tap and hold actions.
Hope that helps.
Regards cjb.
Click to expand...
Click to collapse
Thanks for help.
I can't do any investitions in that.
More of that it's not the same I need. I need to simulate this not only at start, also during work.
Yes, so make the prgram asking if a connect is needed run when the power button is pressed. If the user needs to connect they press off then on then the window comes up asking if a simulated tap is needed (I do not mean reset). If the full off is not desireable then dose your unit change the brightness when the power button is held down? If so, and if it is using the standard name for the named event to signal brigtness changes then you could make the tap simulate program run all the time in a loop but waiting for the brigtness change event. Waiting will take up almost no processor time and the program is so small it takes up almost no memory! The user just has to hold the power button for several seconds and the your window will pop up. The down side is that your app will also have to save then restore the brigtness settings so the user dose not need to manualy reset the brigtness level.

Kiosk mode & some questions

Hi,
my application on Windows Mobile 5.0 shall run in kiosk mode. Therefore, I've disabled the TaskBar and did some other stuff. Basically, it works great, but I'm still having a few problems:
1. When I hide the taskbar, also the "OK" Button which is needed by some dialogs gets hidden. Therefore, when the user e.g. wants to change communication/GPRS settings, there is no way to accept the changes or close the regarding dialogs. (I have to use these sort of things provided by the operating system - thus, the OS is not entirely hidden).
Is there any possibility to simulate the TaskBar's OK button within my own application? (E.g., by sending a certain Windows-Message indicating the OK-Button pressed?)
Or, alternatively, is it possible to just hide some parts of the TaskBar (e.g., the Start Button) and keep the OK button, clock, and GSM status visible??
2. Somestimes, there appears a system-notification window, e.g. notifying the user about establishing a GPRS connection, or regarding failures. Is it possible to intercept these dialogs and to hide them, or just to disable them such that the user can see it, but tapping the "Cancel" or "Settings" button won't cause any action?
I'm working with Visual Studio 2005/windows Mobile 5.0 SDK in visual c++ and I'm using the HTC ARTEMIS device
Kind regards,
Günther
1. You can send WM_COMMAND with wParam = IDOK.
It must work, because it's how app handle it!
Is there anything I have to consider when sending WM_COMMAND system-wide? A simple PostMessage(NULL, WM_COMMAND,...) seems not to work. Do you see any possibility to get a Windows handle to the active application that should receive the WM_COMMAND message?
Or do you have any idea how applications tell the TaskBar to show the OK or Cancel button? I think this happens via system-wide windows messages, doesn't it? But which messages, and how to intercept them???
Any help is still highly apprechiated (it seems that nobody else did ever have this problem, also in various fora I couldn't yet get an answer... )
I have the same problem with the ok buttom. My PDA have 1 buttom for the camera, so I use this buttom like an OK buttom, for now.
But I´m still trying to make the ok buttom be operacional on the blocked taskbar.

HButton for smartphone

Hi,
I created HButton for smartphones. BUT I have no smartphone so I developed it on smartphone emulator.
I will be very gladly, if there is someone who can test it.
Please note: Test it on your own risk - never been run on real smartphone.
thanks
Hundera
Great! While I have no time to test it right now, I'll frontpage the news if it turns out to be working!
when i get to the assign window, i get stuck there, don't know what's the next step
oldsap said:
when i get to the assign window, i get stuck there, don't know what's the next step
Click to expand...
Click to collapse
Hi,
I created it little messy. It has to be changed before official release.
* Using * assign it to any HW button. I don't know if there will be name and icon of selected button or just something like "unknown 40C1".
* Create list of applciations
* Left and right button select preferred application​* enter to add it to list​* Press OK.
thats all. Now you should be able to start application using HButton....
What now?
I managed to do almost everything:
I assigned applications to the list of button1,
I clicked on '*', and so
Assigned to (*) displays "Unknown 40C1"
When I run the application Button1 manually, the application I chose for Button1 is run.
But what now? What do I have to press to make the application run? What is button1? I tried all buttons, pressing for various lengths of time, but I can't get it to run.
Do I need to edit the registry so that the application "Button1" is assigned to some button?
Hi,
at first thanks for help.
"Unknown 40C1" means - there are registry part about this button. In SPh, there's missing names of buttons - so name is unknown.
I has no SPh, only emulator. I checked registry and there is all ok - only names are missing. All flags and path to applications that should be started are similar to pocketpc.
These registry settings are altered by my program so HButton1 should be started by button with code "40C1". What button it is - I really don't know. That's what I need to test.
But as you describe it, it looks like that these settings are ignored.... So Where is settings of button's behavior on smartphone?!?!
ghostwheel said:
I managed to do almost everything:
I assigned applications to the list of button1,
I clicked on '*', and so
Assigned to (*) displays "Unknown 40C1"
When I run the application Button1 manually, the application I chose for Button1 is run.
But what now? What do I have to press to make the application run? What is button1? I tried all buttons, pressing for various lengths of time, but I can't get it to run.
Do I need to edit the registry so that the application "Button1" is assigned to some button?
Click to expand...
Click to collapse
not totally sure
I'm no expert in this.
If I understand correctly, one way to do it is through links in the \windows directory,
so
\windows\short_MSG
is a link to the program called when the message button is pressed
\windows\short_Camera, and short_IE
are for camera and explorer button.
But I think there are also other places to set these. And some phones allow long_MSG,IE,Camera links for long button press - not mine.
I tried to copy the Button1 link to short_MSG, and that managed to run the first command in the list for button1, but not the next on a longer press. (And it still launched the message program first, so there must be a second place that determines what is launched...)
Maybe people in the smartphone forum will have more info...
All this was on an s620 WM6.1
just a few more comments
Now that I can get HButton to partially run, I have a few comments:
I'm not exactly sure why, but going from HBSetup to configure buttons 1 and 2 takes a really long time. HButtonTask is much shorter. Maybe it is because a list of all programs is generated, and this takes time? In any case, maybe one could display a message "please wait..." - the first time I thought the program had crashed.
Pressing left (instead of right) when the bottom selector in HButton1 setup shows <None> crashes the program (ArgumentOutOfRangeException)
In HButtonTask setup there are two arrows below Custom delay (I think to chose the delay), but no number is displayed, and pressing left-right only toggles the boxes.
<Start Menu> doesn't work. <Clock>, <Toggle BT>, <Quit>, <Today> do work. <Back> behaves a bit differently than the Back key - it switches between tasks, instead of screens - but that's ok and can be useful!
In the HButton1/2 setup screens, I would change the left softkey to "save" instead of "ok". Too often I pressed that button instead of the center/enter button to change the action on the list. Because it takes ~10 seconds to enter the screen again, it is quite annoying....
Hi
I am really interested in this project if is still under developement

Heed Help, How make simple blootooth??

hello, I am a student, I and my friend has the task of the teacher to create a tool that can be controlled by handpone android via bluetooth.
I made ​​a tool with ATMEGA microcontroller to turn off and turn on the electronic device.
tools and microcontroller has been completed. but I do not know how Constructing android app using bluetooth.:crying::crying::crying:
I have downloaded all the required programs eclipse, android SDK, ADT, Android SDK and AVD Manager to download all done.
I made the first Android Application Project
I enter 1 textview, 3 Button, and 2 toggle inside layout.
Here's a function of the layout :
1. button1, to connect bluetooth & pair bluetooth
2.1. Toggle Button1, if i press toggle1 to "ON" android send data "1ON" to my device for switch ON power suplay, if i press toggle1 to "OFF" android send data "1OFF" to my device for switch OFF power suplay.
2.2 Toggle Button2, if i press toggle2 to "ON" android send data "2ON" to my device for switch ON power suplay, if i press toggle2 to "OFF" android send data "2OFF" to my device for switch OFF power suplay.
why 1ON, 1OFF, 2ON, 2OFF? because I write such a program dimicrocontroler.
sample: if buffer = "1ON" then, if buffer = "2ON" then ......
3. button2, to disconnect bluetooth
4. button3, to show messagebox my name
5. textview = "Bluetooth Comm"
every body can help me? can you sample tutorial for my problem?
Thanks
Regards
BuayaLaut.
sorry i dont speak english with perfect.
buayagurun said:
hello, I am a student, I and my friend has the task of the teacher to create a tool that can be controlled by handpone android via bluetooth.
I made ​​a tool with ATMEGA microcontroller to turn off and turn on the electronic device.
tools and microcontroller has been completed. but I do not know how Constructing android app using bluetooth.:crying::crying::crying:
I have downloaded all the required programs eclipse, android SDK, ADT, Android SDK and AVD Manager to download all done.
I made the first Android Application Project
I enter 1 textview, 3 Button, and 2 toggle inside layout.
Here's a function of the layout :
1. button1, to connect bluetooth & pair bluetooth
2.1. Toggle Button1, if i press toggle1 to "ON" android send data "1ON" to my device for switch ON power suplay, if i press toggle1 to "OFF" android send data "1OFF" to my device for switch OFF power suplay.
2.2 Toggle Button2, if i press toggle2 to "ON" android send data "2ON" to my device for switch ON power suplay, if i press toggle2 to "OFF" android send data "2OFF" to my device for switch OFF power suplay.
why 1ON, 1OFF, 2ON, 2OFF? because I write such a program dimicrocontroler.
sample: if buffer = "1ON" then, if buffer = "2ON" then ......
3. button2, to disconnect bluetooth
4. button3, to show messagebox my name
5. textview = "Bluetooth Comm"
every body can help me? can you sample tutorial for my problem?
Thanks
Regards
BuayaLaut.
sorry i dont speak english with perfect.
Click to expand...
Click to collapse
This is simple.go through the bluetooth chat example in android sdk.modify it for making a serial connetion to a bluetooth module. Interface bluetooth module to controller. I have done this once. Its not that difficult
Sent from my Nexus 4 using Tapatalk

Search Database From A Web Server

I want my app to have a search function but instead of searching locally, I want to search from the data on my web server and return the data in a JSON format. The good thing is, I know how to do this but I'm not sure how can I implement an activity with this kind of interface and behavior.
Legends are as follow: (Please see the mockup image that I attached below)
Black - Action Bar
Blue - Activity Container
Red - Searching (Search input and button here)
Green - List View (Fetched data from the web server)
Basically I want the user to input their search key and when they press the search button, a loading image will appear while the data are being fetched, when the fetching is completed I want the fetched data to appear on the list view on the same activity.
Thank you and have a good day!
clonedaccnt said:
I want my app to have a search function but instead of searching locally, I want to search from the data on my web server and return the data in a JSON format. The good thing is, I know how to do this but I'm not sure how can I implement an activity with this kind of interface and behavior.
Legends are as follow: (Please see the mockup image that I attached below)
Black - Action Bar
Blue - Activity Container
Red - Searching (Search input and button here)
Green - List View (Fetched data from the web server)
Basically I want the user to input their search key and when they press the search button, a loading image will appear while the data are being fetched, when the fetching is completed I want the fetched data to appear on the list view on the same activity.
Thank you and have a good day!
Click to expand...
Click to collapse
Your red searching layout can either be done manually using a horizontal LinearLayout with an ImageButton and an EditText, or, in my view far easier, with a SearchView in the ActionBar. Head over to this documentation page to set it up! You'll then get a call to onNewIntent with the search query and use that to update your ListView from the server.

Categories

Resources