Tuesday, April 15, 2008

Thursday, April 03, 2008

Using The Microsoft UI Automation Library to Drive UI Automation

The UI Automation Library is included in the .NET Framework 3.0. The concept seems to be straightforward. Every UI control is an "AutomationElement" which can be found through searching from the Parent "AutomationElement". The top AutomationElement is defined as the "RootElement", which is the Desktop. Another way to get the AutomationElement Object to a given Window is by starting a "Process", and then using the Process MainWindowHandle to get the AutomationElement object.

The code shown below is basically a test that Invoke Notepad, Enters an input text, and then it compares with the text which is read from Text property of the Notepad Text Field, and then closes Notepad without saving.
using System;
using System.Windows.Automation;
using System.Diagnostics;
using System.Threading;
using System.Collections.Generic;
using System.Text;

namespace UIAuto_01
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting Notepad!!!");

// #1 Start Notepad
//
Process notepadProcess = Process.Start("notepad.exe");
Thread.Sleep(500);
AutomationElement aeDesktop = AutomationElement.RootElement;

// #2 Find Notepad
//
AutomationElement aeNotepad = AutomationElement.FromHandle(notepadProcess.MainWindowHandle);

if (null == aeNotepad)
{
throw new Exception("Notepad not found!");
}
Console.WriteLine("Found Notepad !!!!");

// #3 Find Notepad Text Field Control
//
AutomationElementCollection aeAllTextBoxes =
aeNotepad.FindAll(TreeScope.Children,
new PropertyCondition(AutomationElement.ControlTypeProperty,
ControlType.Document));

if (0 == aeAllTextBoxes.Count)
{
throw new Exception("Notepad Edit field not found!!");
}

Console.WriteLine("Found Notepad Edit Field!!!!");

AutomationElement aeNotepadDoc = aeAllTextBoxes[0];

// #4 Type the input value
//
aeNotepadDoc.SetFocus();
string InputValue = "Hello World!";
System.Windows.Forms.SendKeys.SendWait(InputValue);

// #5 Get the Text from the Text Field
//
TextPattern tpNotepadDoc = (TextPattern)aeNotepadDoc.GetCurrentPattern(TextPattern.Pattern);
string ActualValue = tpNotepadDoc.DocumentRange.GetText(-1).Trim();

// #6 Compare input and actual
//
if (ActualValue == InputValue)
{
Console.WriteLine("Test Passed!");
}
else
{
Console.WriteLine("Test Failed: Expected={0} Actual={1}", InputValue, ActualValue);
}

// #7 Now close Notepad
//
WindowPattern wpNotepad = (WindowPattern)aeNotepad.GetCurrentPattern(WindowPattern.Pattern);
wpNotepad.Close();

// #8 Find The Save, Don't Save, Cancel Dailog
//
AutomationElement aeSaveDailog = findElement(aeNotepad, "Notepad", 10);
if (null == aeSaveDailog)
{
throw new Exception("Notepad Save dailog was not found!");
}

// #9 Find the "Don't Save" button and Click it
//
AutomationElement aeDontSaveBtn = findElement(aeSaveDailog, "Don't Save", 10);
if (null == aeDontSaveBtn)
{
throw new Exception("Notepad Don't Save Button was not found!");
}
InvokePattern ipDontSaveBtn = (InvokePattern)aeDontSaveBtn.GetCurrentPattern(InvokePattern.Pattern);
ipDontSaveBtn.Invoke();

// #10 Done
//
Console.ReadLine();
}

// Returns a Automation Element based on the parent AutomationElement, and caption.
//
private static AutomationElement findElement(AutomationElement parent, string caption, int timeout)
{
AutomationElement aeNew = null;
int numWaits = 0;
do
{
aeNew = parent.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.NameProperty, caption)
);
++numWaits;
Thread.Sleep(100);
} while (aeNew == null && numWaits < timeout);
return (aeNew);
}
}
}

Wednesday, April 02, 2008

iPhone full Arabic support is here



Requirements:
1- Firmware version 1.1.3/1.1.4
2- Arabic Keyboard setup following instructions provided by Tariq @ http://www.iphoneislam.com/
Setup instructions:
1- Add the following Source in your Installer. This can be done by going to the Sources Tab, and selecting the Edit button. Then, type the following URL in the source field: http://repo.aakqtr.com/
2- After the sources are refreshed, navigate to BiOsS Modz category in the Install Tab, and select: iPhone Arabizer 1.0 and choose Install.
3- Reboot the Phone
4- At this point Safari can render the Arabic text to any Arabic website, Email, Contacts, and Calander also support Arabic text at this point
5- Go to Settings > General > International > Language: and choose Arabic (this will change your UI Language)
6- Go to Settings > General > International > Region Format and Select Arabic and the Country.
Now you have Full Arabic support in the iPhone.

Friday, March 07, 2008

iPhone SDK Announcement: SEGA on the iPhone


From what was presented on the special keynote the SDK looks promising. The only bad part the entire toolset are native Mac OS tools, no Windows.


The most impressive thing is the SEGA game that was developed in two week period using the SDK, and the comment about the quality of the game is console quality not cell phone quality.


Friday, February 29, 2008

Monday, February 18, 2008

Scripting with C# Script

I have been playing cscript recently and I have found it a better alternative to Jscript. With C# Script you have the power of C# Language with the scripting capability. Hence, you don't have to compile your code when making modification to it.

You also have the option to create an executable out of the script.

Here is an example of accessing COM from C# Script. Notice the include tag on the first line

//css_prescript com(SYSINFO.SysInfo.1, SisInfoLib);
using System;
using SisInfoLib;
class Script
{
[STAThread]
static public void Main(string[] args)
{
SysInfoClass sysInfo = new SysInfoClass();
switch (sysInfo.ACStatus)
{
case 0:
Console.WriteLine("Not using AC power");
break;
case 1:
Console.WriteLine("Using AC power");
break;
default:
Console.WriteLine("Unknown AC power status");
break;
}
if (sysInfo.BatteryLifePercent != 255)
Console.WriteLine("Battery life " + sysInfo.BatteryLifePercent + "%");
else
Console.WriteLine("Battery charge status not known");
}
}

Thursday, December 27, 2007

Arabic iPhone




This is very promising. I have already installed the Arabic font, and Arabic keyboard and now I can read/write Arabic SMS, Email, and open most of Arabic web sites.


The good news, more programs are in in the works right now including prayer program, Quran, and more. For more information visit this website: www.iphoneislam.com.
Also, for more inforation about the full Arabic support watch the following video: http://www.iphoneislam.com/?p=22


Also, I have been experimenting with writing a prayer program myself, and I am planning to post it soon on this blog. The program will play the athan at prayer times, and it will display the prayer times for the current day. More information will follow soon.


I am planning to put it as open source under google code portal

Tuesday, October 30, 2007

Native iPhone Applications: the first Quran App


Developed by Zoosware. But first you have to install either AppTap, or AppSnapp.
Reviews to be followed soon. Stay tuned

Thursday, September 20, 2007

3D Virtual Desktop

Check it out

This brings back memories about when Central Point, the company behind PC Tools, released Central Point Desktop for Windows and introduced the idea of Virtual Desktops. At that time I got really used to it especially Windows 3.1 at that time did not have a useful desktop (it was called Program Manager)

Anyway, so far I am loving this tool, and will be evaluating for a possible purchase.

Monday, August 27, 2007

Quran (Arabic) for iPhone

This is basically scanned pages of the entire Quran in Arabic. It's very impressive. What we need is a WEB 2.0 version of Pocket Islam

To setup Quran for the iPhone, click on this link for instructions: Link

Tuesday, July 10, 2007

Can AT&T handle the iPhone?

Going to AT&T is totally a different experience from going to the apple store. Going to AT&T give you the feeling that AT&T is making guesses about how the iPhone is suppose to work and what feature have or not. For example, when I asked about whether the iPhone supports the stereo Bluetooth headset, .i.e. AD2P, their immediate answer was yes of course. So based on their answer I made the purchase from their store to find out that it is not supported yet. Also, when they were asked about their discount policy on the iPhone accessories I got many conflicting answers. One store told me that all iPhone related accessories do not qualify for corporate discount. While others told only products that are packaged with AT&T brand quality for discount.

In my overall experience dealing with AT&T, ,most of their employees are incompetent in handling advance Smart Phones and most of them do not have basic understanding of basic smart phone features. When I told one of the AT&T sales rep that I used my own SIM card instead of the one that came with the device he was very surprised that it worked and he insisted that the iPhone will not with any other SIM card other than the one that came with it. They are not aware that all SIM cards are standards and since the iPhone is locked to AT&T as long as you have an existing AT&T SIM the activation process will work without any problems. No wonder why people were having problems activating their phones.

I think it would have been a good idea for Apple to provide a full training to the AT&T sales rep in using the iPhone. In additions, Apple needs to train AT&T in general how to interact with customers. When I walk into the AT&T I feel like I am walking into a mechanic shop. Where, when I walk into the Apple store I feel I am walking into a high tech Art Museum. Totally different experience.

Monday, July 02, 2007

I love my iPhone, here are my top 5 feature requests

  1. Support for MS Exchange Push Technology. including support for Hotmail
  2. IM client support for MSN, Yahoo, Google Talk, AOL, ...etc
  3. Video recording
  4. Media transfer via Bluetooth
  5. Arabic Support in the Safari Browser.

    Thats it :)

Saturday, June 30, 2007

I have the iPhone now and I hate it :(

I really miss my 8525 that I sold last week in order to buy this phone.

So far this is my second day with the iPhone and I hate it so far. Here are the reasons:-

  1. Why can't I transfer photos, sounds to another phone using the Bluetooth.
  2. NO IM. Most phones, even low end phones have IM built in.
  3. No support with Exchange Mail, unless it's MAPI? Why?
  4. Broweser does not support Arabic text.
  5. The Internet browsing via Edge is exermly slow

I am going to give my self another 3 days to see if I change my mind. I hope I will since I have spent $600.

Monday, June 11, 2007

Google: this is how to disable Vista Desktop Search Index

It is totally untrue the only way to turn off Local Desktop search is by disabling the Windows Search Service. Here are the steps:-

  1. Start > Control Panel > Indexing Options
  2. Modify > Show All Locations
  3. Now Uncheck all the locations currently check
  4. Uncheck the Offline files and Outlook if selected.
Google claim that Vista does not allow third party Desktop search applications to install / run is misleading.