How to get pass word in star symbols?

How to get pass word in star symbols?

A windows edit controller which enters pass word usually displays to star symbols.
But they’re just a property in the edit controller.
You can try this solution to get the content of edit controller.

 

Procedures are as below.
1.    Get a mouse’s position regularly with a timer.
2.    Use the function of “GetWindowLong” to get style which is current controller.
It will be an “EditControl” if it included the message of “ES_PASSWORD”, because the message of “ES_PASSWORD” is only for “EditControl”.
3.    Send a message of “EM_SETPASSWORDCHAR” to disable encrypting property in the “EditControl”.
4.    Get pass word quickly. XD
5.    Send a message of “EM_SETPASSWORDCHAR” again to enable encrypting property.

Whole actions will be completed before the window redrawing.
So you won’t be found by vague window.

 

 

There is a simple.

	void CGetPasswordDlg::Init()
{
    CWnd::SetTimer(0,300,CGetPasswordDlg::TimerProc);
}

void CGetPasswordDlg::TimerProc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
    POINT Point;
    
    ::GetCursorPos(&Point);
    HWND hwndCurr = ::WindowFromPoint(Point);
    
    
    // get class name.
    char szClass[255];
    ::memset(&szClass,0,sizeof(szClass));
    ::GetClassName(hwndCurr, szClass,255);
    
    
    // variable of password.
    char szPass[255];
    ::memset(&szPass,0,sizeof(szPass));
    
    
    // get style
    LONG lStyle = ::GetWindowLong(hwndCurr,GWL_STYLE);
    
    
    // check whether encrypting.     
    long lComp = lStyle & ES_PASSWORD;
    if(lComp!=0)    
    {
        // disable the encrypting property.
        ::PostMessage(hwndCurr, EM_SETPASSWORDCHAR, 0, 0);
        
        
        // get pass word.
        ::SendMessage(hwndCurr, WM_GETTEXT, 255, (LPARAM)szPass);
        
        
        // enable the encrypting property.
        ::PostMessage(hwndCurr, EM_SETPASSWORDCHAR, (WPARAM) '*', 0);
    }
    else    
    {
        ::SendMessage(hwndCurr, WM_GETTEXT, 255, (LPARAM)szPass);
    }
    
    CGetPasswordDlg* pDlg = (CGetPasswordDlg*)theApp.GetMainWnd();
    
    
    char szTitle[255];
    ::memset(&szTitle,0,sizeof(szTitle));
    ::sprintf(szTitle,"%s  hWnd=%d, x=%d, y=%d",TITLE, hwndCurr,Point.x, Point.y);
    
    
    pDlg->SetWindowText(szTitle);
    pDlg->mEdit.SetWindowText(szClass);
    pDlg->mPassWord.SetWindowText(szPass);

}

 

You can get pass word successfully as below.

image_thumb10