|
Post by sarmednafi on Apr 30, 2023 6:19:26 GMT -5
Dear Group,
I have three opened windows on desk top, the one I want behind the others. Is it possible via my LB code to bring the window which I want on Top? The windows dose not created by my code it is for external programs.
We can describe as: How to bring external application window on top?
I really appreciate your help.
Regards Sarmed
|
|
|
Post by Walt Decker on Apr 30, 2023 18:03:00 GMT -5
If the other two windows were created by LB you can hide them with the HIDE statement. The other window will automatically be in the foreground.
|
|
|
Post by sarmednafi on Apr 30, 2023 22:06:35 GMT -5
Sir,
Thank you for your response, No Sir they are not.
The idea is to select one of them then send Alt+F4 to close it. The send Alt+F4 is covered in LB forum it's code is simple. I know there is an API function in windows can do my request but who will help?
The following code open window write Q on it then send Alt+F4 the window will close quickly may be faster than you can see.
' cod start nomainwin open "Test" for text as #m #m "!trapclose [quit]" call keybdEvent _VK_SHIFT, 1 call keybdEvent asc("Q"), 1 call keybdEvent asc("Q"), 0 call keybdEvent _VK_SHIFT, 0 ' sending Alt+F4 call keybdEvent _VK_MENU, 1 call keybdEvent _VK_F4, 1 call keybdEvent _VK_F4, 0 call keybdEvent _VK_MENU, 0 wait [quit] close #m end sub keybdEvent bVk, depressed 'bVk ......... Virtual Key Code of the key 'depressed ... 0 = released, 1 = depressed if depressed = 0 then dwFlags = _KEYEVENTF_KEYUP calldll #user32, "keybd_event",_ bVk as ushort,_ bScan as ushort,_ dwFlags as ulong,_ dwExtraInfo as ulong,_ result as void end sub ' code end
|
|
|
Post by Brandon Parker on May 1, 2023 9:28:22 GMT -5
You can try something like this...
'NoMainWin windowTitle$ = "Your Window Title Here" hWnd = FindWindow(windowTitle$) result = SetForeGroundWindow(hWnd) result = ShowWindow(hWnd, _SW_SHOWNORMAL) End
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function FindWindow(lpWindowName$) lpWindowName$ = lpWindowName$ + chr$(0) CallDLL #user32, "FindWindowA", _NULL As ulong, _ lpWindowName$ As ptr, _ FindWindow As ulong End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function SetForeGroundWindow(hWnd) CallDLL #user32, "SetForegroundWindow", hWnd As ulong, _ SetForeGroundWindow As long End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function ShowWindow(hWnd, nCmdShow) CallDLL #user32, "ShowWindow", hWnd As ulong, _ nCmdShow As long, _ ShowWindow As long End Function
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on May 1, 2023 10:21:32 GMT -5
Dear Group, I have three opened windows on desk top, the one I want behind the others. Is it possible via my LB code to bring the window which I want on Top? The windows dose not created by my code it is for external programs. We can describe as: How to bring external application window on top? I really appreciate your help. Regards Sarmed
I am confused. Do you want to close the windows that are on top or just bring the bottom window to the foreground?
If none of the windows were created by your application about the only thing you can do is bring them to the foreground. I doubt that you can close a window programmatically that was not created by your application. They are completely different processes and do not communicate well with one another.
|
|
|
Post by sarmednafi on May 1, 2023 11:58:14 GMT -5
Brandon Parker,
Thank you Sir, It's worked a great help you present. All the Best
--------------------------------------------------------
Walt Decker,
Sir, The Window I interested with I want to close it. Since Alt+F4 Don't work till the window I want to close it be on top So I have to bring it on top first.
Regards Sarmed
|
|