Home > Software engineering >  For the first time after the sendmessage, second to the different controls sendmessage not been upda
For the first time after the sendmessage, second to the different controls sendmessage not been upda

Time:09-30

Hi,

Want to be in the client system on the basis of development, the customer code is not visible to us in the system, we can only to simulate the mouse operation,
In a page has two customer system TAB box, in which a certain TAB box after page to modify the contents of the data, click on the save button to save the current data, and then click another TAB to switch, click save, to switch from the TAB when there will be no dialog prompt, if not, click save to switch from the TAB will appear when am I to give up a dialog prompt unsaved data,
And one more thing is, after click save, the status bar will be prompted, data is saved,

Behavior is expected now, click on the save button, the status bar will be prompted to save successfully, click the TAB to switch
//click "save" button
ContextReader. Instance. DoAction (btnShowInListEleID, "buttonclick", null);
//Thread. Sleep (1000);
if (! Auto314Util. WaitUntilText (txtStatus, "BZ save 処 finished Richard が し ま し た,", "==", 20))
{
Util. Log. The getInstance (). LogInfo (" Automation314 Click save button fails. ");
return 1;
}
//click "* * * TAB
"Auto314Util. ClickTab (tabsFrameHwnd, 1, "WFL", 4);
if (! Auto314Util. DelayBeforePageShow (WFL 314, 10))
{
return 1;
}


Public override String doAction (String id, String action, String param)
{
Try
{
Dictionary DicChildren=Util. FindWindow. FindAllChildWnd (hWndBizForm);
If (dicChildren!=null & amp; & DicChildren. Either ContainsKey (id))
{
IntPtr HWND=dicChildren [id];
,,,,,,,,,
If (action=="buttonclick")
{
WinAPI. SendMessage (HWND, BM_CLICK, 0, null);
Util. Log. The getInstance (). LogInfo (" Button Click on ElementID: "+ id);
}
}
The else
,,,,,,,,
}


Public static void clickTab (IntPtr hWnd, int n, string text, int intRetryTime)
{
If (intRetryTime & gt; 0)
{
For (int I=1; I & lt;=intRetryTime; I++)
{
If (n & lt; 1)
return;
RECT rect;
Point endPosition=new Point ();
WinAPI. GetWindowRect (hWnd, out the rect);
EndPosition. X=the rect. Left + n * 80;
EndPosition. Y=the rect. Top + 10;
WinAPI. SetCursorPos (endPosition. X, endPosition. Y);
//to simulate mouse click
WinAPI. Mouse_event (MouseEventFlag. LeftDown, 0, 0, 0, UIntPtr. Zero).
WinAPI. Mouse_event (MouseEventFlag. LeftUp, 0, 0, 0, UIntPtr. Zero).
WinAPI. Mouse_event (MouseEventFlag. LeftDown, 0, 0, 0, UIntPtr. Zero).
WinAPI. Mouse_event (MouseEventFlag. LeftUp, 0, 0, 0, UIntPtr. Zero).
Auto314Util. DelayBeforePageShow (" 314 WFL ", 5);
If (EventListener. CurContext. AppID=="* * *" & amp; & EventListener.curContext.Com ponentID=="* * *")
{
Util. Log. The getInstance (). LogInfo (" Auto314Util Click the Tab "+ I +" times before page shows up. * * * ");
return;
}
}
Util. Log. The getInstance (). LogInfo (" Auto314Util Click Tab: "+ intRetryTime +" times but page * * * did not show up in ");
}
}

But the question is: after the click save button, the status bar has been updated, the log also shows that the button is clicked, but click TAB will prompt me if I have to give up the current data, it feels like click save button on the form did not get the update in time, click the TAB or think there is no point to save?
I also added a sleep before click TAB, sleep 5 s are still won't do,


You know why? What's the solution?

CodePudding user response:

When you are processing the message, plus message loop,

The best thing to do is put in a your own thread to execute,
Don't lock the message thread,

CodePudding user response:

Can you say detail, plus a message loop is what mean?

What is the reason there appear this kind of situation

CodePudding user response:

Fyi:
 # pragma comment (lib, "user32") 
#include
#include
#include
#include
Char datestr [16].
Char timestr [16].
Char MSS [4].
Void the log (char * s) {
* struct tm now;
Struct timeb TB;

Ftime (& amp; TB);
Now=localtime (& amp; TB. Time);
Sprintf (datestr, "% d % % 4 d - 02-02 d", now - & gt; Tm_year + 1900, now - & gt; Tm_mon + 1, now - & gt; Tm_mday);
Sprintf (timestr, "02 02 02 % d: % d: % d", now - & gt; Tm_hour, now - & gt; Tm_min, now - & gt; Tm_sec);
Sprintf (MSS, "% 3 d", TB. Millitm);
Printf (" % s % s. % s % s ", datestr, timestr, MSS, s);
}
VOID CALLBACK myTimerProc1 (
HWND HWND,//handle of the window for the timer messages
UINT uMsg,//WM_TIMER message
UINT idEvent,//timer identifier
DWORD dwTime//the current system time
) {
The log (" In myTimerProc1 \ n ");
}
VOID CALLBACK myTimerProc2 (
HWND HWND,//handle of the window for the timer messages
UINT uMsg,//WM_TIMER message
UINT idEvent,//timer identifier
DWORD dwTime//the current system time
) {
The log (" In myTimerProc2 \ n ");
}
Int main () {
int i;
MSG MSG.

SetTimer (NULL, 0, 0100 myTimerProc1);
SetTimer (NULL, 0, 0200 myTimerProc2);
for (i=0; I<20; I++) {
Sleep (500);
The log (In the main "\ n");
If (GetMessage (& amp; MSG, NULL, 0, 0)) {
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}

}
return 0;
}
//the 2012-07-26 17:29:06. 375 In the main
//the 2012-07-26 17:29:06. 875 In myTimerProc1
//the 2012-07-26 17:29:07. 375 In the main
//the 2012-07-26 17:29:07. 875 In myTimerProc2
//the 2012-07-26 17:29:08. 375 In the main
//the 2012-07-26 17:29:08. 375 In myTimerProc1
//the 2012-07-26 17:29:08. 875 In the main
//the 2012-07-26 17:29:08. 875 In myTimerProc1
//the 2012-07-26 17:29:09. 375 In the main
//the 2012-07-26 17:29:09. 890 In myTimerProc2
//the 2012-07-26 17:29:10. 390 In the main
//the 2012-07-26 17:29:10. 390 In myTimerProc1
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related