I was doing some tests on Window relationships, and found out that there are some windows that aren't accessible via the EnumWindows() and EnumChildWindows() functions.
Some I found by going up to the root of the relationship tree to the root node (nullptr) via GetParent() and another I found by peeking into the messages that were being sent around. Is there no way to find these handles? If so, how? If not, is it done this way for security purposes, or is something broken?
Edit
I've added a repo of the code (including the VS solution I did) here, in case anyone is interested in taking a look. When I run it unmodified, it gives me a single not enumable HWND with the class name Message. Why that isn't included in the message windows, I don't know. Changing the line allocate_nodes(false) to allocate_nodes(true) in the main() function, will force looking for other HWNDs that weren't found using the published interfaces. I'm not sure if these are real or phantoms, though it does capture the not enumable HWND.
Some sample output:
handle #!window_status!got expected!visible!tree!class name!window title
1! special!correct!0!"00000000"!!
2! special!correct!1!" 00010010"!#32769!
3! top level!correct!0!" 00010290"!ComboLBox!
4! top level!correct!0!" 000102FE"!ComboLBox!
5! top level!correct!0!" 000404A0"!ComboLBox!
6! top level!correct!0!" 000404A4"!ComboLBox!
7! top level!correct!0!" 00040822"!ComboLBox!
8! top level!correct!0!" 00071DF8"!ComboLBox!
9! top level!correct!0!" 000A0FF6"!ComboLBox!
10! top level!correct!0!" 001A1CD0"!ComboLBox!
11! top level!correct!0!" 001C1626"!ComboLBox!
12! top level!correct!0!" 001E1C30"!ComboLBox!
13! top level!correct!0!" 001F17FC"!ComboLBox!
14! top level!correct!0!" 002B19E8"!ComboLBox!
15! top level!correct!0!" 003517D2"!ComboLBox!
16! top level!correct!0!" 00351906"!ComboLBox!
17! top level!correct!0!" 00351AE4"!ComboLBox!
18! top level!correct!0!" 003714D2"!ComboLBox!
19! top level!correct!0!" 003916E2"!ComboLBox!
20! top level!correct!0!" 00421248"!ComboLBox!
21! top level!correct!0!" 005B0472"!ComboLBox!
22! top level!correct!0!" 006517CA"!ComboLBox!
23! top level!correct!0!" 00680E16"!ComboLBox!
24! top level!correct!0!" 006F11D0"!ComboLBox!
25! top level!correct!0!" 00751B08"!ComboLBox!
26! top level!correct!0!" 007A165E"!ComboLBox!
27! top level!correct!0!" 00840C0E"!ComboLBox!
28! top level!correct!0!" 009816AC"!ComboLBox!
29! top level!correct!0!" 009E0EE2"!ComboLBox!
30! top level!correct!0!" 00A01AAC"!ComboLBox!
31! top level!correct!0!" 00B1134A"!ComboLBox!
32! top level!correct!0!" 00BA10F8"!ComboLBox!
33! top level!correct!0!" 00C00994"!ComboLBox!
34! top level!correct!0!" 00E014C0"!ComboLBox!
35! top level!correct!0!" 00EA0452"!ComboLBox!
36! top level!correct!0!" 00F911E2"!ComboLBox!
37! top level!correct!0!" 014913EC"!ComboLBox!
38! top level!correct!0!" 015804D0"!ComboLBox!
39! top level!correct!0!" 018E0FF0"!ComboLBox!
40! top level!correct!0!" 01D60FA4"!ComboLBox!
41! top level!correct!0!" 021E087C"!ComboLBox!
42! not enumable!correct!0!" 00010012"!Message!
43! message!correct!0!" 0015184E"!ScriptedMessageWindow!
44! message!correct!0!" 005C0C54"!AccessibleNotificationsWindow!
45! message!correct!0!" 00A6043A"!ScriptedMessageWindow!
46! message!correct!0!" 00E80DEE"!ScriptedMessageWindow!
47! message!correct!0!" 00010014"!#32774!
48! top level!correct!0!" 00010048"!Dwm!DWM Notification Window
49! message!correct!0!" 00010086"!#43!MCI command handling window
50! message!correct!0!" 0001008A"!OleMainThreadWndClass!OleMainThreadWndName
51! top level!correct!0!" 0001008C"!DDEMLMom!
52! top level!correct!0!" 00010090"!DDEMLEvent!
53! message!correct!0!" 00010094"!OleMainThreadWndClass!OleMainThreadWndName
54! message!correct!0!" 00010098"!WorkerW!AppResolver_NotifyWnd
55! message!correct!0!" 000100A8"!OleMainThreadWndClass!OleMainThreadWndName
56! message!correct!0!" 000100B0"!CicMarshalWndClass!CicMarshalWnd
57! message!correct!0!" 000100B2"!UserAdapterWindowClass!
58! message!correct!0!" 000100BC"!OleMainThreadWndClass!OleMainThreadWndName
59! message!correct!0!" 000100C0"!CicMarshalWndClass!CicMarshalWnd
60! top level!correct!0!" 000100CC"!PushNotificationsPowerManagement!Windows Push Notifications Platform
61! top level!correct!0!" 000100CE"!IME!Default IME
62! message!correct!0!" 000100D6"!UserAdapterWindowClass!
63! message!correct!0!" 000100DC"!UserAdapterWindowClass!
64! top level!correct!0!" 000100E2"!GDI+ Hook Window Class!G
65! top level!correct!0!" 000100E4"!IME!Default IME
66! top level!correct!0!" 000100E8"!#32770!The Event Manager Dashboard
67! top level!correct!0!" 000100EA"!IME!Default IME
68! top level!correct!0!" 00010102"!MSCTFIME UI!MSCTFIME UI
69! not top level!correct!0!" 000100F0"!Button!OK
70! not top level!correct!0!" 000100F2"!Static!Activity Information
71! not top level!correct!0!" 000100F4"!Button!Cancel
72! not top level!correct!0!" 000100F6"!ListBox!
The default field separator is !, but can be changed at the top of the source file. I wonder what all of these hidden ComboBoxes are for that are off of the Desktop?
Related
I have been stuck in that question from Coursera AlgorithmicBox. The question of Quiz is as below. I do not have any idea how to approac for the solution :)
You are given 20 black and white cells. The leftmost one is white, the
rightmost one is black, the colors of all other cells are hidden. You
can reveal the color of a cell by clicking on it. Your goal is to find
two adjacent cells of different colors by using at most 5 clicks.
Since there is white cell and a black cell, we know that there is a transition at some point. We can click on the 10th cell, if it's white we discard the cells left of it, if it's black, the cells right of it, we'll be left with 11 (or 10) cells, if we repeat this process using the middle, or one of the two middle cells in the case of even tiles one more times, we'll have at most 6 cells. We repeat this process again to discard two more cells and we're left with 3 cells, we then check the last cell to see all 3 cells. Since we know that the left and right cells are different, it's either the first two or last two that are different but adjacent.
We used 4 clicks.
In general this is similar binary search, with similar guarantees. we always check for the floor[n/2] th cell (or ceil, doesn't matter).
For the following question I wanted to know how to estimate the probability that I have selected from bin A.
There are 10 bins, 4 are labelled A, 6 labelled B. Each bin has balls with two colors (Red/ blue). The distribution of red and blue balls in bin A is (0.3 to 0.7) The distribution of red and blue balls in bin B is (0.7 to 0.3). If you randomly draw two balls with replacement and they turn out to be red and blue what is the probability we selected from A?
I am getting (Probability selecting red from any Bin that is A/ Total probability selecting red from all bins)X (Probability selecting blue from any bin that is A/ Total probability of selecting a blue from all bins) =13.7%
I have finite 2D space with wrapped coordinates both way (I mean going left will wrap around into right edge, the same going for up/down).
I also have a set of box aligned to axes. These boxes have float coordinates inside space.
Problem: find smallest bounding box aligned to axes enclosing all boxes. Bounding box CAN be wrapped around.
Samples:
(Pink denotes space boundaries, red boxes needs to be enclosed, blue border denotes smallest possible bounding box)
A sweeping algorithm can be used to find the largest vertical gap, i.e. maximally distant two vertical lines that have no boxes between them.
Similarly, a sweeping algorithm can be used to find the largest horizontal gap. Obviously, both gaps can wrap around edges.
The shape left by removing the gaps from the 2D space is the smallest bounding box containing all boxes. I am not sure if it's guaranteed to have the smallest area of all the containing boxes, but there exists no bounding box that has both dimensions smaller than this one. If it existed, it would define two gaps (vertical & horizontal) both larger than the maximal ones.
The sweeping to detect both gaps can be done in O(N * log N) where N is the number of boxes.
The % of the total area enclosed by a bounding box will be:
% of total area enclosed by bounding box = (% of horizontal range enclosed by horizontal bounds) * (% of vertical range enclosed by vertical bounds)
Taking wrapping into account obviously. Therefore you can minimize the horizontal and vertical bounds independently in order to minimize the total area.
To minimize the horizontal bounds, you need to find the largest gap between one rectangle's right edge and the next's left edge. You can do this efficiently by sorting all edges (left and right) into a single list and iterating across it, incrementing a count when you get a left and decrementing when you get a right. Your largest gap is the biggest difference in x values when the count goes from 0 -> 1. You'll have to handle the wrap-around case specially, you could easily do this just by repeating the rectangles once horizontally, offset by the width of the total area. You also have to take into account wrapped-around rectangles when initializing the count at the start.
Then do likewise for the vertical bounds.
I have to find an algorithm that can find the total amount of intersections between two sets of arrays, whereas one of the array is sorted.
An example, we have these two arrays and we draw straight lines towards corresponding number.
These two arrays gives us a total of 7 intersections.
What kind of algorithms does it exist to help me with this problem?
I have used the search button but did not find anything that would solve this problem for me.
Thanks
Given two number M and N, the lines won't intersect if
the top M is to the right of the top N, and the bottom M is to the right of the bottom N
the top M is to the left of the top N, and the bottom M is to the left of the bottom N
In the other two cases:
left top, right bottom
right top, left bottom
the lines do intersect.
In the example, 8 is to the left of all 4 numbers on the top row, and to the right of 3 numbers on the bottom, so 8 intersects with three numbers.
5 is to the right of 8 on top, left of 8 on the bottom, giving one intersection. 5 is left of 4 and 1 on top, and right of 4 and 1 on the bottom, giving two more. So 5 intersects with three numbers.
Note that we counted the intersection of 5 and 8 twice. In fact every intersection will be counted twice. If you finish the example, you'll count 14 intersections. Divide by 2 at the end to get the answer.
you can represent each line as y=a+bx and then compare each line to the others by comparing their y values.
each line will have maximum one intersection with each other line.
Given a large list of GPS coordinates and their weight, is there an open source software (database/search engine) to get top N values inside a bounding box or a circle?
SELECT * FROM list WHERE IS_IN_BBOX(coords, bbox) ORDER BY weight DESC LIMIT 10;
I expect the list to be in tens of millions of items. The bounding box might be very large (whole world) or very small (zoom 18), but the search should still be reasonably fast. Also, could we use Elasticsearch for that? I saw that it has a distance based search, but not weight based search. How about Postgis?
You can can use ST_MakeEnvelope and && operator
SELECT *
FROM list
WHERE list.coords && ST_MakeEnvelope(left, bottom, right, top, srid)
ORDER BY list.weight;
repleace left, bottom, right, top and srid accordingly to search