Magma Expert Licensed User Longtime User Feb 23, 2021 #1 Hi there... I know is a big title... I don't need that to be a "B4J" solution - it can be cmd / line or poweshell script... but b4j will be the "best" So that i need to know - is the program user works now on + in front... not all the apps are running in memory but the front one !!! With powershell i can see with this command what is running now... but which is in front of all? example: B4X: Get-Process | Where-Object { $_.MainWindowTitle } | Format-Table ID,Name,Mainwindowtitle ?AutoSize Id Name MainWindowTitle -- ---- --------------- 3392 B4J xxxxxx - B4J 8988 B4J jRDC - B4J 4984 cmd Administrator: Γραμμή εντολών - powershell Last edited: Feb 23, 2021
Hi there... I know is a big title... I don't need that to be a "B4J" solution - it can be cmd / line or poweshell script... but b4j will be the "best" So that i need to know - is the program user works now on + in front... not all the apps are running in memory but the front one !!! With powershell i can see with this command what is running now... but which is in front of all? example: B4X: Get-Process | Where-Object { $_.MainWindowTitle } | Format-Table ID,Name,Mainwindowtitle ?AutoSize Id Name MainWindowTitle -- ---- --------------- 3392 B4J xxxxxx - B4J 8988 B4J jRDC - B4J 4984 cmd Administrator: Γραμμή εντολών - powershell
Sandman Expert Licensed User Longtime User Feb 23, 2021 #2 You're only looking for a Windows solution, correct? Perhaps some combination of https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getforegroundwindow and then https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/finding-the-process-id? The former delivers a handle for the window, and I have no idea how to go from that to the process id that is required by the latter, sorry. Upvote 0
You're only looking for a Windows solution, correct? Perhaps some combination of https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getforegroundwindow and then https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/finding-the-process-id? The former delivers a handle for the window, and I have no idea how to go from that to the process id that is required by the latter, sorry.
Magma Expert Licensed User Longtime User Feb 23, 2021 #3 Thanks.... that gave me ideas... powershell: B4X: $code = @' [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); '@ Add-Type $code -Name Utils -Namespace Win32 while(1){ $hwnd = [Win32.Utils]::GetForegroundWindow() Get-Process | Where-Object { $_.mainWindowHandle -eq $hwnd } | Select-Object processName, MainWindowTItle, MainWindowHandle sleep -Milliseconds 200 } Can we "convert" it someway to "b4j"... ? Upvote 0
Thanks.... that gave me ideas... powershell: B4X: $code = @' [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); '@ Add-Type $code -Name Utils -Namespace Win32 while(1){ $hwnd = [Win32.Utils]::GetForegroundWindow() Get-Process | Where-Object { $_.mainWindowHandle -eq $hwnd } | Select-Object processName, MainWindowTItle, MainWindowHandle sleep -Milliseconds 200 } Can we "convert" it someway to "b4j"... ?
Magma Expert Licensed User Longtime User Feb 23, 2021 #4 https://www.b4x.com/android/forum/threads/how-to-get-getforegroundwindow-getactivewindow.123648/ well i am doing this often... Saying/Searching something and then... Must Searching better + improve my english too [tick] :-( //Sorry GUYS ! Last edited: Feb 23, 2021 Upvote 0
https://www.b4x.com/android/forum/threads/how-to-get-getforegroundwindow-getactivewindow.123648/ well i am doing this often... Saying/Searching something and then... Must Searching better + improve my english too [tick] :-( //Sorry GUYS !