Skip to content

Commit

Permalink
Add DetectHiddenWindows and A_DetectHiddenWindows
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 5, 2023
1 parent 53fa4c7 commit c6ad56b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
8 changes: 4 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ <h2>Table of contents </h2>
<a class="tbd" href="#DetectHiddenText.htm">DetectHiddenText</a>
</li>
<li>
<a class="tbd" href="#DetectHiddenWindows.htm">DetectHiddenWindows</a>
<a href="#DetectHiddenWindows.htm">DetectHiddenWindows</a>
</li>
<li>
<a href="#IfWinActive.htm">IfWinActive/IfWinNotActive</a>
Expand Down Expand Up @@ -1666,7 +1666,7 @@ <h4 class="calibre25"><a id="Variables.htm__settings" href="#Variables.htm__sett
</tr>
<tr class="calibre3">
<td class="calibre4">A_DetectHiddenWindows</td>
<td class="calibre4 tbd"><a id="Variables.htm__DetectHiddenWindows" href="#Variables.htm__DetectHiddenWindows" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> The current mode (On or Off) set by <a href="#DetectHiddenWindows.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">DetectHiddenWindows</a>.</td>
<td class="calibre4"><a id="Variables.htm__DetectHiddenWindows" href="#Variables.htm__DetectHiddenWindows" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">#</a> The current mode (On or Off) set by <a href="#DetectHiddenWindows.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">DetectHiddenWindows</a>.</td>
</tr>
<tr class="calibre3">
<td class="calibre4">A_DetectHiddenText</td>
Expand Down Expand Up @@ -2089,7 +2089,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<td height="16" class="calibre4">Determines whether invisible text in a window is "seen" for the purpose of finding the window. This affects commands such as IfWinExist and WinActivate.</td>
</tr>
<tr class="calibre3">
<td height="16" class="tbd calibre4"><a href="#DetectHiddenWindows.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">DetectHiddenWindows</a></td>
<td height="16" class="calibre4"><a href="#DetectHiddenWindows.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">DetectHiddenWindows</a></td>
<td height="16" class="calibre4">Determines whether invisible windows are "seen" by the script.</td>
</tr>
<tr class="calibre3">
Expand Down Expand Up @@ -13362,7 +13362,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<p class="calibre8">  </p>
</div>
</div>
<div class="calibreMain tbd">
<div class="calibreMain">
<div class="calibreEbookContent">
<a id="DetectHiddenWindows.htm" href="#DetectHiddenWindows.htm">#</a> <h2 class="calibre17">DetectHiddenWindows</h2>
<hr size="2" class="calibre24" />
Expand Down
8 changes: 8 additions & 0 deletions src/cmd/misc/detect-hidden-windows.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# DetectHiddenWindows, On|Off
class Cmd::Misc::DetectHiddenWindows < Cmd::Base
def self.min_args; 1 end
def self.max_args; 1 end
def run(thread, args)
thread.settings.detect_hidden_windows = args[0].downcase == "on"
end
end
10 changes: 7 additions & 3 deletions src/cmd/x11/window/win-util.cr
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ class Cmd::X11::Window::Util
exclude_text = match_conditions[3]? || ""
current_desktop = thread.runner.display.x_do.desktop.to_i32

# Note: This can crash with "XGetWindowProperty failed!Invalid memory access (signal 11) at address 0x0 [...] xdo_get_desktop_for_window +120 in /usr/lib/libxdo
# Which is fixed with an xdotool fork (see build/README.md)
wins = thread.runner.display.x_do.search do
require_all
only_visible # if not present, this can seem unpredictable and buggy to the user https://github.com/jordansissel/xdotool/issues/67#issuecomment-1193573254
# ^ link also explains the need for specifying desktop:
desktop current_desktop
if ! thread.settings.detect_hidden_windows
only_visible # if not present, this can seem unpredictable and buggy to the user https://github.com/jordansissel/xdotool/issues/67#issuecomment-1193573254
# ^ link also explains the need for specifying desktop:
desktop current_desktop
end
if title.starts_with?("ahk_class ")
# TODO: these/name etc should all be case sensitive. Maybe double filter below? How performant is querying for .name etc?
window_class_name title[10..] # TODO: is this regex? how to make partial matches like ahk?
Expand Down
4 changes: 4 additions & 0 deletions src/run/thread.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Run
property coord_mode_mouse = CoordMode::RELATIVE
property coord_mode_caret = CoordMode::RELATIVE
property coord_mode_menu = CoordMode::RELATIVE
property detect_hidden_windows = false
property ahk_x11_track_performance = false
end

Expand Down Expand Up @@ -213,6 +214,9 @@ module Run
case var
when "a_index"
(@loop_stack.last?.try &.index || 0).to_s
when "a_detecthiddenwindows"
pp! @settings
@settings.detect_hidden_windows ? "On" : "Off"
else
nil
end
Expand Down

0 comments on commit c6ad56b

Please sign in to comment.