Calibration in ATM machines
-
Hi everyone, I have a question. Do anyone know how to detect calibration in ATM machines? I have a autoscript .exe file. When I run the file, it opens a dialog box having CAlibration button on it. When I hit the calibration button, it does the calibration and ends without showing that when it is done. So, what my problem is, I want to detect that calibration window and see when it closes. Your help will be appreciated. Thanks Preeti Preeti9
-
Hi everyone, I have a question. Do anyone know how to detect calibration in ATM machines? I have a autoscript .exe file. When I run the file, it opens a dialog box having CAlibration button on it. When I hit the calibration button, it does the calibration and ends without showing that when it is done. So, what my problem is, I want to detect that calibration window and see when it closes. Your help will be appreciated. Thanks Preeti Preeti9
-
Yes, Please help Thanks Preeti Preeti9
-
Yes, Please help Thanks Preeti Preeti9
Assuming it's running Windows (is it?), then you can use the standard techniques for any displayed window. For example: Use FindWindow to locate the dialog box. Periodically check if the window still exists (IsWindow). There are other methods to detect the process and when it closes provided that the process doesn't keep running after calibration is complete.
-
Assuming it's running Windows (is it?), then you can use the standard techniques for any displayed window. For example: Use FindWindow to locate the dialog box. Periodically check if the window still exists (IsWindow). There are other methods to detect the process and when it closes provided that the process doesn't keep running after calibration is complete.
Hi, Yes, its running on windows. I wrote a code that opens up the window , I mean completes calibration. Same as you said, use FindWindow to locate the dialog box. Its working properly but I don't know when does it completes the calibration. I am not able to detect when that window closes. I don't know how to use IsWindow. Can you give me more detail on that? Also, what other methods can you use to detect a process ? Thanks for your help. Waiting for more details. Thanks Preeti Preeti9
-
Hi, Yes, its running on windows. I wrote a code that opens up the window , I mean completes calibration. Same as you said, use FindWindow to locate the dialog box. Its working properly but I don't know when does it completes the calibration. I am not able to detect when that window closes. I don't know how to use IsWindow. Can you give me more detail on that? Also, what other methods can you use to detect a process ? Thanks for your help. Waiting for more details. Thanks Preeti Preeti9
IsWindow simply returns TRUE or FALSE if the specified window handle is a valid window or not. So, if it suddenly returned FALSE, obviously the window is no longer around. Example:
HWND hWnd = FindWindow(....);
while( true )
{
if( ! IsWindow(hWnd) )
break; // window is gone;
Sleep(1000); // wait a second for window to close
};This is the quick and crude method. Find the window handle and periodically poll to see if the window still exists. You can also do the same thing without polling by using a window hook. Lookup SetWindowsHook and CBTProc for more information. To wait for the process to complete rather than the window. You need to get a process handle that's associated with that window and wait for it to close. This method, of course, will only work if the process doesn't live on after the window is destroyed. Pseudo Example (error checking removed for brevity):
HWND hWnd = FindWindow(...);
DWORD ProcID;
DWORD ThrdID = 0;
HANDLE hProcess;ThrdID = GetWindowThreadProcessId( hWnd, &ProcID );
hProcess = OpenProcess( SYNCRONIZE, FALSE, ProcID );// Wait for the process to complete
WaitForSingleObject( hProcess, INFINITE );
CloseHandle(hProcess); -
IsWindow simply returns TRUE or FALSE if the specified window handle is a valid window or not. So, if it suddenly returned FALSE, obviously the window is no longer around. Example:
HWND hWnd = FindWindow(....);
while( true )
{
if( ! IsWindow(hWnd) )
break; // window is gone;
Sleep(1000); // wait a second for window to close
};This is the quick and crude method. Find the window handle and periodically poll to see if the window still exists. You can also do the same thing without polling by using a window hook. Lookup SetWindowsHook and CBTProc for more information. To wait for the process to complete rather than the window. You need to get a process handle that's associated with that window and wait for it to close. This method, of course, will only work if the process doesn't live on after the window is destroyed. Pseudo Example (error checking removed for brevity):
HWND hWnd = FindWindow(...);
DWORD ProcID;
DWORD ThrdID = 0;
HANDLE hProcess;ThrdID = GetWindowThreadProcessId( hWnd, &ProcID );
hProcess = OpenProcess( SYNCRONIZE, FALSE, ProcID );// Wait for the process to complete
WaitForSingleObject( hProcess, INFINITE );
CloseHandle(hProcess);Thanks for your help... I don't know but if I use here IsWindow, I am getting the same result as I was getting it earlier. I am sending you my code ....have a look and let me know is this correct to detect the calibration , I mean when that window closes. Here's the code: { CTouchScreenAPI* pTouch; HWND hCalWin; DWORD procId; HANDLE hProcess; DWORD dwWaitResult; pTouch = CTouchScreenAPI::Create(); if (pTouch) { if (pTouch->Init()) pTouch->Recalibrate(FALSE); else MessageBox(NULL, "Created touchscreen interface OK, but Init() failed", "Info", MB_OK); HWND hCalWin = ::FindWindow(pszABSPOINT_WND_CLASS_NAME, NULL); while( true ) { if( ! IsWindow(hCalWin) ) break; // window is gone; Sleep(1000); // wait a second for window to close }; GetWindowThreadProcessId(hCalWin, &procId); hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procId); while (1) { dwWaitResult = MsgWaitForMultipleObjects(1, &hProcess, FALSE, 30*1000, QS_PAINT); if (dwWaitResult == WAIT_OBJECT_0 + 1) { MSG xMsg; while (PeekMessage(&xMsg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&xMsg); DispatchMessage(&xMsg); } } else if (dwWaitResult == WAIT_TIMEOUT) { SendMessage(hCalWin, WM_CLOSE, 0, 0); TerminateProcess(hProcess, 0); break; } else dwWaitResult == WAIT_OBJECT_0; { //Calibration process completed; break; } } Thanks Preeti Preeti9
-
Thanks for your help... I don't know but if I use here IsWindow, I am getting the same result as I was getting it earlier. I am sending you my code ....have a look and let me know is this correct to detect the calibration , I mean when that window closes. Here's the code: { CTouchScreenAPI* pTouch; HWND hCalWin; DWORD procId; HANDLE hProcess; DWORD dwWaitResult; pTouch = CTouchScreenAPI::Create(); if (pTouch) { if (pTouch->Init()) pTouch->Recalibrate(FALSE); else MessageBox(NULL, "Created touchscreen interface OK, but Init() failed", "Info", MB_OK); HWND hCalWin = ::FindWindow(pszABSPOINT_WND_CLASS_NAME, NULL); while( true ) { if( ! IsWindow(hCalWin) ) break; // window is gone; Sleep(1000); // wait a second for window to close }; GetWindowThreadProcessId(hCalWin, &procId); hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procId); while (1) { dwWaitResult = MsgWaitForMultipleObjects(1, &hProcess, FALSE, 30*1000, QS_PAINT); if (dwWaitResult == WAIT_OBJECT_0 + 1) { MSG xMsg; while (PeekMessage(&xMsg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&xMsg); DispatchMessage(&xMsg); } } else if (dwWaitResult == WAIT_TIMEOUT) { SendMessage(hCalWin, WM_CLOSE, 0, 0); TerminateProcess(hProcess, 0); break; } else dwWaitResult == WAIT_OBJECT_0; { //Calibration process completed; break; } } Thanks Preeti Preeti9
A couple of things: 1. Does the pTouch->Recalibrate and/or CTouchScreenAPI::Create spawn another process? Or is the recalibrate function contained within your own process (separate thread maybe?) Does recalibrate return immediately? 2. You don't necessarily need to do both the IsWindow loop and the process loop. In any case you need to call GetWindowThreadProcessId before the IsWindow loop. Otherwise, what's the point? The window is gone so the call will always fail. 3. Don't use PROCESS_ALL_ACCESS unless you absolutely have to. Use the minimum security setting to get the job done. Depending on the circumstances and user's security level the call may fail trying for all access. SYNCHRONIZE is all you need for waiting on the handle. If you need to call TerminateProcess then add PROCESS_TERMINATE as well. 4. You might want to use QS_ALLINPUT rather than QS_PAINT so that all messages get processed. See "Waiting in a message_loop"" for an example. 5. Since you're apparently doing all this in a window oriented thread (probably you're main thread), you don't want to use Sleep(1000). This will just freeze up your window while you're waiting in the loop. It'd better doing only the process wait loop, peek message loop, or using a window hook to wait for close notification of the window. 6. It's kind of pointless to call TerminateProcess immediately after SendMessage. You're not exactly giving the process much time to clean up and exit normally. Don't call TerminateProcess except as last resort.
-
A couple of things: 1. Does the pTouch->Recalibrate and/or CTouchScreenAPI::Create spawn another process? Or is the recalibrate function contained within your own process (separate thread maybe?) Does recalibrate return immediately? 2. You don't necessarily need to do both the IsWindow loop and the process loop. In any case you need to call GetWindowThreadProcessId before the IsWindow loop. Otherwise, what's the point? The window is gone so the call will always fail. 3. Don't use PROCESS_ALL_ACCESS unless you absolutely have to. Use the minimum security setting to get the job done. Depending on the circumstances and user's security level the call may fail trying for all access. SYNCHRONIZE is all you need for waiting on the handle. If you need to call TerminateProcess then add PROCESS_TERMINATE as well. 4. You might want to use QS_ALLINPUT rather than QS_PAINT so that all messages get processed. See "Waiting in a message_loop"" for an example. 5. Since you're apparently doing all this in a window oriented thread (probably you're main thread), you don't want to use Sleep(1000). This will just freeze up your window while you're waiting in the loop. It'd better doing only the process wait loop, peek message loop, or using a window hook to wait for close notification of the window. 6. It's kind of pointless to call TerminateProcess immediately after SendMessage. You're not exactly giving the process much time to clean up and exit normally. Don't call TerminateProcess except as last resort.
Hi there, First of all ,thank you for your help... Now, coming to the code: 1. Recalibrate function is contained within the process. yes, recalibrate function return immediately. 2. Ok, I am gonna use IsWindow loop and calling GetWindowThreadProcessID before the loop. 3.Ok, I used Synchronize rather than Process_all_access. 4. is also Ok. 5. is also Ok. 6. Should I wait for some time and then call Terminate Process? Thanks Waiting for reply Preeti Preeti9
-
Hi there, First of all ,thank you for your help... Now, coming to the code: 1. Recalibrate function is contained within the process. yes, recalibrate function return immediately. 2. Ok, I am gonna use IsWindow loop and calling GetWindowThreadProcessID before the loop. 3.Ok, I used Synchronize rather than Process_all_access. 4. is also Ok. 5. is also Ok. 6. Should I wait for some time and then call Terminate Process? Thanks Waiting for reply Preeti Preeti9
If the Recalibrate function is contained within your own process, then waiting for the process to complete won't work. You'll be waiting for yourself to exit. However, if recalibrate spawns off another thread (sounds possible since it returns immediately) then you can wait on the thread handle instead. Use these tests to verify that another thread was launched. Add code similar to: pTouch->Recalibrate(); HWND hWnd = FindWindow(...); DWORD RecalProcID; DWORD RecalThreadID = GetWindowThreadProcessId( hWnd, &ProcID ); DWORD MyProcID = GetCurrentProcessId(); DWORD MyThreadID = GetCurrentThreadId(); HANDLE hRecalThread = OpenThread( SYNCHRONIZE, FALSE, RecalThreadID ); Put a breakpoint before the recalibrate call. When breakpoint is hit, open the threads window (menu: Debug/Windows/Threads) Monitor this window to see if another thread is created when recalibrate is executed. If in the same process, then RecalProcID will match MyProcID. If different thread, then RecalThreadID will be different than MyThreadID. What you're looking for is that RecalThreadID is created fresh when Recalibrate is called (or when TouchScreen object is created) and that the thread goes away when the calibration is done. If, on the other hand, RecalThreadID is the same as MyThreadID then you cannot use MsgWaitForMultipleObjects to wait on anything as you will be waiting on yourself. Then about the only you can do is check IsWindow periodically inside a PeekMessage loop. Undoubtedly you will need to process messages as the recalibrate itself will be depending on it. What does the Recalibrate function return? Are there any other functions for checking for status? Ultimately if the recalibrate spawns another thread and then the thread goes away when recalibration is complete, then you don't even need the IsWindow loop - just the MsgWaitForMultipleObjects.
-
If the Recalibrate function is contained within your own process, then waiting for the process to complete won't work. You'll be waiting for yourself to exit. However, if recalibrate spawns off another thread (sounds possible since it returns immediately) then you can wait on the thread handle instead. Use these tests to verify that another thread was launched. Add code similar to: pTouch->Recalibrate(); HWND hWnd = FindWindow(...); DWORD RecalProcID; DWORD RecalThreadID = GetWindowThreadProcessId( hWnd, &ProcID ); DWORD MyProcID = GetCurrentProcessId(); DWORD MyThreadID = GetCurrentThreadId(); HANDLE hRecalThread = OpenThread( SYNCHRONIZE, FALSE, RecalThreadID ); Put a breakpoint before the recalibrate call. When breakpoint is hit, open the threads window (menu: Debug/Windows/Threads) Monitor this window to see if another thread is created when recalibrate is executed. If in the same process, then RecalProcID will match MyProcID. If different thread, then RecalThreadID will be different than MyThreadID. What you're looking for is that RecalThreadID is created fresh when Recalibrate is called (or when TouchScreen object is created) and that the thread goes away when the calibration is done. If, on the other hand, RecalThreadID is the same as MyThreadID then you cannot use MsgWaitForMultipleObjects to wait on anything as you will be waiting on yourself. Then about the only you can do is check IsWindow periodically inside a PeekMessage loop. Undoubtedly you will need to process messages as the recalibrate itself will be depending on it. What does the Recalibrate function return? Are there any other functions for checking for status? Ultimately if the recalibrate spawns another thread and then the thread goes away when recalibration is complete, then you don't even need the IsWindow loop - just the MsgWaitForMultipleObjects.
Hi, Yes, I am doubtful if I can use here Msgwaitformultipleobjects or not.... I wasn't able to implement this: pTouch->Recalibrate(); HWND hWnd = FindWindow(...); DWORD RecalProcID; DWORD RecalThreadID = GetWindowThreadProcessId( hWnd, &ProcID ); DWORD MyProcID = GetCurrentProcessId(); DWORD MyThreadID = GetCurrentThreadId(); HANDLE hRecalThread = OpenThread( SYNCHRONIZE, FALSE, RecalThreadID ); This is giving me errors for OpenThread. I am sending you my code again and please let me know how to proceed further to detect that calibration window. Here's the code: // TSCalibrate.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "CWin32AbsPointAPI.h" void main () { } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CTouchScreenAPI* pTouch; HWND hCalWin; DWORD SYNCRONIZE; DWORD procId; HANDLE hProcess; DWORD dwWaitResult; pTouch = CTouchScreenAPI::Create(); if (pTouch) { if (pTouch->Init()) pTouch->Recalibrate(FALSE); else MessageBox(NULL, "Created touchscreen interface OK, but Init() failed", "Info", MB_OK); HWND hCalWin = ::FindWindow(pszABSPOINT_WND_CLASS_NAME, NULL); GetWindowThreadProcessId(hCalWin, &procId); // retrieves the identifier of the thread that created this window. hProcess = OpenProcess(SYNCHRONIZE, FALSE, procId);//returns a handle to an existing process object while( true ) { if( ! IsWindow(hCalWin) ) break; // window is gone; // Sleep( 1000); // wait a second for window to close }; while (1) { dwWaitResult = MsgWaitForMultipleObjects(1, &hProcess, FALSE, 30*1000, QS_ALLINPUT); if (dwWaitResult == WAIT_OBJECT_0 + 1) { MSG xMsg; while (PeekMessage(&xMsg, NULL, 0, 0, PM_REMOVE)) { if (xMsg.message == WM_QUIT) return 1; TranslateMessage(&xMsg); DispatchMessage(&xMsg); }// end of PeekMessage while loop. } else if (dwWaitResult == WAIT_TIMEOUT) { SendMessage(hCalWin, WM_CLOSE, 0, 0); //TerminateProcess(hProcess, 0); break; } else dwWaitResult == WAIT_OBJECT_0; { //Calibration process completed; break; } } } else { MessageBox(NULL, "Unable to get pointer to Touchscreen interface", "Info", MB_OK); } return 0; }
-
Hi, Yes, I am doubtful if I can use here Msgwaitformultipleobjects or not.... I wasn't able to implement this: pTouch->Recalibrate(); HWND hWnd = FindWindow(...); DWORD RecalProcID; DWORD RecalThreadID = GetWindowThreadProcessId( hWnd, &ProcID ); DWORD MyProcID = GetCurrentProcessId(); DWORD MyThreadID = GetCurrentThreadId(); HANDLE hRecalThread = OpenThread( SYNCHRONIZE, FALSE, RecalThreadID ); This is giving me errors for OpenThread. I am sending you my code again and please let me know how to proceed further to detect that calibration window. Here's the code: // TSCalibrate.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "CWin32AbsPointAPI.h" void main () { } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CTouchScreenAPI* pTouch; HWND hCalWin; DWORD SYNCRONIZE; DWORD procId; HANDLE hProcess; DWORD dwWaitResult; pTouch = CTouchScreenAPI::Create(); if (pTouch) { if (pTouch->Init()) pTouch->Recalibrate(FALSE); else MessageBox(NULL, "Created touchscreen interface OK, but Init() failed", "Info", MB_OK); HWND hCalWin = ::FindWindow(pszABSPOINT_WND_CLASS_NAME, NULL); GetWindowThreadProcessId(hCalWin, &procId); // retrieves the identifier of the thread that created this window. hProcess = OpenProcess(SYNCHRONIZE, FALSE, procId);//returns a handle to an existing process object while( true ) { if( ! IsWindow(hCalWin) ) break; // window is gone; // Sleep( 1000); // wait a second for window to close }; while (1) { dwWaitResult = MsgWaitForMultipleObjects(1, &hProcess, FALSE, 30*1000, QS_ALLINPUT); if (dwWaitResult == WAIT_OBJECT_0 + 1) { MSG xMsg; while (PeekMessage(&xMsg, NULL, 0, 0, PM_REMOVE)) { if (xMsg.message == WM_QUIT) return 1; TranslateMessage(&xMsg); DispatchMessage(&xMsg); }// end of PeekMessage while loop. } else if (dwWaitResult == WAIT_TIMEOUT) { SendMessage(hCalWin, WM_CLOSE, 0, 0); //TerminateProcess(hProcess, 0); break; } else dwWaitResult == WAIT_OBJECT_0; { //Calibration process completed; break; } } } else { MessageBox(NULL, "Unable to get pointer to Touchscreen interface", "Info", MB_OK); } return 0; }
I was forgetting that OpenThread is available only for Windows 2000 and up. What operating system is this running on? If this is on 2000 and up, then you can enable those functions by adding: #define WINVER 0x0501 #define _WIN32_WINNT 0x0501 before including the Windows header files. In any case you don't need the OpenThread call and its wait loop just to be able to step through the first few lines in order to determine what threads are created. What does Recalibrate return? TRUE/FALSE or something else?
-
I was forgetting that OpenThread is available only for Windows 2000 and up. What operating system is this running on? If this is on 2000 and up, then you can enable those functions by adding: #define WINVER 0x0501 #define _WIN32_WINNT 0x0501 before including the Windows header files. In any case you don't need the OpenThread call and its wait loop just to be able to step through the first few lines in order to determine what threads are created. What does Recalibrate return? TRUE/FALSE or something else?
I have windows XP.....But its still giving me errors with OpenProcess. Recalibrate function is returning False.... Thanks Preeti Preeti9
-
I have windows XP.....But its still giving me errors with OpenProcess. Recalibrate function is returning False.... Thanks Preeti Preeti9
Hi, What if I use SetForegroundWindow(hCalWin); DWORD AllowSetForegroundWindow(procId); OR AnyPopup(); When I execute and type in the file name on command window, it starts doing calibration returning the cursor to next line, that means it is't able to detect it. You said there are other methods for it. Let me know. Please help. Thanks Preeti9
-
Hi, What if I use SetForegroundWindow(hCalWin); DWORD AllowSetForegroundWindow(procId); OR AnyPopup(); When I execute and type in the file name on command window, it starts doing calibration returning the cursor to next line, that means it is't able to detect it. You said there are other methods for it. Let me know. Please help. Thanks Preeti9
AnyPopup is an archaic function. I don't see at the moment how SetForegroundWindow, etc. would help you. I need more information about what the calibration process is doing. What is the result from the following code:
pTouch->Recalibrate();
HWND hRecalWnd = FindWindow(...);
DWORD RecalProcID = 0;
DWORD RecalThreadID = GetWindowThreadProcessId( hRecalWnd, &RecalProcID );
char MsgText[1024];
DWORD CurProcID = GetCurrentProcessId();
DWORD CurThreadID = GetCurrentThreadId();sprintf( MsgText, "HWND = %p\nValid = %s\nRecalProcID = %x\nRecalThreadID = %x\nCurProcID = %x\nCurThreadID = %x",
hRecalWnd, IsWindow(hRecalWnd) ? "Yes" : "No",
RecalProcID, RecalThreadID, CurProcID, CurThreadID );
MessageBox( NULL, MsgText, "Test", MB_OK ); -
AnyPopup is an archaic function. I don't see at the moment how SetForegroundWindow, etc. would help you. I need more information about what the calibration process is doing. What is the result from the following code:
pTouch->Recalibrate();
HWND hRecalWnd = FindWindow(...);
DWORD RecalProcID = 0;
DWORD RecalThreadID = GetWindowThreadProcessId( hRecalWnd, &RecalProcID );
char MsgText[1024];
DWORD CurProcID = GetCurrentProcessId();
DWORD CurThreadID = GetCurrentThreadId();sprintf( MsgText, "HWND = %p\nValid = %s\nRecalProcID = %x\nRecalThreadID = %x\nCurProcID = %x\nCurThreadID = %x",
hRecalWnd, IsWindow(hRecalWnd) ? "Yes" : "No",
RecalProcID, RecalThreadID, CurProcID, CurThreadID );
MessageBox( NULL, MsgText, "Test", MB_OK );The code is doing calibration and doesn't shows anything. Its running the same way as earlier code was running. Should I send you all the files again? Thanks Preeti Preeti9