Posts: 66
Threads: 19
Joined: May 2015
I am using QM version 2.4.3 on Windows 8.1
QM will not always activate a window and make it visible on the screen.
Even though QM says the window is active (I checked using the command "win") the window is not visible?
(Note I have tried changing the option "Disable foreground lock option" and it does not work and the windows API function IsWindowVisible always report all windows visible even if they are not)
How do I ensure that when a windows is activated using "act" it definitely becomes visible on the screen?
Thank you
Posts: 12,147
Threads: 143
Joined: Dec 2002
Probably it is "cloaked". Or finds another cloaked window with same name.
Macro
Macro2526
int w=win("Start menu" "ImmersiveLauncher")
act w
int active(win=w) visible(IsWindowVisible(w)) cloaked(IsWindowCloaked(w))
out "active=%i visible=%i cloaked=%i" active visible cloaked
if cloaked
,cloaked=0
,if(DwmSetWindowAttribute(w 13 &cloaked 4)) out _s.dllerror ;;Try to uncloak. Error: Access is denied..
,
If you don't have IsWindowCloaked:
Function
IsWindowCloaked
function# hwnd
;Returns nonzero if the window is cloaked.
;Returns flags: 0 not cloaked, 1 cloaked by its application, 2 cloaked by Windows, 4 parent window is cloaked.
;REMARKS
;On Windows 8 and later, a window may be cloaked. Then it is invisible, although functions IsWindowVisible and hid say it is visible.
;On Windows 8, cloaked are inactive Windows store app windows. Also some inactive system windows, such as Start screen and Search.
;On Windows 10, cloaked are windows on inactive desktops. Also some system windows.
;Added in: QM 2.4.3.
if(_winver>=0x602 and !DwmGetWindowAttribute(hwnd 14 &_i 4)) ret _i
Posts: 66
Threads: 19
Joined: May 2015
Thank you.
I will try this and test.
Posts: 133
Threads: 15
Joined: Jun 2014
QM 2.4.2.2 does not have function "DwmGetWindowAttribute".
Posts: 12,147
Threads: 143
Joined: Dec 2002
dll- dwmapi #DwmGetWindowAttribute hwnd dwAttribute !*pvAttribute cbAttribute
Posts: 66
Threads: 19
Joined: May 2015
If I do not have the function DwmSetWindowAttribute what do I use?
is it:
dll- dwmapi #DwmSetWindowAttribute hwnd dwAttribute !*pvAttribute cbAttribute
Posts: 12,147
Threads: 143
Joined: Dec 2002
yes
Macro
Macro2514
dll- dwmapi
,#DwmGetWindowAttribute hwnd dwAttribute !*pvAttribute cbAttribute
,#DwmSetWindowAttribute hwnd dwAttribute !*pvAttribute cbAttribute
Posts: 66
Threads: 19
Joined: May 2015
Posts: 66
Threads: 19
Joined: May 2015
I actually created a function from your Macro2526 (see above at top of thread) and it worked ok when called from a macro but not when called from another function?
I guess it cannot be used in this way?
Posts: 12,147
Threads: 143
Joined: Dec 2002
Posts: 66
Threads: 19
Joined: May 2015
It may not have anything to do with the fact that the function I coded was being called by another function rather than a macro but the code does not seem to be able to execute "act w" and I have also seen a pointer error from the line "cloaked=(IsWindowCloaked(w))".
The code worked ok when called from a macro and not a function.
Here is the code for the function "actuncloak"
Macro
Macro17
/
function str'chart int'&cloaked
int w=win(chart)
out "activating and uncloaking"
;tryagain
0.01
act w
err
,out "cannot activate window in actuncloak"
,goto tryagain
,
if win<>w or win=0
,out "trying to activate window in actuncloak again"
,goto tryagain
cloaked=(IsWindowCloaked(w))
int active(win=w) visible(IsWindowVisible(w))
out "active=%i visible=%i cloaked=%i" active visible cloaked
if cloaked
,cloaked=0
,if(DwmSetWindowAttribute(w 13 &cloaked 4))
,,out _s.dllerror ;;Try to uncloak. Error: Access is denied..
,,ret
ret
Posts: 12,147
Threads: 143
Joined: Dec 2002
How it is called from another function when does not work? Please show code.
Replace the beginning to
Function
Function292
;/
function str'chart int&cloaked
if(!&cloaked) out "bad argument 'cloaked', must be an int variable"
int w=win(chart)
if(!w) end "window not found"
Posts: 66
Threads: 19
Joined: May 2015
You made me realise thank you.
When I called the function from a macro I correctly sent the window name parameter as a string e.g. "Quick Marcos" but when I called the function from another function I incorrectly sent the window as an integer e.g. win="Quick Macros"
Problem solved with your help.
Thank you