AwesomeWM - open/close window callback - awesome-wm

I have following idea:
I have a wallpaper in 2 version. One original and second a bit blurry. I want to change the wallpaper from original when first window/program opens on the screen. Once the last window/program is closed change the wallpaper back.
Also when I change between tags I want to check if any window/program is open or not and then adjust the wallpaper.
How can I do that?
P.S.
I use nitrogen to set wallpaper
AwesomeWM client created/removed callback

I found a way to set the wallpaper depending on the visible clients, but I have no idea how your Nitrogen calls look like. Just replace the naughty.notify lines with your Nitrogen invocations.
Somewhere in your rc.lua, you should find something like this:
awful.screen.connect_for_each_screen(function(s)
Add the following to that function
tag.connect_signal("property::selected", function(t)
if #s.clients > 0 then
naughty.notify({text = "set blurry wallpaper", timeout = 1})
else
naughty.notify({text = "set original wallpaper", timeout = 1})
end
end
)
table.getn is deprecated but this is the solution for older lua versions:
tag.connect_signal("property::selected", function(t)
if table.getn(s.clients) > 0 then
naughty.notify({text = "set blurry wallpaper", timeout = 1})
else
naughty.notify({text = "set original wallpaper", timeout = 1})
end
end
)

Related

Check if WinList() contains a certain title

I am listing all open windows using WinList() to get window title and -handle in AutoIt.
I want to check if resulting array contains a specific title. What is the best way to do this? There is no WinList().Contains("TitleName") or something like that.
Local $aList = WinList() ;Gets a list of Window Titles and IDs
OK, I got it now:
For $i = 1 To $aList[0][0]
If $aList[$i][0] = "Title/String you search for" Then
MsgBox($MB_SYSTEMMODAL, "", "MessageBox shows this text if title is in list.")
EndIf
Next
You could also use something similar to what you wrote.
#include <Array.au3>
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 0) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Local $title = 'AutoIt Help (v3.3.14.2)'
Local $aList = WinList()
;~ _ArrayDisplay($aList)
Local $iIndex = _ArraySearch($aList,$title)
WinActivate($aList[$iIndex][1], '')
Window exists?
"I am listing all open windows … I want to check if … contains a specific title. What is the best way to do this?"
As per Documentation - Function Reference - WinExists() :
Checks to see if a specified window exists.
Example.
Global Const $g_sWndTitle = 'Window title here'
If WinExists($g_sWndTitle) Then WinFlash($g_sWndTitle)
Retrieve window handle, -text and -title
Handle
"… to get window title and -handle …"
As per Documentation - Function Reference - WinGetHandle() :
Retrieves the internal handle of a window.
Example:
Global Const $g_sWndTitle = 'Window title here'
Global $g_hWnd
If WinExists($g_sWndTitle) Then
$g_hWnd = WinGetHandle($g_sWndTitle)
WinFlash($g_hWnd)
EndIf
Text
As per Documentation - Function Reference - WinGetText() :
Retrieves the text from a window.
Example:
Global Const $g_sWndTitle = 'Window title here'
If WinExists($g_sWndTitle) Then
WinFlash($g_sWndTitle)
ConsoleWrite(WinGetText($g_sWndTitle) & #CRLF)
EndIf
Title
Likewise, WinGetTitle().

SciTE Script - How to get inside a Tree Control to set checkboxes

I'm using AutoIt and SciTE to create an installation script. The problem I am running into is that there is a tree menu for selection of features. I can select the whole treeview (SysTreeView32), but am not sure how to get inside it to check the boxes without doing a mouse move and click (not a great option).
The Treeview looks like this:
The Control Info from AutoIT is like this:
I'm sure it is possible, just can't figure out how to do it. This is my first attempt a such a script. Creating a response file does not work for this exe for some reason. So - this appears to be my only way out to create a somewhat silent install (not silent anymore, but at least automated).
* EDIT - Current State of Things *
I did figure out how to do some of this, but I still can't figure out if the items is selected before accessing it. So - since it toggles, I could be turning off a feature I want!
$hWnd = WinWaitActive($WindowTitle, 'Select Features')
$tvCtl = ControlGetHandle($WindowTitle, '', 'SysTreeView321')
$firstItem = _GUICtrlTreeView_FindItem($tvCtl, 'eBooks')
_GUICtrlTreeView_SelectItem($tvCtl, $firstItem, $TVGN_FIRSTVISIBLE)
_GUICtrlTreeView_ClickItem($tvCtl, $firstItem, "left", True, 1)
Send('{SPACE}')
I wouldn't think I would have to send the space since I sent the ClickItem, but seems so.
I could also do this:
ControlTreeView($hWnd, '', $tvCtl, 'Select', '#0')
ControlSend($hWnd, '', $tvCtl, ' ')
That will toggle the first one. So - i can count them all up and do it that way.
But when I check for "IsEnabled" or "IsChecked", it always says NO. So - I can't check the ones I need only. I have to hope their status is what I expect.
Here is how I am checking "IsChecked" and "IsEnabled":
If ControlCommand($hWnd, '', $logTool, 'IsEnabled') then
ConsoleWrite('Log Tool - IsEnabled' & #CRLF)
Else
ConsoleWrite('Log Tool - NOTEnabled' & #CRLF)
EndIf
and
If ControlCommand($hWnd, '', $logTool, 'IsChecked') then
ConsoleWrite('Log Tool - IsChecked' & #CRLF)
Else
ConsoleWrite('Log Tool - NOTChecked' & #CRLF)
EndIf
It always comes back NOTEnabled and NOTChecked. I made sure that I ran the same procedure above: FindItem, SelectItem, ClickItem. And, the correct item is highlighted/selected when this procedure is run - I can see that. So - it just isn't returning a proper value.
Opt('WinTitleMatchMode', 2)
$hWnd = WinGetHandle("InstallShield Wizard") ; Notice the correct title
$hTree = ControlGetHandle($hWnd, '', "[CLASS:SysTreeView32;INSTANCE:1]")
; == Now you can interact with the treeview with functions from "GuiTreeView.au3"
EDIT:
Try this
; Select the item so:
_GUICtrlTreeView_SelectItem($hTree, $hItem, $TVGN_CARET)
; Get checked state:
_GUICtrlTreeView_GetChecked($hTree, $hItem)
For more deatails read the AutoIt help.

How to expand a tree view using AutoIt

The UI is as following:
The tool "AutoIt Window Info" can only locate the elements in red (red rectangle area), the sub items can not be located.
So how can I expand or operate these items?
Usually Windows controls can be accessed using keystrokes as well.
In the screen-dump the Farmtt element is selected. That would be your starting point.
You may try:
Send("{DOWN}") Move down an element.
Send("{TAB}") Navigate to next control (button, checkbox, etc)
Send("{NumPadMult}") Recursively expands folders in a SysTreeView32.
Send("{ENTER}") ENTER key on the main keyboard
etc.
Reference:
https://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm
There are two things over here:
1) Use the following code snippet:
;Gets the handle for the text
Func readFirstlevelTreeNodes($hWndCtrl)
Local $firstItemHandle = _GUICtrlTreeView_GetFirstItem ($hWndCtrl)
Local $iCount = _GUICtrlTreeView_GetSiblingCount( $hWndCtrl, $firstItemHandle )
Dim $aRet[$iCount]
$aRet[0] = $firstItemHandle
For $index = 1 To $iCount - 1
$aRet[$index] = _GUICtrlTreeView_GetNextSibling ( $hWndCtrl, $firstItemHandle )
$firstItemHandle = $aRet[$index]
Next
getTreeNodeTextList($hWndCtrl,$aRet)
EndFunc
; Gets the text for given sibling node handle lists
Func getTreeNodeTextList($hWndCtrl,$aRet)
ConsoleWrite("Tree Node first level list"&#CRLF)
For $index = 0 To Ubound($aRet) -1
ConsoleWrite(_GUICtrlTreeView_GetText ( $hWndCtrl, $aRet[$index] )&#CRLF)
Next
EndFunc
You may see the output for the first level tree nodes.
2) If you still dont see the output then please verify the control handle values and window handles. If they are correct and it still doesnt show the first level tree nodes then try running your sciTE editor as administrator.
I think this should help.

How to tell if an object has been touch by the player in gml code

Hey am going to give an example of what am trying to do imagine that i have 5 circle sprites and in my gml code i want to do something like this if cirlce_1 was touch then you can touch circle_2 and if circle_2 was touch then you can touch cirlce_3. Please who can help me with this, willing to give a reward via paypal.
Touch events in Game Maker are treated as mouse events. If you want the circles to only allow the player to touch them in order, you can assign each one to have a number and make them all the same object. Take a look at this:
Script to create circles
counter = 0;
lastball = 0;
for(i = 0; i < 10; i++){//Make that third part "i += 1" if using a version before Studio
c = instance_create(floor(random(room_width)), floor(random(room_height)), objCircle);
lastball++;
c.myNum = lastball;
c.radius = 16;//Or whatever radius you want
};
The for statement here automatically generates circles around the room, but if you want manual control, try this:
newCircle()
c = instance_create(argument0, argument1, objCircle);
c.myNum = lastball;
c.radius = 16;
lastball++;
This will create a new circle wherever you want and will automatically increment lastball as well every time it's called. For instance, you could say newCircle(16, 27);.
In the step code for objCircle
if(mouse_check_button_pressed(mb_left) && point_distance(x, y, mouse_x, mouse_y) < radius && counter == myNum){
counter++;//Or counter += 1 in versions before Studio
//Insert whatever circles do when clicked here
};
The circles can be made to do anything when clicked. Since they're all the same object, perhaps you could use a switch statement so each one does something different depending on its number.
Let me know if there's anything else I can help with.

Regd: WebDriver on secure Certificate

I have been using WebDriver for past 6 months.
There are couple of issues am facing right now [Version 2.3.1]:
a) when i try to get the element for the override link on the security certificate [https] page in IE through webdriver findElement, its not able to find that element but the selenium RC works fine.
Then i got a fix for tht by using:
webDriver.navigate().to(javascript:document.getElementById('overridelink').click());
Note :
I tried using the below code to fetch the element on security certificate page , but it returns
the body element
WebElement activeElement() [WebElement with focus, or the body element if no element with focus can be detected.], why its not able to pick the element by using findelement ?
b) i connected the remote network through SSL for running the webdriver test, am not able to click the override link on secure certificate [https] page?
c) is it better approach implementing webdriver [currently am using this] directly instead of using any framework like jbehave ?
Please provide your suggestions
Thanks,
Jayaraj A
Thank you for workaround!
For Java, your solution will look just a bit different and it helped me:
//driver is initialised somewhere before, for example, as RemoteWebDriver
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
Yeah, I had similar problems. Webdriver doesn't seem to have complete information on
the Certificate error page for some reason.
I'm on Windows XP SP3, running IE 7 with Python/Webdriver
I'm using this hack to get around the certificate error page:
(Help, I still can't get freeeking Markdown to format a code block...)
#!/c/Python27/python
import win32con
import win32gui
def certificate_continue():
"""
Find the IE Window that has a Certificate Error and try to continue anyway.
We'll use the win32 modules to find the right window & child window,
then write some Javascript into the address bar and execute to continue.
"""
def _enumWindowsCallback(hwnd, windows):
"""
Cannibalized from Gigi Sayfan (WindowMover)
http://www.devx.com/opensource/Article/37773/1954
This appends window information as a 3-tuple to the list
passed into win32gui.EnumWindows()
"""
class_name = win32gui.GetClassName(hwnd)
# apparently win32gui.GetWindowText() only works to get the text
# on a button or a label not really for edit windows.
text = win32gui.GetWindowText(hwnd)
windows.append((hwnd, class_name, text))
def _get_certificate_error_window():
"""
all_windows[] gets filled up with a list of tuples, then loop through
it filtering on class and the window text (title bar text).
Assumes only one 'Certificate Error' window.
"""
all_windows = []
win32gui.EnumWindows(_enumWindowsCallback, all_windows)
for win in all_windows:
class_name = win[1]
title_bar_text = win[2]
if class_name == 'IEFrame' and \
'Certificate Error: Navigation Blocked' in title_bar_text:
return win
def _get_edit_text(hwnd):
"""
This function courtesy of Omar Raviv with huge help from Simon Brunning.
http://www.brunningonline.net/simon/blog/archives/000664.html
"""
buf_size = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0)
buf_size += 1 # don't forget that null character boys...
buffer = win32gui.PyMakeBuffer(buf_size)
# odd, we're telling them how big the text is that they're giving
# back to us
win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, buf_size, buffer)
# don't need the null character now for Python
return buffer[:buf_size]
def _get_address_bar(parent_handle):
"""
There appears to be several 'Edit' windows within each browser window.
From Microsoft: If a child window has created child windows of its own,
EnumChildWindows enumerates those windows as well.
"""
childwins = []
win32gui.EnumChildWindows(parent_handle, _enumWindowsCallback,
childwins)
for win in childwins:
child_handle = win[0]
class_name = win[1]
if 'Edit' in class_name:
edit_text = _get_edit_text(child_handle)
if 'http://' in edit_text or 'https://' in edit_text:
return child_handle # then this must be it...
# begin certificate_continue
target_win = _get_certificate_error_window()
try:
cert_err_handle = target_win[0]
except TypeError:
print "OK, no Certificate Error window available"
return(1)
address_bar_handle = _get_address_bar(cert_err_handle)
# any better way to check the handle ?
if not win32gui.IsWindow( address_bar_handle):
print "Choked getting IE edit window"
return(1)
# now, need to send this JavaScript text to the browser Address Bar
javascript_continue = 'javascript: var continue_element = document.getElementById("overridelink"); continue_element.click();'
win32gui.SendMessage(address_bar_handle, win32con.WM_SETTEXT, 0,
javascript_continue)
# OK, and finally, send a carriage return to the address bar
# This last abomination, courtesy of Claudiu
# http://stackoverflow.com/#questions/5080777/
# what-sendmessage-to-use-to-send-keys-directly-to-another-window
win32gui.SendMessage(address_bar_handle, win32con.WM_KEYDOWN,
win32con.VK_RETURN, 0)
return(0)
if __name__ == '__main__':
status = certificate_continue()
exit(status)

Resources