AutoIT get child window from a parent window - autoit

I came across a problem which looks trivial to me but I can't find a valid solution after googling for an hour.
I want to fill in a window security popup window.
This is part of a selenium test, that can run in parallel next to other tests.
So in order to be sure that my autoit script fills in the correct popup (and not form another test that is running), i want to identify this popup as a child of a parent window. Is there an easy way to do this?
The code i had so far:
$browserHandl = WinWait($parentTitle)
WinActivate($browserHandl, "")
$popUpHandl = WinWait("Windows Security")
So my fear is that WinWait will return one of all the open Windows Security popups currently open on the machine.
So:
1. Is there a way to obtain the childwindows of a parent window when i got its handle?
2. Is my fear correct that i indeed will have a race condition with multiple tests running at the same time?

input box open
input box hidden
I used a progress to hide what I needed to.
add #include
$file = GUICtrlCreateInput("", 10, 5, 350, 25)
You need 3 lines for the Marquee
Local $iProgress = GUICtrlCreateProgress(30, 10, 270, 20, $PBS_MARQUEE)
GUICtrlSendMsg($iProgress, $PBM_SETMARQUEE, 1, 50)
and to make it cover the input box
and 0 to stop and remove the Marquee GUICtrlSendMsg($iProgress, $PBM_SETMARQUEE, 0, 50) ; Send the message $PBM_SETMARQUEE and wParam of 0 to stop the scrolling marquee.

Related

Maximize client window vertically to the half left of screen

How to configure a shortcut key in awesome to toggle a client window vertical maximization to the left half of the screen (snap to left)?
Module awful.placement has an example that may help, but there is no mention on how to implement a toggle that would be able to maximize the client or restore it to its prior size and location.
Currently I have the following in rc.lua:
clientkeys = gears.table.join(
-- ...
awful.key({ modkey, "Mod1" }, "Left",
function (c)
-- Simulate Windows 7 'edge snap' (also called aero snap) feature
local f = awful.placement.scale + awful.placement.left + awful.placement.maximize_vertically
f(c.focus, {honor_workarea=true, to_percent = 0.5})
end ,
{description = "maximize vertically to the left half of screen", group = "client"})
)
Are you looking for awful.placement.restore? It seems to do be what you are looking for. However, the documentation says one has to "set[...] the right context argument" for this, but does not mention which one that is.
I think it should be scale since it is the first one in your chain, but I fail to see the logic in calling this chain "scale".
To turn that into a toggle, you can "invent" a new client property. Something like this: if c.my_toggle then print("a") else print("b") end c.my_toggle = not c.my_toggle. This way, the my_toggle property tracks which function you have to call.

Auto-generating widgets in awesome-wm

So what I currently want to do is pretty much implement rofi in awesome.
The reason I want to do this and I don't just use rofi is because I want to learn how to 'auto-generate' widgets in awesome.
This will come in handy later when I'll implement things like network widgets that when clicked, shows you a panel, shows you the wifi hotspots available as rows, etc etc. So it's just for me to learn how awesome works better. But also, I want a program launcher.
And also, before someone suggests it, I already know that there's a built-in launcher in awesome, and I also know that there's this. This is not what I'm looking for. I want to have the same thing thing rofi and dmenu have: I want to have suggestions pop up when you press keys. and I want to be able to click on the suggestions, etc.
What I want is something like this: uhhhh
So what I'm having problems is this: how do I auto-generate the rows? I want to be able to specify in only one place how many rows I want, and have awesome do the rest.
I've looked through Elv's github and I found radical and even though what he made is a menu system, I thought that I could use some of his code to do what I want. But I can't for the love of god figure out how it works. No offense to him, but it's not all too well docummented, even for users, and for actually explaining how the code works there's no docummentation.
So My question is: How can I make this work? How would I go about making the widgets that act as the rows automatically?
TL;DR:
i want to write a program launcher like rofi in awesome
i want to be able to specify only in one place the number of rows
therefore, (((I think))) I need to automatically generate widgets as rows somehow, how can I do it?
EDIT:
What I want is to be able to create the rows of my launcher automatically. I know I can hardcode the rows myself, have each row have a different id and then I can write a function that on each keypress, will update each widget with the most relevant matches. So it would be something like (not tested at all):
local wibox = require("wibox")
local awful = require("awful")
local num_rows = 10
local row_height = 40
-- set the height of the background in accordance to how many rows there are,
-- and how high each row should be
local prompt_height = row_height * num_rows
local prompt_width = 300
-- make a widget in the middle of the screen
local background = wibox({
x = awful.screen.focused().geometry.width / 2 - prompt_width / 2,
y = awful.screen.focused().geometry.height / 2 - prompt_height / 2,
width = prompt_width,
height = prompt_height,
bg = "#111111",
visible = false,
ontop = false
})
local rofi_launcher = wibox.widget({
widget = background,
{
-- get a flexible layout so the searchbox and the suggestion boxes get
-- scaled to take up all the space of the background
layout = wibox.layout.flex.vertical,
{ -- the prompt you actually type in
-- set id here so we can adjust its ratio later, so the magnifying
-- glass will end up on the right, and the texbox will take up the left side
id = "searchbox_and_mangifying_glass",
layout = wibox.layout.ratio.horizontal,
{
-- set id so we can use it as a prompt later
id = "searchbox",
widget = wibox.widget.textbox,
},
{
widget = wibox.widget.imagebox,
icon = '~/path/to/magnifying_glass_icon.svg',
},
},
{ -- this is where I actually create the rows that will display suggestions
{ -- row number 1
-- make a background for the textbox to sit in, so you can change
-- background color later for the selected widget, etc etc.
widget = wibox.widget.background,
{
-- give it an id so we can change what's displayed in the
-- textbox when we press keys in the prompt
id = "suggestion_1",
widget = wibox.widget.textbox,
},
},
{ -- row number 2
-- background, again
widget = wibox.widget.background,
{
-- id and textbox again
id = "suggestion_2",
widget = wibox.widget.textbox,
},
},
-- and another 8 (according to the `num_rows` variable) of the same two
-- textboxes above. This is exactly my problem. How can I make these
-- textboxes automatically and still be able to interact with them to
-- display suggestions on the fly, as the user types keys into the prompt?
},
},
})
If this is not clear enough please do let me know what you don't understand and I will update my question.
Equally untested as your code, but this creates a tables of textboxes instead of using the declarative layout to create all these textboxes:
[SNIP; For shorter code I removed some stuff at the beginning]
local textboxes = {}
local widgets = {}
for i = 1, num_rows do
local tb = wibox.widget.textbox()
local bg = wibox.widget.background(tb)
bg:set_bg("#ff0000") -- The original code did not set a bg color, but that would make the bg widget useless...?
tb.id = "suggestion_" .. tostring(i) -- This is likely unnecessary, but the original code set these IDs, too
table.insert(textboxes, tb)
table.insert(widgets, bg)
end
local rofi_launcher = wibox.widget({
widget = background,
{
-- get a flexible layout so the searchbox and the suggestion boxes get
-- scaled to take up all the space of the background
layout = wibox.layout.flex.vertical,
{ -- the prompt you actually type in
[SNIP - I did not change anything here; I only removed this part to make the code shorter]
},
widgets
},
})
-- Now make the textboxes display something
textboxes[3].text = "I am the third row"
textboxes[5].text = "I am not"

How can I use my handle number?

I have 2 windows that have the same title. So, I have to detect them by handle. They use very long time to begin from the beginning of my code, too. So I have to begin them before, then debug the middle of code by detect them by their handle. The codes are difference between them, so I must specify the handle by my hand. However, thank you very much.
I got my own window's handle number by Au3Info application.
But It didn't work when I use like this:
;run Au3Info.exe to get calc.exe window's handle number
;then activate minimizing calc.exe by copied window's handle number from Au3Info.exe
Run("C:\Program Files\AutoIt3\Au3Info.exe")
WinWaitActive("(Frozen) AutoIt v3 Window Info")
WinSetOnTop("(Frozen) AutoIt v3 Window Info", "", 0)
WinMove("(Frozen) AutoIt v3 Window Info","",0,0)
Run("calc.exe")
WinWaitActive("Calculator")
Winmove("Calculator","",500,500)
WinActivate("(Frozen) AutoIt v3 Window Info")
WinWaitActive("(Frozen) AutoIt v3 Window Info")
MouseClickDrag("left",261, 156,505,505)
MouseClick("left",136, 374,10) ;copy calculator window's handle number form Au3Info
WinSetState ( "Calculator", "", #SW_MINIMIZE )
WinActivate(ClipGet ( ))
;$hWnd=0x004D01DE ; window's handle number copy from Au3Info
;ConsoleWriteError(#crlf & WinActivate($hWnd) & #crlf)
Above, I want to active current session 0x004D01DE-handle windows, but it didn't work, returned me "0", not found specific window. Although the window's handle number still be the same, when I recheck.
I debugging some part of my script, so I have to copy the specific handle window's number by myself to save a long period of time for debugging from the full code.
Did I use that window's handle number in right way?
I see no reason to use Au3Info.exe. WinWaitActive already returns the handle. Just use it:
Run("calc.exe")
$hCalc=WinWaitActive("Calculator")
MsgBox(0,"Handle","Calculatior's handle is: " & $hCalc)
WinMove($hCalc,"",500,500)
WinSetState($hCalc,"",#SW_MINIMIZE)
Another possibility is WinGetHandle
The answer is HWnd(). Just change WinActivate(ClipGet()) to WinActivate(HWnd(ClipGet())).

Execute command when mouse touches screen edge in Awesome-wm

I'm new to doing custom lua for the rc.lua in Awesome and I'm having a bit of trouble working out how to launch something based on the mouse position. This is what I have, so-far, but it's not doing anything.
-- Open todo when mouse hits right screen edge.
todo_timer = timer({timeout = 0.1})
todo_timer:add_signal("todopopup", function()
if mouse.coords.x >= 3198 then
scratch.drop("urxvt -e vim /home/ryan/to-do", "center", "right", 0.33, 1, "true")
end
end)
todo_timer:start()
--
Instead of using a timer, you could/should use the mousegrabber like the following:
mousegrabber.run(function(mouse)
if mouse.x > 3196 then
-- Do your stuff here
end
-- Return true, to continue grabbing the mouse
return true
end)
The problem with that approach is, that you can only register one mousegrabber at a time. So this is a perfect solution, if you just need to listen shortly for that mouse movements. If you need longer, you could stop the grabbing when you need the grabber for something else (mainly client re sizing and moving) and start it, when that that is finished.
This almost works as intended. For some reason the scratchpad appears on screen 1 the first time and does not center vertically properly (this problem only occurs with a horizontal position of "right", I assume it's a problem with scratchpad), for me, but it should work for people who do not have a multi-monitor setup or for launching other commands of your choice.
-- Open todo when mouse hits right screen edge.
local function todopad()
scratch.drop("urxvt -e vimpager /home/ryan/to-do", "center", "right", .20, 800, "true", 2)
end
todo_timer = timer({timeout = 1})
todo_timer:add_signal("timeout", function()
if mouse.coords()["x"] >= 3196 then
todopad()
end
end)
todo_timer:start()
--

What is CLASS:wxWindowNR in AutoIt, and how can I click the control?

I'm using AutoIt to try to automate the use of a program called PhotoZoom 4. I'm running into a problem where I need to type text into a box where this is the Class and instance:
[CLASS:wxWindowNR; INSTANCE:8]
I've tried the following with no luck (each line is a separate attempt):
ControlSetText($batchWindowTitle2, "", "[CLASS:wxWindowNR; INSTANCE:8]", '800')
ControlCommand($batchWindowTitle2, "", "[CLASS:wxWindowNR; INSTANCE:8]", "AddString", '800')
ControlClick($batchWindowTitle2, "", "[CLASS:wxWindowNR; INSTANCE:8]", "left", 1, 32, 12)
Send("800")
I expected either ControlCommand or ControlSetText to work at least, but they didn't.
I googled this problem as well, but I literally couldn't find any references of "wxWindowNR" anywhere on the web. I'll attach a photo of the control.
If you don't know what wxWindowNR is either (I expect you might not since I have not seen it anywhere else on the web), what's the best way to automate clicking and typing in the box? I thought ControlClick would do it...
"Tab-cycle" (for example, send("{Tab 5}")) through all your controls until you get there in your GUI and then use a simple send().

Resources