All examples I found was C# related, but I'm unfamiliar with it.
My task is to provide some kind of automation for testing. I have installer which first buttons are inside of SysListView32, as I can understand
My target is to select them, choose button by its name and click it
The last part is obvious:
GetWindowText(control, window_name, 256);
if(strcmp.....
{
do smth
}
But when it comes to SysListView32 I can't understand how to extract its object and names in C
Take a look at LVM_GETITEM. The MSDN documentation page is here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb774953(v=vs.85).aspx. The documentation is actually pretty thorough.
A short example that will retrieve the "lParam", the image list index for the icon and the text of an item:
LVITEM lvItem;
TCHAR szBuffer[MAX_PATH + 1] = { 0 };
lvItem.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
lvItem.iItem = iItem;
lvItem.iSubItem = 0;
lvItem.pszText = szBuffer;
lvItem.cchTextMax = MAX_PATH;
if(ListView_GetItem(m_hListView,&lvItem))
{
/* success! the item details are in lvItem */
}
Related
Whenever I open a PDF-file in Illustrator for edithing, there are a lot of ungrouped and uncategorized Elemetns in it.
So I tried to select multiple elements with a spicific name with the below Script, but since the name of the elements are between Angle-brackets "<someName>" script wont select them:
function selectPageItemsByName(items, name) {
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.name === name) {
item.selected = true;
}
}
}
function main() {
var document = app.activeDocument;
var name = '<someFile>';
document.selection = null;
selectPageItemsByName(document.pageItems, name);
}
main();
Femkeblanko from Adobe Community says: Items with angle brackets in their label (unless user-created) are unnamed. They correspond to an empty string, i.e. "".
If I remove the Brackets from the name of the Elemetns, the script works but I have a lot of Elements and it needs time.
So, isn't there a way to salve it?
this is a pretty creative way:
// Select->Objects->Clipping Mask
app.executeMenuCommand("Clipping Masks menu item");
// Edit->Clear
app.executeMenuCommand("clear");
but it isn't really documented very well
some links for future reference:
Where is the perfect reference of adobe illustrator script?
https://ai-scripting.docsforadobe.dev/index.html
https://ten-artai.com/illustrator-ccver-22-menu-commands-list/
https://github.com/ten-A/AiMenuObject
Using the Calendar component in Extjs 7.0 we noticed that the header cells didn't line up correctly with their columns if the language was set to Dutch:
When checking the source code I found the place where these values are added in the cell html;
In Ext.calendar.header.Base, in the setHeaderText function the following code exists:
var me = this,
D = Ext.Date,
value = me.getValue(),
format = me.getFormat(),
domFormat = me.domFormat,
cells = me.cells,
len = cells.length,
useDates = me.useDates,
cell, i;
if (!value) {
return;
}
value = D.clone(value);
for (i = 0; i < len; ++i) {
cell = cells[i];
if (useDates) {
cell.setAttribute('data-date', D.format(value, domFormat));
}
cell.setAttribute('data-day', value.getDay());
cell.innerHTML = D.format(value, format);
value = D.add(value, D.DAY, 1);
}
The innerHtml is set by formatting the Date(D) object which results in the 3 characters of that day. If you change this to just setting a 4 char value like cell.innerHTML = 'Test' the headers line up just fine:
But for some reason this doesn't work when using the D.format value. If somebody has any idea what causes this, I would love to hear.
I can't seem to test if this also goes wrong in another language cause for some reason my packages can't be loaded in anymore.
You can set(or fix) localization override localization constants.
Calendar use Ext.Date.dayNames and Ext.Date.getShortDayName().
All constants list you can see in localization package.
Fiddle example
I have a simple XCB window. When I run my application and alt-tab, Gnome's window list displays my application as "unknown". The window's title bar shows the correct title.
Here's how I set its title:
xcb_change_property(WindowGlobal::connection,
XCB_PROP_MODE_REPLACE,
WindowGlobal::window,
XCB_ATOM_WM_NAME,
XCB_ATOM_STRING,
8,
strlen (title),
title );
Here's most of my window creation code:
int visualID = screen->root_visual;
xcb_colormap_t colormap = xcb_generate_id( connection );
WindowGlobal::window = xcb_generate_id( connection );
WindowGlobal::windowWidth = width == 0 ? screen->width_in_pixels : width;
WindowGlobal::windowHeight = height == 0 ? screen->height_in_pixels : height;
xcb_create_colormap( connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visualID );
const uint32_t eventmask = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION;
const uint32_t valuelist[] = { eventmask, colormap, 0 };
const uint32_t valuemask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
xcb_create_window(
connection,
XCB_COPY_FROM_PARENT,
WindowGlobal::window,
screen->root,
0, 0,
WindowGlobal::windowWidth, WindowGlobal::windowHeight,
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
visualID,
valuemask,
valuelist
);
xcb_map_window( connection, WindowGlobal::window );
xcb_size_hints_t hints = {};
xcb_icccm_size_hints_set_min_size( &hints, WindowGlobal::windowWidth, WindowGlobal::windowHeight );
xcb_icccm_size_hints_set_max_size( &hints, WindowGlobal::windowWidth, WindowGlobal::windowHeight );
xcb_icccm_set_wm_size_hints( WindowGlobal::connection, WindowGlobal::window, XCB_ATOM_WM_NORMAL_HINTS, &hints );
xcb_atom_t protocols[] =
{
WindowGlobal::wm_delete_window
};
xcb_icccm_set_wm_protocols( WindowGlobal::connection, WindowGlobal::window,
WindowGlobal::wm_protocols, 1, protocols );
How do I make XCB to set the text that shows in Gnome's window list?
The right property in xcb is XCB_ATOM_WM_CLASS.
I have seen some code on GitHub, where two strings were being concatenated with a "\0".
(I saw it in awesomeWM/awesome/xwindow.h and other window managers on GitHub)
This worked for me:
xcb_change_property(WindowGlobal::connection,
XCB_PROP_MODE_REPLACE,
WindowGlobal::window,
XCB_ATOM_WM_CLASS,
XCB_ATOM_STRING,
8,
sizeof("title""\0""Title"),
"title\0Title" );
The second part of the string is what is shown in gnome.
Here is another common way I have seen:
char *res_name = "title";
char *res_class = "Title";
char *class_hint;
size_t class_len;
class_len = strlen(res_name) + 1 + strlen(res_class) + 1;
class_hint = (char *)malloc(class_len);
strcpy(class_hint, res_name);
strcpy(class_hint + strlen(res_name) + 1, res_class);
xcb_change_property (WindowGlobal::connection,
XCB_PROP_MODE_REPLACE,
WindowGlobal::window,
XCB_ATOM_WM_CLASS,
XCB_ATOM_STRING,
8,
class_len,
class_hint);
free(class_hint);
The char *res_class is what is shown in gnome.
With Xlib you would use the function XSetClassHint.
There you would use the XClassHint struct which consists of two strings:
char *res_name and char *res_class.
On https://www.x.org/releases/X11R7.7/doc/man/man3/XAllocClassHint.3.xhtml I found this:
The res_name member contains the application name, and the res_class member contains the application class. Note that the name set in this property may differ from the name set as WM_NAME. That is, WM_NAME specifies what should be displayed in the title bar and, therefore, can contain temporal information (for example, the name of a file currently in an editor’s buffer). On the other hand, the name specified as part of WM_CLASS is the formal name of the application that should be used when retrieving the application’s resources from the resource database.
I could find more information here and here.
I am working on the Keil uv4 IDE with an ARM Cortex-M3 in a bare metal C application. I have a GUI that I created that is currently in English, but I would like to give the user the ability to go between other languages like you can on a cell phone.
I have created a structure with all the words that are used called string_table_t.
struct string_table_t
{
char *word1;
char *word2;
char *word3;
};
My thought process was to have plain text files for the different languages and the list of words used contained in each one. Then I would do a load function that would link the pointers of the string table with the actual word.
Now, my initial menu is created statically by defining it like so. It is based off of Altium software platform.
// Test structure
struct string_table_t string_table = {"Main Menu","test1","test2"};
form_t mainmenu_form =
{
.obj.x = 0,
.obj.y = 0,
.obj.width = 240,
.obj.height = 320,
.obj.draw = form_draw,
.obj.handler = mainmenu_form_handler,
.obj.parent = NULL,
.obj.agui_index = 0,
.obj.visible = __TRUE,
.obj.enabled = __TRUE,
.caption.x = 0,
.caption.y = 0,
.caption.text = "Main Menu",
.caption.font = &helveticaneueltstdltext18_2BPP,
.caption.color = RGB(230,230,230),
.caption_line_color = RGB(241,101,33),
.caption.fontstyle = FS_NONE,
.caption.align = ALIGN_CENTRE,
.captionbarcolor = RGB(88,89,91),
.children = mainmenu_children,
.n_children = 4,
.relief = RELIEF_NONE,
.color = RGB(65,64,66),
};
What I want to do is replace the "Main Menu" of the caption.text with string_table.word1. Therefore, if I load a different language set, the menu will automatically be pointing to the correct char array. Doing this currently results in a error expression must have a constant value.
Now, I can get this to work by leaving the text null in the menu component and adding:
Link_pointer_to_menu() {
mainmenu_form.caption.text = string_table.Main_menu_text;
}
This will compile and work, but I would rather not have to have 100 or so of these statements. Is there a more optimal way of doing this?
I would recommend something like that:
enum MyWords
{
msgHello,
msgOpen,
msgClose,
msgMainMenu,
num_Messages,
};
char *string_table_t[num_Messages];
You should write code that loads your language file and assigns pointers in this array. After that in your code:
.caption.text = string_table_t[msgMainMenu];
The idea is that you give each string a symbolic name that is an offset in the table of strings. After that you use this offset as an index into the table.
I got a ton of movieclips in a class. Is there a more efficient way to apply a function to every instance in the class other than this?
var textArray:Array = [
interludes.interludeIntro.interludeBegin1,
interludes.interludeIntro.interludeBegin2,
interludes.interludeIntro.interludeBegin3,
interludes.interludeIntro.interludeBegin4,
interludes.interludeIntro.interludeBegin5,
interludes.interludeIntro.interludeBegin6,
interludes.interludeIntro.interludeBegin7,
//... ... ...
interludes.interludeIntro.interludeBegin15
];
for each (var interludeText:MovieClip in interludeBeginText)
{
interludeText.alpha = 0 //clear all text first
}
Also for some reason this doesn't work:
interludes.interludeIntro.alpha = 0;
It permanently turns that class invisible, even if I try to make specific instances visible later with:
interludes.interludeIntro.interludeBegin1.alpha = 1;
I have NO idea why the above doesn't work. I want to turn every single instance in the class interludeIntro invisible, but I want to turn specific instances visible later.
(btw I have no idea how to insert code on this website, pressing "code" doesn't do anything, so pardon the bad formatting)
I'm not really sure what you're asking, but what may be useful is that, in ActionScript you can refer to properties by name, like myObject["someProperty"].
Using that, you can iterate over properties if they follow some naming scheme, so for example:
for (var i:int = 1; i <= 15; i ++)
interludes.interludeIntro["interludeBegin" + i].alpha = 0;
That iterates over interludes.interludeIntro.interludeBegin1 through ...15 and sets their alpha properties to 0.
When you do that:
interludes.interludeIntro.alpha = 0;
you turn the movie clip and all its children invisible.
So later when you do that:
interludes.interludeIntro.interludeBegin1.alpha = 1;
You make the movie clip visible, but since its parent is still invisible, you don't see anything. The solution is to loop through the movie clips and make each of them invisible/visible.
// Keep the parent visible at all time
interludes.interludeIntro.alpha = 1;
for (var i:int = 0; i < textArray.length; i++) {
textArray[i].alpha = 0;
}
// Now this will work:
interludes.interludeIntro.interludeBegin1.alpha = 1;