Am working on a Point Of Sale application that have to be active (ALWAYS ON FOCUS) at all times until intentionally closed. As of now, it does happen that the application is not always on focus, either because windows popped-up a notification update or i clicked the task bar unintentionally resulting in focus switching to that particular windows. Is there a way of insuring that at all times the application is not only ALWAYS on top BUT also always active because computers that would be running this POS application won’t be having a mouse to keep on switching focus? Thank you.
Announcement
Collapse
No announcement yet.
Help With Making An Application Awalys Active / on focus
Collapse
X
-
One possible way to make sure your application window is always on top and active is this:
At the end of your On Show event script, start a timer, which is triggered every few seconds. Five seconds should be fast enough to make the application return quickly, like this:
Code:Page.StartTimer(5000);
Code:nRes = String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\User32.dll", "GetActiveWindow", "0", DLL_RETURN_TYPE_LONG, DLL_CALL_CDECL)); nWnd = Application.GetWndHandle(); if (nRes ~= nWnd) then -- set current window on top and reactivate Window.SetOrder(nWnd, HWND_TOPMOST); end
-
Originally posted by Ulrich View PostOne possible way to make sure your application window is always on top and active is this:
At the end of your On Show event script, start a timer, which is triggered every few seconds. Five seconds should be fast enough to make the application return quickly, like this:
Code:Page.StartTimer(5000);
Code:nRes = String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\User32.dll", "GetActiveWindow", "0", DLL_RETURN_TYPE_LONG, DLL_CALL_CDECL)); nWnd = Application.GetWndHandle(); if (nRes ~= nWnd) then -- set current window on top and reactivate Window.SetOrder(nWnd, HWND_TOPMOST); end
This solves my problem. Maybe it's time indigorose help us with more knowledge on how to extend AMS applications with windows dll.
Comment
-
Ulrich, we have a new problem with the proposed solution.
Our proposed approach finds an input field that is always on focus for bar code reading on scan, yet our proposed solution does not restore this focus when the application is restored to it's required top order
(Window.SetOrder(nWnd, HWND_TOPMOST);c
Comment
-
You could use Page.SetFocus() to move the focus to the desired control when the window became inactive.
Ulrich
- Likes 1
Comment
-
Try this:
Code:function ResetApplicationFocus() nRes = String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\User32.dll", "GetActiveWindow", 0, DLL_RETURN_TYPE_LONG, DLL_CALL_CDECL)); nWnd = Application.GetWndHandle(); if (nRes ~= nWnd) then -- set current window on top and reactivate Window.SetOrder(nWnd, HWND_TOPMOST); DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SetForegroundWindow", nWnd, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); Page.SetFocus("INPUT_BARCODE"); end end
Comment
Comment