Programmatically send keystrokes to active current window in Windows

Here is the code to send keys (key strokes) to active current application in Windows using C++/Win API.

void SendKey(WORD wVkey)
	INPUT inputs[2];
	inputs[0].type = inputs[1].type = INPUT_KEYBOARD;
	inputs[0].ki.dwExtraInfo = inputs[1].ki.dwExtraInfo = 0;
	inputs[0].ki.wVk = inputs[1].ki.wVk = wVkey;
	inputs[0].ki.dwFlags = 0;
	inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;
	SendInput(2, inputs, sizeof(INPUT));

Get size (rectangle) of complete virtual screen (all display monitors together)

Here is the code to get the complete virtual screen rectangle that includes all display monitors. Code is in C++/MFC.

//gets the coordinates of the complete virtual screen which is includes all the monitors present
CRect GetVirtualScreenRect()
	CRect rcVirtualScreen;
	rcVirtualScreen.left = GetSystemMetrics(SM_XVIRTUALSCREEN); = GetSystemMetrics(SM_YVIRTUALSCREEN);
	rcVirtualScreen.right = rcVirtualScreen.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
	rcVirtualScreen.bottom = + GetSystemMetrics(SM_CYVIRTUALSCREEN);
	return rcVirtualScreen;

Check if email address is valid in C++/MFC

Here is the C++/MFC code to check if an email address is valid. 
bool IsEmailAddressValid(CString emailAddress)
	if (emailAddress.IsEmpty()) return false;
	int idx;
	CString rightPart;
	idx = emailAddress.Find(_T('@'));
	if (idx == -1) return false;
	//is the first character @?
	if (idx == 0) return false;
	rightPart = emailAddress.Right(emailAddress.GetLength() - idx - 1);
	idx = rightPart.Find(_T('.'));
	if (idx == -1) return false;
	//character immediately after @ is .?
	if (idx == 0) return false;
	//is there only period?
	if (rightPart.GetLength() == 1) return false;
	///is the last character period and no characters after that?
	if (rightPart.GetLength() - 1 == idx) return false;
	return true;

Convert array/list to string using a separator in C++ (MFC)

Following is the code to convert array to string using a specific separator. Language used is C++ using MFC (Microsoft Foundation Classes).

This function can trim each term in the array and also ignore blank (empty) string.

You can easily modify it for list or any other similar collection class.

void ArrayToString(CAtlArray<CString> & arrValue, CString & strValue, CString strSeparator
					, BOOL bTrim/*=TRUE*/, BOOL bIgnoreEmptyString/*=TRUE*/)
	int i;
	CString strItem;
	//append all strings with ; as separator
		strItem = arrValue[i];
		if (bTrim)
		if (bIgnoreEmptyString)
			if (strItem.IsEmpty())
		strValue += strItem;
		if (i < (int(arrValue.GetCount())-1))
			strValue += strSeparator;

Setting reminders saves a lot of money and makes life smoother

Today, I am going to highlight on a very simple fact. In today’s age of technology and smart phone, I strongly suggest that you use right apps to make your life smoother. An app that would help you to write quick notes and set reminders can really keep you stress free “if” you learn to use it timely and consistently.

I am using Notezilla – sticky notes and reminders app. Not because I wrote that myself, but because it has turned out to be a really cool utility app. Because it syncs between iPhone/Android devices and your Windows PCs. So, all your notes and reminders are always with you. This is essential since you need to be reminded any time and any where.

Here is how a notes and reminders app can help you save money and tedious effort.

  1. Set reminders to monthly phone bills. If you miss this, you may end up paying penalty.
  2. Set reminders to pay credit card bills. Now, the non-payment charges for this can be really high.
  3. Remind yourself to pay insurance premiums every year.
  4. We often miss out on taking regular data backups. Set reminders to take necessary backups. Or automate it using Copywhiz.
  5. If you have extra money in your bank account, set reminder to invest it at the right place. Investing money at the right time can earn you more interest.
  6. Jot down all the important numbers for quick reference to save time: Example: Tax id, bank account number, passport number, social security number, insurance policy numbers, GST number and the list goes on.
  7. If you are maintaining equipments such as inverter/UPS batteries, you can set a reminder so that you can extend their life.
  8. Set reminders to call the service men for your car, air conditioner (AC), room heater and various other day-to-day machinery.
  9. If want to stop renewal of a subscription at a particular time, you can set a reminder so that you don’t get charged accidentally. Avoid unnecessary hassle.
  10. If you have any deadline to buy or sell an investment, it is best to set a reminder.
  11. Often, the government of your country would have deadlines to pay taxes, file income tax returns, pay advanced tax etc. Save yourself from penalty by noting them down in an app and setting reminders.
  12. And the list goes on. You can think of other creative ways of setting reminders for both trivial and important life tasks.

Share your ideas of using a notes & reminder app effectively to make life better and more productive. Add your comments below.

Thanks. You may want to check out my product Notezilla – sticky notes and reminders apps for Windows and phones.


Looking for Sqlite Net PCL for your Xamarin project?

The phone app for Notezilla is created using Xamarin Forms. I like the way Xamarin Forms has grown. It works pretty well.

If you are looking for SQlite .Net PCL library, you might find multiple. But I will tell you which one is good.

For last few years I had used Sqlite.Net PCL and Sqlite-Net Extensions in my app. While I was debugging performance issue in the iOS version of my app, I found that the performance lag was due to a single linq query. It used to take 7 seconds. Xamarin Forms list view which listed our records was performing too slow. This was the case only in iOS. Not in Android.

So I looked for an alternative. And finally found the original Sqlite-Net-PCL project that is being maintained till date. I implemented Sqlite-Net-PCL and found that the same linq query executed in less than 1 second. This was a great deal for me.

In short, use Sqlite-Net-PCL. Do not use Sqlite.Net PCL because it is slow and it is not being maintained.

Sqlite-Net Extensions is dependent on Sqlite.Net PCL. Fortunately, we weren’t using Sqlite-Net Extensions. So we could easily remove it from our project.


XLabs Xamarin Forms Labs – Label does not un-strikethrough in Android

If you are trying to use un-strike-through (remove strike through) a text in extended label of XLabs Xamarin-Forms-Labs , you may not see it working. This is a bug.

To fix it, I have added to else part in both in ExtendedLabelRenderer.cs of Android platform. This fixes it.

  if (view.IsUnderline)
            control.PaintFlags = control.PaintFlags | PaintFlags.UnderlineText;
            control.PaintFlags &= ~PaintFlags.UnderlineText;
        if (view.IsStrikeThrough)
            control.PaintFlags = control.PaintFlags | PaintFlags.StrikeThruText;
            control.PaintFlags &= ~PaintFlags.StrikeThruText;


XLabs Xamarin Forms Labs – Label does not show strikethrough on multi-line in iOS

If you are trying to use strike through property of XLabs Xamarin-Forms-Labs , you may not see the strike through work on labels having multiline (wrapped text). This is a bug.

To fix it, add the following line after setting this.Control.AttributedText = new NSMutableAttributedString in the file ExtendedLabelRendered.cs

 ((NSMutableAttributedString)this.Control.AttributedText).AddAttribute (
                UIStringAttributeKey.BaselineOffset, new NSNumber(0) , new NSRange (0, view.Text.Length));


Why Google Chromecast is better than Set Top Box (TataSky etc)

Six months back I moved from TataSky to Google Chromecast! What an amazing relief! I find several advantages of using TV via the Internet over normal Set Top Box like TataSky, DishNet, Airtel Digital TV, Videocon DTH etc.

For several years I was looking for some technology that will allow me to restrict TV by time slots. This is mainly for my kids, so that they don’t watch TV anytime they wish to and however long. I consider TV a slow poison. It takes away precious time, physical and mental health.

Here are the advantages of casting.

  1. The complete control is via the phone. Only if the kids get the phone, they get to watch TV.
  2. It is free! No monthly subscriptions! You are just using your existing broadband Internet bandwidth.
  3. More channel options. More apps providing hundreds of channels (Jio TV, Hotstar, YuppTV etc)
  4. Less commercial advertisements.
  5. Short commercial advertisements. A 30 minute TV program actually finishes in 20 minutes. We we save a lot of time and frustration due to length ads.
  6. Watch TV programs before their scheduled time. Since the same program is available at different time zones, you can watch a serial well before their Indian time table. Watch early, sleep early!
  7. There are more advantages…..I am unable to recollect. Will add them soon :)

StackOverflow like alternative Q & A system

In order to build a Question & Answer system like StackOverflow, for my website Conceptworld, I was looking for various alternatives.

The reasons behind building a Q&A website for our products were:

  1. SEO (Search Engine Optimization)
  2. Minimizing Support
  3. Provide customers with quick answers to frequent questions

Since year 2000 when we founded Conceptworld, we have received several thousand support queries. I wanted to put the best, frequently asked support queries into this Q&A website.

I found a long list on this stack exchange page but I wanted something that can be setup easily on my Windows based server (IIS). I am using shared hosting from Lunarpages.

Finally I found a fantastic Q&A system called Question2Answer. It is a PHP based free and open source platform which works so well. I have successfully set it up on our Conceptworld support page.

Question2Answer is as easy as setting up wordpress on any server. It has a huge community around it. Plus there are several plugins available to tweak the product to your needs.

If you are looking for a free Q2A platform that will work on Windows IIS based server, then I strongly recommend Question2Answer.

If you found this post useful, please like it by clicking on one of the social media buttons (facebook, twitter, google+) on top/left of this post.