大家好,
想在在客戶系統的基礎上開發,客戶系統的代碼對我們是不可見的,我們只能去模擬滑鼠操作。
在客戶系統的某一頁面有兩個tab框,在其中某一個tab框的內容頁面修改完資料后,點擊保存按鈕會對當前的資料進行保存,然后點擊另一個tab進行切換。 點擊保存后,進行tab切換的時候就不會有對話框提示,如果不點擊保存,進行tab切換的時候就會出現一對話框提示我是不是要放棄未保存的資料。
還有一點是,點擊保存后,狀態欄會提示,資料已保存。
現在期待的行為是,點擊保存按鈕, 狀態欄會提示保存成功,點擊tab切換
// click "保存" button
ContextReader.Instance.doAction(btnShowInListEleID, "buttonclick", null);
//Thread.Sleep(1000);
if (!Auto314Util.waitUntilText(txtStatus, "BZ保存処理が完了しました。", "==", 20))
{
Util.Log.getInstance().logInfo("Automation314 Click 保存 button fails.");
return 1;
}
// click "***" tab
Auto314Util.clickTab(tabsFrameHwnd, 1, "WFL", 4);
if (!Auto314Util.delayBeforePageShow("314WFL", 10))
{
return 1;
}
public override String doAction(String id, String action, String param)
{
try
{
Dictionary<String, IntPtr> dicChildren = Util.FindWindow.findAllChildWnd(hWndBizForm);
if (dicChildren != null && dicChildren.ContainsKey(id))
{
IntPtr hwnd = dicChildren[id];
。。。。。。。
if (action == "buttonclick")
{
WinAPI.SendMessage(hwnd, BM_CLICK, 0, null);
Util.Log.getInstance().logInfo("Button Click on ElementID:" + id);
}
}
else
。。。。。。
}
public static void clickTab(IntPtr hWnd, int n, string text, int intRetryTime)
{
if (intRetryTime > 0)
{
for (int i = 1; i <= intRetryTime; i++)
{
if (n < 1)
return;
RECT rect;
Point endPosition = new Point();
WinAPI.GetWindowRect(hWnd, out rect);
endPosition.X = rect.Left + n * 80;
endPosition.Y = rect.Top + 10;
WinAPI.SetCursorPos(endPosition.X, endPosition.Y);
//模擬滑鼠雙擊
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("314WFL", 5);
if (EventListener.curContext.AppID == "***" && EventListener.curContext.ComponentID == "***")
{
Util.Log.getInstance().logInfo("Auto314Util Click Tab " + i + " times before page ***shows up.");
return;
}
}
Util.Log.getInstance().logInfo("Auto314Util Click Tab: " + intRetryTime + " times but page *** did not show up.");
}
}
但問題是:點擊保存按鈕完了之后,狀態欄也得到了更新,log也顯示按鈕是被點擊了的,但是點擊tab的時候還是會提示我是否放棄當前的資料。 感覺好像點擊保存按鈕的狀態沒有及時得到更新,點擊tab還是認為沒有點保存?
我在click tab之前也加了sleep了,sleep 5s都還是不行,
大家知道這是為什么嗎?有什么解決方案嗎?
uj5u.com熱心網友回復:
在你處理訊息的時候,加上訊息回圈。最好的辦法就是放在一個你自己的執行緒中去執行。
不要鎖死訊息執行緒。
uj5u.com熱心網友回復:
可否再說的詳細一點,加上訊息回圈是什么意思?還有出現這種情況的原因是什么呢
uj5u.com熱心網友回復:
僅供參考:#pragma comment(lib,"user32")
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>
#include <windows.h>
char datestr[16];
char timestr[16];
char mss[4];
void log(char *s) {
struct tm *now;
struct timeb tb;
ftime(&tb);
now=localtime(&tb.time);
sprintf(datestr,"%04d-%02d-%02d",now->tm_year+1900,now->tm_mon+1,now->tm_mday);
sprintf(timestr,"%02d:%02d:%02d",now->tm_hour ,now->tm_min ,now->tm_sec );
sprintf(mss,"%03d",tb.millitm);
printf("%s %s.%s %s",datestr,timestr,mss,s);
}
VOID CALLBACK myTimerProc1(
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
) {
log("In myTimerProc1\n");
}
VOID CALLBACK myTimerProc2(
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
) {
log("In myTimerProc2\n");
}
int main() {
int i;
MSG msg;
SetTimer(NULL,0,1000,myTimerProc1);
SetTimer(NULL,0,2000,myTimerProc2);
for (i=0;i<20;i++) {
Sleep(500);
log("In main\n");
if (GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
//2012-07-26 17:29:06.375 In main
//2012-07-26 17:29:06.875 In myTimerProc1
//2012-07-26 17:29:07.375 In main
//2012-07-26 17:29:07.875 In myTimerProc2
//2012-07-26 17:29:08.375 In main
//2012-07-26 17:29:08.375 In myTimerProc1
//2012-07-26 17:29:08.875 In main
//2012-07-26 17:29:08.875 In myTimerProc1
//2012-07-26 17:29:09.375 In main
//2012-07-26 17:29:09.890 In myTimerProc2
//2012-07-26 17:29:10.390 In main
//2012-07-26 17:29:10.390 In myTimerProc1
//2012-07-26 17:29:10.890 In main
//2012-07-26 17:29:10.890 In myTimerProc1
//2012-07-26 17:29:11.390 In main
//2012-07-26 17:29:11.890 In myTimerProc2
//2012-07-26 17:29:12.390 In main
//2012-07-26 17:29:12.390 In myTimerProc1
//2012-07-26 17:29:12.890 In main
//2012-07-26 17:29:12.890 In myTimerProc1
//2012-07-26 17:29:13.390 In main
//2012-07-26 17:29:13.890 In myTimerProc2
//2012-07-26 17:29:14.390 In main
//2012-07-26 17:29:14.390 In myTimerProc1
//2012-07-26 17:29:14.890 In main
//2012-07-26 17:29:14.890 In myTimerProc1
//2012-07-26 17:29:15.390 In main
//2012-07-26 17:29:15.890 In myTimerProc2
//2012-07-26 17:29:16.390 In main
//2012-07-26 17:29:16.390 In myTimerProc1
//2012-07-26 17:29:16.890 In main
//2012-07-26 17:29:16.890 In myTimerProc1
//2012-07-26 17:29:17.390 In main
//2012-07-26 17:29:17.890 In myTimerProc2
//2012-07-26 17:29:18.390 In main
//2012-07-26 17:29:18.390 In myTimerProc1
//2012-07-26 17:29:18.890 In main
//2012-07-26 17:29:18.890 In myTimerProc1
//2012-07-26 17:29:19.390 In main
//2012-07-26 17:29:19.890 In myTimerProc2
uj5u.com熱心網友回復:
我做過一個類似的專案是注入進去實作的uj5u.com熱心網友回復:
樓主實作了嗎???遇到同樣問題了
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/99735.html
標籤:界面
上一篇:在vc環境下做影像邊緣的提取。
