how to use pywinauto to get checkbox in treeview - treeview

some UI list like this have some button or check box in treeview
| | GroupBox - '' (L807, T366, R1257, B746)
| | ['GroupBox']
| |
| | TreeView - '' (L815, T382, R1249, B732)
| | ['TreeView']
| | child_window(auto_id="1176", control_type="Tree")
| | |
| | | CheckBox - 'Intrusion Prevention' (L839, T384, R957, B402)
| | | ['CheckBox', 'Intrusion PreventionCheckBox', 'Intrusion Prevention', 'CheckBox0', 'CheckBox1']
| | | child_window(title="Intrusion Prevention", control_type="CheckBox")
| | |
| | | CheckBox - 'USB Malware Protection' (L874, T402, R1010, B420)
| | | ['USB Malware ProtectionCheckBox', 'CheckBox2', 'USB Malware Protection']
| | | child_window(title="USB Malware Protection", control_type="CheckBox")
| | |
| | | TreeItem - 'Network Virus Protection' (L858, T420, R996, B438)
| | | ['Network Virus Protection', 'Network Virus ProtectionTreeItem', 'TreeItem', 'TreeItem0', 'TreeItem1']
| | | child_window(title="Network Virus Protection", control_type="TreeItem")
I can use TreeView to see Treeitems like this
dlg = app.top_window()
a = dlg.TreeView
b = a.print_items()
i can see b have tree item (ex:Network Virus Protection) but no checkbox (ex:Intrusion Prevention) so how can i get checkbox ele from treeview?
i know can use child_window("title") to get check box , but i need get this ele and check it text, so use title are not better

you can try this extension,
https://marketplace.visualstudio.com/items?itemName=ClickCorp.clicknium
it includes one automation library, and can recorde the checkbox and do check or uncheck operation:
ui(locator.notepad.checkbox).check()

Related

Use AWK with delimiter to print specific columns

My file looks as follows:
+------------------------------------------+---------------+----------------+------------------+------------------+-----------------+
| Message | Status | Adress | Changes | Test | Calibration |
|------------------------------------------+---------------+----------------+------------------+------------------+-----------------|
| Hello World | Active | up | 1 | up | done |
| Hello Everyone Here | Passive | up | 2 | down | none |
| Hi there. My name is Eric. How are you? | Down | up | 3 | inactive | done |
+------------------------------------------+---------------+----------------+------------------+------------------+-----------------+
+----------------------------+---------------+----------------+------------------+------------------+-----------------+
| Message | Status | Adress | Changes | Test | Calibration |
|----------------------------+---------------+----------------+------------------+------------------+-----------------|
| What's up? | Active | up | 1 | up | done |
| Hi. I'm Otilia | Passive | up | 2 | down | none |
| Hi there. This is Marcus | Up | up | 3 | inactive | done |
+----------------------------+---------------+----------------+------------------+------------------+-----------------+
I want to extract a specific column using AWK.
I can use CUT to do it; however when the length of each table varies depending on how many characters are present in each column, I'm not getting the desired output.
cat File.txt | cut -c -44
+------------------------------------------+
| Message |
|------------------------------------------+
| Hello World |
| Hello Everyone Here |
| Hi there. My name is Eric. How are you? |
+------------------------------------------+
+----------------------------+--------------
| Message | Status
|----------------------------+--------------
| What's up? | Active
| Hi. I'm Otilia | Passive
| Hi there. This is Marcus | Up
+----------------------------+--------------
or
cat File.txt | cut -c 44-60
+---------------+
| Status |
+---------------+
| Active |
| Passive |
| Down |
+---------------+
--+--------------
| Adress
--+--------------
| up
| up
| up
--+--------------
I tried using AWK but I don't know how to add 2 different delimiters which would take care of all the lines.
cat File.txt | awk 'BEGIN {FS="|";}{print $2,$3}'
Message Status
------------------------------------------+---------------+----------------+------------------+------------------+-----------------
Hello World Active
Hello Everyone Here Passive
Hi there. My name is Eric. How are you? Down
Message Status
----------------------------+---------------+----------------+------------------+------------------+-----------------
What's up? Active
Hi. I'm Otilia Passive
Hi there. This is Marcus Up
The output I'm looking for:
+------------------------------------------+
| Message |
|------------------------------------------+
| Hello World |
| Hello Everyone Here |
| Hi there. My name is Eric. How are you? |
+------------------------------------------+
+----------------------------+
| Message |
|----------------------------+
| What's up? |
| Hi. I'm Otilia |
| Hi there. This is Marcus |
+----------------------------+
or
+------------------------------------------+---------------+
| Message | Status |
|------------------------------------------+---------------+
| Hello World | Active |
| Hello Everyone Here | Passive |
| Hi there. My name is Eric. How are you? | Down |
+------------------------------------------+---------------+
+----------------------------+---------------+
| Message | Status |
|----------------------------+---------------+
| What's up? | Active |
| Hi. I'm Otilia | Passive |
| Hi there. This is Marcus | Up |
+----------------------------+---------------+
or random other columns
+------------------------------------------+----------------+------------------+
| Message | Adress | Test |
|------------------------------------------+----------------+------------------+
| Hello World | up | up |
| Hello Everyone Here | up | down |
| Hi there. My name is Eric. How are you? | up | inactive |
+------------------------------------------+----------------+------------------+
+----------------------------+---------------+------------------+
| Message |Adress | Test |
|----------------------------+---------------+------------------+
| What's up? |up | up |
| Hi. I'm Otilia |up | down |
| Hi there. This is Marcus |up | inactive |
+----------------------------+---------------+------------------+
Thanks in advance.
One idea using GNU awk:
awk -v fldlist="2,3" '
BEGIN { fldcnt=split(fldlist,fields,",") } # split fldlist into array fields[]
{ split($0,arr,/[|+]/,seps) # split current line on dual delimiters "|" and "+"
for (i=1;i<=fldcnt;i++) # loop through our array of fields (fldlist)
printf "%s%s", seps[fields[i]-1], arr[fields[i]] # print leading separator/delimiter and field
printf "%s\n", seps[fields[fldcnt]] # print trailing separator/delimiter and terminate line
}
' File.txt
NOTES:
requires GNU awk for the 4th argument to the split() function (seps == array of separators; see gawk string functions for details)
assumes our field delimiters (|, +) do not show up as part of the data
the input variable fldlist is a comma-delimited list of columns that mimics what would be passed to cut (eg, when a line starts with a delimiter then field #1 is blank)
For fldlist="2,3" this generates:
+------------------------------------------+---------------+
| Message | Status |
|------------------------------------------+---------------+
| Hello World | Active |
| Hello Everyone Here | Passive |
| Hi there. My name is Eric. How are you? | Down |
+------------------------------------------+---------------+
+----------------------------+---------------+
| Message | Status |
|----------------------------+---------------+
| What's up? | Active |
| Hi. I'm Otilia | Passive |
| Hi there. This is Marcus | Up |
+----------------------------+---------------+
For fldlist="2,4,6" this generates:
+------------------------------------------+----------------+------------------+
| Message | Adress | Test |
|------------------------------------------+----------------+------------------+
| Hello World | up | up |
| Hello Everyone Here | up | down |
| Hi there. My name is Eric. How are you? | up | inactive |
+------------------------------------------+----------------+------------------+
+----------------------------+----------------+------------------+
| Message | Adress | Test |
|----------------------------+----------------+------------------+
| What's up? | up | up |
| Hi. I'm Otilia | up | down |
| Hi there. This is Marcus | up | inactive |
+----------------------------+----------------+------------------+
For fldlist="4,3,2" this generates:
+----------------+---------------+------------------------------------------+
| Adress | Status | Message |
+----------------+---------------|------------------------------------------+
| up | Active | Hello World |
| up | Passive | Hello Everyone Here |
| up | Down | Hi there. My name is Eric. How are you? |
+----------------+---------------+------------------------------------------+
+----------------+---------------+----------------------------+
| Adress | Status | Message |
+----------------+---------------|----------------------------+
| up | Active | What's up? |
| up | Passive | Hi. I'm Otilia |
| up | Up | Hi there. This is Marcus |
+----------------+---------------+----------------------------+
Say that again? (fldlist="3,3,3"):
+---------------+---------------+---------------+
| Status | Status | Status |
+---------------+---------------+---------------+
| Active | Active | Active |
| Passive | Passive | Passive |
| Down | Down | Down |
+---------------+---------------+---------------+
+---------------+---------------+---------------+
| Status | Status | Status |
+---------------+---------------+---------------+
| Active | Active | Active |
| Passive | Passive | Passive |
| Up | Up | Up |
+---------------+---------------+---------------+
And if you make the mistake of trying to print the '1st' column, ie, fldlist="1":
+
|
|
|
|
|
+
+
|
|
|
|
|
+
If GNU awk is available, please try markp-fuso's nice solution.
If not, here is a posix-compliant alternative:
#!/bin/bash
# define bash variables
cols=(2 3 6) # bash array of desired columns
col_list=$(IFS=,; echo "${cols[*]}") # create a csv string
awk -v cols="$col_list" '
NR==FNR {
if (match($0, /^[|+]/)) { # the record contains a table
if (match($0, /^[|+]-/)) # horizontally ruled line
n = split($0, a, /[|+]/) # split into columns
else # "cell" line
n = split($0, a, /\|/)
len = 0
for (i = 1; i < n; i++) {
len += length(a[i]) + 1 # accumulated column position
pos[FNR, i] = len
}
}
next
}
{
n = split(cols, a, /,/) # split the variable `cols` on comma into an array
for (i = 1; i <= n; i++) {
col = a[i]
if (pos[FNR, col] && pos[FNR, col+1]) {
printf("%s", substr($0, pos[FNR, col], pos[FNR, col + 1] - pos[FNR, col]))
}
}
print(substr($0, pos[FNR, col + 1], 1))
}
' file.txt file.txt
Result with cols=(2 3 6) as shown above:
+---------------+----------------+-----------------+
| Status | Adress | Calibration |
+---------------+----------------+-----------------|
| Active | up | done |
| Passive | up | none |
| Down | up | done |
+---------------+----------------+-----------------+
+---------------+----------------+-----------------+
| Status | Adress | Calibration |
+---------------+----------------+-----------------|
| Active | up | done |
| Passive | up | none |
| Up | up | done |
+---------------+----------------+-----------------+
It detects the column width in the 1st pass then splits the line on the column position in the 2nd pass.
You can control the columns to print with the bash array cols which is assigned at the beginning of the script. Please assign the array to the list of desired column numbers in increasing order. If you want to use the bash variable in different way, please let me know.

Find references to files, recursively

In a project where XML/JS/Java files can contain references to other such files, I'd like to be able to have a quick overview of what has to be carefully checked, when one file has been updated.
So, it means I need to eventually have a look at all files referencing the modified one, and all files referencing files which refer to the modified one, etc. (recursively on matched files).
For one level, it's quite simple:
grep -E -l -o --include=*.{xml,js,java} -r "$FILE" . | xargs -n 1 basename
But how can I automate that to match (grand-(grand-))parents?
And how can that be, maybe, made more readable? For example, with a tree structure?
For example, if the file that interests me is called modified.js...
show-referring-files-to modified.js
... I could wish such an output:
some-file-with-ref-to-modified.xml
|__ a-file-referring-to-some-file-with-ref-to-modified.js
another-one-with-ref-to-modified.xml
|__ a-file-referring-to-another-one-with-ref-to-modified.js
|__ a-grand-parent-file-having-ref-to-ref-file.xml
|__ another-file-referring-to-another-one-with-ref-to-modified.js
or any other output (even flat) which allows for quickly checking which files are potentially impacted by a change.
UPDATE -- Results of current proposed answer:
ahmsff.js
|__ahmsff.xml
| |__ahmsd.js
| | |__ahmsd.xml
| | | |__ahmst.xml
| | | | |__BESH.java
| |__ahru.js
| | |__ahru.xml
| | | |__ahrut.xml
| | | | |__ashrba.js
| | | | | |__ashrba.xml
| | | | | | |__STR.java
| | |__ahrufrp.xml
| | | |__ahru.js
| | | | |__ahru.xml
| | | | | |__ahrut.xml
| | | | | | |__ashrba.js
| | | | | | | |__ashrba.xml
| | | | | | | | |__STR.java
| | | | |__ahrufrp.xml
| | | | | |__ahru.js
| | | | | | |__ahru.xml
| | | | | | | |__ahrut.xml
| | | | | | | | |__ashrba.js
| | | | | | | | | |__ashrba.xml
| | | | | | | | | | |__STR.java
| | | | | | |__ahrufrp.xml
(...)
I'd use a shell function (for the recursion) inside an shell script:
Assuming the filenames are unique have no characters that need escaping in them:
File: /usr/local/bin/show-referring-files-to
#!/bin/sh
get_references() {
grep -F -l --include=*.{xml,js,java} -r "$1" . | grep -v "$3" | while read -r subfile; do
#read each line of the grep result into the variable subfile
subfile="$(basename "$subfile")"
echo "$2""$subfile"
get_references "$subfile" ' '"$2" "$3"'\|'"$subfile"
done
}
while test $# -gt 0; do
#loop so more than one file can be given as argument to this script
echo "$1"
get_references "$1" '|__' "$1"
shift
done
There still are lots of performance enhancements possible.
Edit: Added $3 to prevent infinite-loop.

Sphinx malformed table

We've got a RST table in sphinx that looks like this:
+-------------------------+---------------------------------------------+-----------------------------------------+
| Key | Appearance in the administration | Value |
+=========================+=============================================+=========================================+
| |text_line| | simple text input | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |text_area| | text area | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |text_editor| | text editor with formatting capabilities | HTML string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |checkbox| | checkbox | boolean |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |single_select| | list of radio buttons | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |multiple_select| | list of checkboxes | array of strings |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |color| | color picker | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |date| | date picker | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |time| | text input with time validation | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |url| | text input with URL validation | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |email| | text input with email validation | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |password| | password input | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |phone| | text input for a phone number | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |internal_links| | widget for selecting links to other pages | resolved pages as defined in parameters |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |single_internal_link| | widget for selecting a single page | resolved page as defined in parameters |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |smart_content| | widget for configuring a data source | resolved pages as defined in parameters |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |resource_locator| | widget for entering the URL of a page | string |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |tag_list| | autocomplete input for entering and adding | array of strings |
| | tags | |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |category_list| | autocomplete input for entering and adding | array of strings |
| | tags | |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |media_selection| | widget for selecting media (images, | array containing arrays with |
| | documents) | urls for every format |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |contact_selection| | widget for selecting contacts | array containing array representations | |
| | | of the contact objects |
+-------------------------+---------------------------------------------+-----------------------------------------+
| |snippet| | widget for selecting snippets | array containing array representations |
| | | of the snippets |
+-------------------------+---------------------------------------------+-----------------------------------------+
Since recently I get the following error when trying to build the documentation using make build:
ERROR: Malformed table.
It also outputs this table again, but without any hint what is wrong here, and I can't find it. Can anybody help me out?
While trying to format the code correctly I found the error on my own... The row for contact_selection contained a pipe at the very end of the line, after some tabs...

Display record count in listbox using multiple tables and fields

i need help with a query, can't get it to work correctly. What i'm trying to achieve is to have a select box displaying the number of records associated with a particular theme, for some theme it works well for some it displays (0) when infact there are 2 records, I'm wondering if someone could help me on this, your help would be greatly appreciated, please see below my actual query + table structure :
SELECT theme.id_theme, theme.theme, calender.start_date,
calender.id_theme1,calender.id_theme2, calender.id_theme3, COUNT(*) AS total
FROM theme, calender
WHERE (YEAR(calender.start_date) = YEAR(CURDATE())
AND MONTH(calender.start_date) > MONTH(CURDATE()) )
AND (theme.id_theme=calender.id_theme1)
OR (theme.id_theme=calender.id_theme2)
OR (theme.id_theme=calender.id_theme3)
GROUP BY theme.id_theme
ORDER BY theme.theme ASC
THEME table
|---------------------|
| id_theme | theme |
|----------|----------|
| 1 | Yoga |
| 2 | Music |
| 3 | Taichi |
| 4 | Dance |
| 5 | Coaching |
|---------------------|
CALENDAR table
|---------------------------------------------------------------------------|
| id_calender | id_theme1 | id_theme2 | id_theme3 | start_date | end_date |
|-------------|-----------|-----------|-----------|------------|------------|
| 1 | 2 | 4 | | 2015-07-24 | 2015-08-02 |
| 2 | 4 | 1 | 5 | 2015-08-06 | 2015-08-22 |
| 3 | 1 | 3 | 2 | 2014-10-11 | 2015-10-28 |
|---------------------------------------------------------------------------|
LISTBOX
|----------------|
| |
| Yoga (1) |
| Music (1) |
| Taichi (0) |
| Dance (2) |
| Coaching (1) |
|----------------|
Thanking you in advance
I think that themes conditions should be into brackets
((theme.id_theme=calender.id_theme1)
OR (theme.id_theme=calender.id_theme2)
OR (theme.id_theme=calender.id_theme3))
Hope this help

Visual studio 2010 IDE layout

My current visual studio panel layout looks similar to the drawing below:
-----------------
| | | |
| | | |
| | | |
| | |--|
| | | |
| |---------| |
| | | |
-----------------
I really don't need the full height of the screen for the toolbox or server explorer and was wondering if there was a way to change the layout so that the bottom section extended all the way to the left edge of the screen like in this drawing:
-----------------
| | | |
| | | |
| | | |
| | |--|
| | | |
|------------| |
| | |
-----------------
I am space constrained on the right side, so a symetric layout with the bottom section running full width wouldn't be acceptable. I've tried dragging stuff around but haven't had any luck in getting VS to position the panels as I want. Is my desired layout not possible or am I missing the right way to coax the layout into fitting?
Yes, you can do this. When you are dragging the toolbox, note the little "targets" in the center of the screen. Drop the toolbox onto the target that corresponds with the area where you want it docked.
See here for more detail and pics.
Drag the bottom panel off and make sure to mouse over the icon that appears all the way at the bottom center of the screen, although this will cause it to take up the whole bottom portion of the IDE,
That's an easy process.
Drag the window docked in the bottom to middle of the VS window so that it floats in the middle.
Now when you drag it, a helper would apper to doc it.
You'll have some dynamic docking helpers like below.
↑
↑
← ← → →
↓
↓
if you chose the downarrow in the dock helper in the middle, you'll get the layout like this.
| | | |
| | | |
| | | |
| | |--|
| | | |
| |---------| |
| | | |
-----------------
If you chose the downarrow all the way at the bottom, you'll get the layout like this.
| | | |
| | | |
| | | |
| | |--|
| | | |
|---------------|
| |
-----------------

Resources