You need to call SetFocus right after you connect the threads in order for the SendInput to take place in the Notepad app:
Code:
  if(AttachThreadInput( GetCurrentThreadId(), threadID,true))
			  {
                                SetFocus(hTargetWnd);
				sendKey('G');
				AttachThreadInput(GetCurrentThreadId(),threadID,   false);
			  }