Autoit Controlsend to child window - autoit

I have from 1-6 commandprompts in a window. When they weren't in the window, I could use controlsend fine.
Code:
$GUI2 = GUICreate("Consoles", 1020, 600, 1282, 300, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
$hwnd00 = WinGetHandle("Consoles")
If GUICtrlRead($Bungee) = 1 Then
$BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide)
If Not ProcessWait($BungeeServer) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Bungee")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Bungee")
Global $hwnd0 = WinGetHandle("Bungee")
EndIf
EndIf
If GUICtrlRead($server1) = 1 Then
$1 = Run("java " & $chosen & " -jar " & '"' & $file1 & '"' & "\minecraft_server.jar", $file1, $Hide)
If Not ProcessWait($1) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Server1")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server1")
Global $hwnd1 = WinGetHandle("Server1")
EndIf
EndIf
If GUICtrlRead($server2) = 1 Then
$2 = Run("java " & $chosen & " -jar " & '"' & $file2 & '"' & "\minecraft_server.jar", $file2, $Hide)
If Not ProcessWait($2) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Server2")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server2")
Global $hwnd2 = WinGetHandle("Server2")
EndIf
EndIf
If GUICtrlRead($server3) = 1 Then
$3 = Run("java " & $chosen & " -jar " & '"' & $file3 & '"' & "\minecraft_server.jar", $file3, $Hide)
If Not ProcessWait($3) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Server3")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server3")
Global $hwnd3 = WinGetHandle("Server3")
EndIf
EndIf
If GUICtrlRead($server4) = 1 Then
$4 = Run("java " & $chosen & " -jar " & '"' & $file4 & '"' & "\minecraft_server.jar", $file4, $Hide)
If Not ProcessWait($4) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Server4")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server4")
Global $hwnd4 = WinGetHandle("Server4")
EndIf
EndIf
If GUICtrlRead($server5) = 1 Then
$5 = Run("java " & $chosen & " -jar " & '"' & $file5 & '"' & "\minecraft_server.jar", $file5, $Hide)
If Not ProcessWait($5) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Server5")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server5")
Global $hwnd5 = WinGetHandle("Server5")
EndIf
EndIf
_WinAPI_SetWindowLong($hwnd0, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd0, $GUI2)
_WinAPI_SetWindowLong($hwnd1, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd1, $GUI2)
_WinAPI_SetWindowLong($hwnd2, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd2, $GUI2)
_WinAPI_SetWindowLong($hwnd3, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd3, $GUI2)
_WinAPI_SetWindowLong($hwnd4, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd4, $GUI2)
_WinAPI_SetWindowLong($hwnd5, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd5, $GUI2)
WinMove($hwnd0, "", 0, 0, 340, 300)
WinMove($hwnd1, "", 340, 0, 340, 300)
WinMove($hwnd2, "", 680, 0, 340, 300)
WinMove($hwnd3, "", 0, 300, 340, 300)
WinMove($hwnd4, "", 340, 300, 340, 300)
WinMove($hwnd5, "", 680, 300, 340, 300)
Earlier I used this: ControlSend("Server1", "", $hwnd1, 'stop' & '{ENTER}')
One line for each of the windows. How can I send information to them when they are in the parent window(Even if the parent window is hidden)?

This command allows the window search routines to search child windows as well as top-level windows.
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
0 = Only search top-level windows (default)
1 = Search top-level and child windows

Related

Downloading a Nested DT table in Shiny

I've got a nested DT table in my Shiny app. The child table is a list that gets passed and rendered into the table. When I go to add a download button via DT's built in method, the output contains the parent table data and then a list of [Object][Object].. instead of the actual child data.
Do I have to write my own downloadable button method instead of using DT's method or is there a original DT method that helps with this? Haven't found a solution yet.
Data
Parent
structure(list(Market = c("ABILENE, TX", "AKRON, OH"), `SQAD CPP ($)` = c(10,
49), `SQAD CPM ($)` = c(22, 30), `Override CPP ($)` = c(0, 0),
`Override CPM ($)` = c(0, 0)), .Names = c("Market", "SQAD CPP ($)",
"SQAD CPM ($)", "Override CPP ($)", "Override CPM ($)"), row.names = c(NA,
-2L), class = "data.frame")
Child
structure(list(Market = c("ABILENE, TX", "ABILENE, TX", "ABILENE, TX",
"ABILENE, TX", "ABILENE, TX", "ABILENE, TX", "ABILENE, TX", "ABILENE, TX",
"ABILENE, TX", "AKRON, OH", "AKRON, OH", "AKRON, OH", "AKRON, OH",
"AKRON, OH", "AKRON, OH", "AKRON, OH", "AKRON, OH", "AKRON, OH"
), Daypart = c(" Podcast", " Streaming/Digital Audio", "Afternoon Drive",
"Daytime", "Evening", "Mon-Fri Average", "Mon-Sun Average", "Morning Drive",
"Weekend", " Podcast", " Streaming/Digital Audio", "Afternoon Drive",
"Daytime", "Evening", "Mon-Fri Average", "Mon-Sun Average", "Morning Drive",
"Weekend"), `Mix (%)` = c(10L, 10L, 10L, 10L, 10L, 10L, 5L, 15L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 5L, 15L, 10L), `Spot:60 (%)` = c(4,
4, 4, 4, 4, 4, 2, 6, 4, 4, 4, 4, 4, 4, 4, 2, 6, 4), `Spot:30 (%)` = c(6,
6, 6, 6, 6, 6, 3, 9, 6, 6, 6, 6, 6, 6, 6, 3, 9, 6), `SQAD CPP ($)` = c(10,
6, 27, 31, 44, 32, 31, 26, 26, 34, 21, 170, 156, 112, 151, 136,
177, 95), `SQAD CPM ($)` = c(21, 13, 57.6, 64.8, 93.6, 68.4,
64.8, 54, 54, 21, 13, 104.5, 96.1, 69, 93, 83.6, 108.7, 58.5),
`Override CPP ($)` = c(10, 6, 27, 31, 44, 32, 31, 26, 26,
34, 21, 170, 156, 112, 151, 136, 177, 95), `Override CPM ($)` = c(21,
13, 57.63, 64.83, 93.64, 68.43, 64.83, 54.03, 54.03, 21,
13, 104.49, 96.13, 68.96, 92.99, 83.59, 108.67, 58.51), population = c(47200L,
47200L, 47200L, 47200L, 47200L, 47200L, 47200L, 47200L, 47200L,
162700L, 162700L, 162700L, 162700L, 162700L, 162700L, 162700L,
162700L, 162700L), slider_60s = c(0.4, 0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4,
0.4), slider_30s = c(0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6,
0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6)), .Names = c("Market",
"Daypart", "Mix (%)", "Spot:60 (%)", "Spot:30 (%)", "SQAD CPP ($)",
"SQAD CPM ($)", "Override CPP ($)", "Override CPM ($)", "population",
"slider_60s", "slider_30s"), class = "data.frame", row.names = c(NA,
-18L))
Code
# Bind the market level and mix breakout data together for the final table
market_mix_table <- reactive({
# Take a dependency on input$goButton
input$goButton
isolate({
markets <- market_costings_gross_net()
mix_breakout <- mix_breakout_digital_elements()
# Make the dataframe
# This must be met length(children) == nrow(dat)
Dat <- NestedData(
dat = markets,
children = split(mix_breakout, mix_breakout$Market)
)
return(Dat)
})
})
# Render the table
output$daypartTable <- DT::renderDataTable({
Server = FALSE
# Whether to show row names (set TRUE or FALSE)
rowNames <- FALSE
colIdx <- as.integer(rowNames)
# The data
Dat <- market_mix_table()
parentRows <- which(Dat[,1] != "")
callback_js = JS(
"var ok = true;",
"function onUpdate(updatedCell, updatedRow, oldValue) {",
" var column = updatedCell.index().column;",
" if(column === 8){",
" ok = false;",
" }else if(column === 7){",
" ok = true;",
" }",
"}",
sprintf("var parentRows = [%s];", toString(parentRows-1)),
sprintf("var j0 = %d;", colIdx),
"var nrows = table.rows().count();",
"for(var i=0; i < nrows; ++i){",
" if(parentRows.indexOf(i) > -1){",
" table.cell(i,j0).nodes().to$().css({cursor: 'pointer'});",
" }else{",
" table.cell(i,j0).nodes().to$().removeClass('details-control');",
" }",
"}",
"",
"// make the table header of the nested table",
"var format = function(d, childId){",
" if(d != null){",
" var html = ",
" '<table class=\"display compact hover\" ' + ",
" 'style=\"padding-left: 30px;\" id=\"' + childId + '\"><thead><tr>';",
" for(var key in d[d.length-1][0]){",
" html += '<th>' + key + '</th>';",
" }",
" html += '</tr></thead><tfoot><tr>'",
" for(var key in d[d.length-1][0]){",
" html += '<th></th>';",
" }",
" return html + '</tr></tfoot></table>';",
" } else {",
" return '';",
" }",
"};",
"",
"// row callback to style the rows of the child tables",
"var rowCallback = function(row, dat, displayNum, index){",
" if($(row).hasClass('odd')){",
" $(row).css('background-color', 'white');",
" $(row).hover(function(){",
" $(this).css('background-color', 'lightgreen');",
" }, function() {",
" $(this).css('background-color', 'white');",
" });",
" } else {",
" $(row).css('background-color', 'white');",
" $(row).hover(function(){",
" $(this).css('background-color', 'lightblue');",
" }, function() {",
" $(this).css('background-color', 'white');",
" });",
" }",
"};",
"",
"// header callback to style the header of the child tables",
"var headerCallback = function(thead, data, start, end, display){",
" $('th', thead).css({",
" 'color': 'black',",
" 'background-color': 'white'",
" });",
"};",
"",
"// make the datatable",
"var format_datatable = function(d, childId, rowIdx){",
" // footer callback to display the totals",
" // and update the parent row",
" var footerCallback = function(tfoot, data, start, end, display){",
" $('th', tfoot).css('background-color', '#F5F2F2');",
" var api = this.api();",
"// update the Override CPM when the Override CPP is changed",
" var col_override_cpp = api.column(7).data();",
" var col_population = api.column(9).data();",
" if(ok){",
" for(var i = 0; i < col_override_cpp.length; i++){",
" api.cell(i,8).data(((parseInt(col_override_cpp[i])*100)/(parseInt(col_population[i])/1000)).toFixed(0));",
" }",
" }",
"// update the Override CPP when the Override CPM is changed",
" var col_override_cpm = api.column(8).data();",
" for(var i = 0; i < col_override_cpm.length; i++){",
" api.cell(i,7).data(((parseInt(col_override_cpm[i])*parseInt(col_population[i])/1000)/(100)).toFixed(0));",
" }",
"// Update the spot mixes",
" var col_mix_percentage = api.column(2).data();",
" var col_mix60_mix30 = api.column(10).data();",
" var col_mix30_mix15 = api.column(11).data();",
" for(var i = 0; i < col_mix_percentage.length; i++){",
" api.cell(i,3).data((parseFloat(col_mix_percentage[i])*parseFloat(col_mix60_mix30[i])).toFixed(1));",
" api.cell(i,4).data((parseFloat(col_mix_percentage[i])*parseFloat(col_mix30_mix15[i])).toFixed(1));",
" }",
"// Make the footer sums",
" api.columns().eq(0).each(function(index){",
" if(index == 0) return $(api.column(index).footer()).html('Mix Total');",
" var coldata = api.column(index).data();",
" var total = coldata",
" .reduce(function(a, b){return parseInt(a) + parseInt(b)}, 0);",
" if(index == 3 || index == 4 ||index == 5 || index == 6 || index==7 || index==8) {",
" $(api.column(index).footer()).html('');",
" } else {",
" $(api.column(index).footer()).html(total);",
" }",
" if(total == 100) {",
" $(api.column(index).footer()).css({'color': 'green'});",
" } else {",
" $(api.column(index).footer()).css({'color': 'red'});",
" }",
" })",
" // update the parent row",
" var col_share = api.column(2).data();",
" var col_CPP = api.column(5).data();",
" var col_CPM = api.column(6).data();",
" var col_Historical_CPP = api.column(7).data();",
" var col_Historical_CPM = api.column(8).data();",
" var CPP = 0, CPM = 0, Historical_CPP = 0, Historical_CPM = 0;",
" for(var i = 0; i < col_share.length; i++){",
" CPP += (parseInt(col_share[i])*parseInt(col_CPP[i]).toFixed(0));",
" CPM += (parseInt(col_share[i])*parseInt(col_CPM[i]).toFixed(0));",
" Historical_CPP += (parseInt(col_share[i])*parseInt(col_Historical_CPP[i]).toFixed(0));",
" Historical_CPM += (parseInt(col_share[i])*parseInt(col_Historical_CPM[i]).toFixed(0));",
" }",
" table.cell(rowIdx, j0+2).data((CPP/100).toFixed(2));",
" table.cell(rowIdx, j0+3).data((CPM/100).toFixed(2));",
" table.cell(rowIdx, j0+4).data((Historical_CPP/100).toFixed(2));",
" table.cell(rowIdx, j0+5).data((Historical_CPM/100).toFixed(2));",
" }",
" var dataset = [];",
" var n = d.length - 1;",
" for(var i = 0; i < d[n].length; i++){",
" var datarow = $.map(d[n][i], function (value, index) {",
" return [value];",
" });",
" dataset.push(datarow);",
" }",
" var id = 'table#' + childId;",
" if (Object.keys(d[n][0]).indexOf('_details') === -1) {",
" var subtable = $(id).DataTable({",
" 'data': dataset,",
" 'autoWidth': true,",
" 'deferRender': true,",
" 'info': false,",
" 'lengthChange': false,",
" 'ordering': d[n].length > 1,",
" 'order': [],",
" 'paging': true,",
" 'scrollX': false,",
" 'scrollY': false,",
" 'searching': false,",
" 'sortClasses': false,",
" 'pageLength': 50,",
" 'rowCallback': rowCallback,",
" 'headerCallback': headerCallback,",
" 'footerCallback': footerCallback,",
" 'columnDefs': [",
" {targets: [0, 9, 10, 11], visible: false},",
" {targets: '_all', className: 'dt-center'}",
" ]",
" });",
" } else {",
" var subtable = $(id).DataTable({",
" 'data': dataset,",
" 'autoWidth': true,",
" 'deferRender': true,",
" 'info': false,",
" 'lengthChange': false,",
" 'ordering': d[n].length > 1,",
" 'order': [],",
" 'paging': true,",
" 'scrollX': false,",
" 'scrollY': false,",
" 'searching': false,",
" 'sortClasses': false,",
" 'pageLength': 50,",
" 'rowCallback': rowCallback,",
" 'headerCallback': headerCallback,",
" 'footerCallback': footerCallback,",
" 'columnDefs': [",
" {targets: [0, 9, 10, 11], visible: false},",
" {targets: -1, visible: false},",
" {targets: 0, orderable: false, className: 'details-control'},",
" {targets: '_all', className: 'dt-center'}",
" ]",
" }).column(0).nodes().to$().css({cursor: 'pointer'});",
" }",
" subtable.MakeCellsEditable({",
" onUpdate: onUpdate,",
" inputCss: 'my-input-class',",
" columns: [2, 7, 8],",
" confirmationButton: {",
" confirmCss: 'my-confirm-class',",
" cancelCss: 'my-cancel-class'",
" }",
" });",
"};",
"",
"// display the child table on click",
"var children = [];", # array to store the id's of the already created child tables
"table.on('click', 'td.details-control', function(){",
" var tbl = $(this).closest('table'),",
" tblId = tbl.attr('id'),",
" td = $(this),",
" row = $(tbl).DataTable().row(td.closest('tr')),",
" rowIdx = row.index();",
" if(row.child.isShown()){",
" row.child.hide();",
" td.html('<img src=\"https://raw.githubusercontent.com/DataTables/DataTables/master/examples/resources/details_open.png\"/>');",
" } else {",
" var childId = tblId + '-child-' + rowIdx;",
" if(children.indexOf(childId) === -1){", # this child table has not been created yet
" children.push(childId);",
" row.child(format(row.data(), childId)).show();",
" td.html('<img src=\"https://raw.githubusercontent.com/DataTables/DataTables/master/examples/resources/details_close.png\"/>');",
" format_datatable(row.data(), childId, rowIdx);",
" }else{",
" row.child(true);",
" td.html('<img src=\"https://raw.githubusercontent.com/DataTables/DataTables/master/examples/resources/details_close.png\"/>');",
" }",
" }",
"});"
)
# Table
table <- DT::datatable(
Dat,
callback = callback_js,
rownames = rowNames,
escape = -colIdx-1,
style = "bootstrap4",
extensions = 'Buttons',
options = list(
dom = "Blfrtip",
buttons = list("copy",
list(
extend = "collection",
buttons = "csv",
text = "Download"
)
),
lengthMenu = list(c(-1, 10, 20),
c("All", 10, 20)),
columnDefs = list(
list(width = '30px', targets = 0),
list(width = '545px', targets = 1),
list(visible = FALSE, targets = ncol(Dat)-1+colIdx),
list(orderable = FALSE, className = 'details-control', targets = colIdx),
list(className = "dt-center", targets = "_all")
)
)
)
# Call the html tools deps (js & css files in this directory)
cell_edit_dep <- htmltools::htmlDependency(
"CellEdit", "1.0.19",
src = 'www/',
script = "dataTables.cellEdit.js",
stylesheet = "dataTables.cellEdit.css"
)
table$dependencies <- c(table$dependencies, list(cell_edit_dep))
table %>% formatStyle(
c('Market', 'SQAD CPP ($)', 'SQAD CPM ($)', 'Override CPP ($)', 'Override CPM ($)'),
target = 'row',
backgroundColor = "#F5F2F2"
)
})
Try this:
js <- c(
"function(xlsx) {",
" var table = $('#daypartTable').find('table').DataTable();",
" // Letters for Excel columns.",
" var LETTERS = [",
" 'A','B','C','D','E','F','G','H','I','J','K','L','M',",
" 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'",
" ];",
" // Get sheet.",
" var sheet = xlsx.xl.worksheets['sheet1.xml'];",
" // Get a clone of the sheet data. ",
" var sheetData = $('sheetData', sheet).clone();",
" // Clear the current sheet data for appending rows.",
" $('sheetData', sheet).empty();",
" // Row count in Excel sheet.",
" var rowCount = 1;",
" // Iterate each row in the sheet data.",
" $(sheetData).children().each(function (index) {",
" // Used for DT row() API to get child data.",
" var rowIndex = index - 2;", #
" // Don't process row if its the header row.",
sprintf(" if (index > 1 && index < %d) {", nrow(Dat)+2), #
" // Get row",
" var row = $(this.outerHTML);",
" // Set the Excel row attr to the current Excel row count.",
" row.attr('r', rowCount);",
" // Iterate each cell in the row to change the row number.",
" row.children().each(function (index) {",
" var cell = $(this);",
" // Set each cell's row value.",
" var rc = cell.attr('r');",
" rc = rc.replace(/\\d+$/, \"\") + rowCount;",
" cell.attr('r', rc);",
" });",
" // Get the row HTML and append to sheetData.",
" row = row[0].outerHTML;",
" $('sheetData', sheet).append(row);",
" rowCount++;",
" // Get the child data - could be any data attached to the row.",
sprintf(" var childData = table.row(':eq(' + rowIndex + ')').data()[%d];", ncol(Dat)-1), #
" if (childData.length > 0) {",
" var colNames = Object.keys(childData[0]);",
" // Prepare Excel formatted row",
" headerRow = '<row r=\"' + rowCount +",
" '\"><c t=\"inlineStr\" r=\"A' + rowCount +",
" '\"><is><t></t></is></c>';",
" for(var i = 0; i < colNames.length; i++){",
" headerRow = headerRow +",
" '<c t=\"inlineStr\" r=\"' + LETTERS[i+1] + rowCount +",
" '\" s=\"7\"><is><t>' + colNames[i] +",
" '</t></is></c>';",
" }",
" headerRow = headerRow + '</row>';",
" // Append header row to sheetData.",
" $('sheetData', sheet).append(headerRow);",
" rowCount++; // Inc excelt row counter.",
" }",
" // The child data is an array of rows",
" for (c = 0; c < childData.length; c++) {",
" // Get row data.",
" child = childData[c];",
" // Prepare Excel formatted row",
" var colNames = Object.keys(child);",
" childRow = '<row r=\"' + rowCount +",
" '\"><c t=\"inlineStr\" r=\"A' + rowCount +",
" '\"><is><t></t></is></c>';",
" for(var i = 0; i < colNames.length; i++){",
" childRow = childRow +",
" '<c t=\"inlineStr\" r=\"' + LETTERS[i+1] + rowCount +",
" '\" s=\"5\"><is><t>' + child[colNames[i]] +",
" '</t></is></c>';",
" }",
" childRow = childRow + '</row>';",
" // Append row to sheetData.",
" $('sheetData', sheet).append(childRow);",
" rowCount++; // Inc excel row counter.",
" }",
" // Just append the header row and increment the excel row counter.",
" } else {",
" $('sheetData', sheet).append(this.outerHTML);",
" rowCount++;",
" }",
" });",
"}"
)
datatable(
Dat, callback = callback, rownames = rowNames, escape = -colIdx-1,
extensions = "Buttons",
options = list(
dom = "Bfrtip",
columnDefs = list(
list(visible = FALSE, targets = ncol(Dat)-1+colIdx),
list(orderable = FALSE, className = 'details-control', targets = colIdx),
list(className = "dt-center", targets = "_all")
),
buttons = list(
list(
extend = "excel",
exportOptions = list(
orthogonal = "export",
columns = 0:(ncol(Dat)-2)
),
orientation = "landscape",
customize = JS(js)
)
)
)
)
Here is an example of the generated Excel file:
EDIT
Better:
excelTitle <- NULL # set to NULL if you don't want a title
js <- c(
"function(xlsx) {",
" var table = $('#daypartTable').find('table').DataTable();",
" // Number of columns.",
" var ncols = table.columns().count();",
" // Is there a title?",
sprintf(" var title = %s;", ifelse(is.null(excelTitle), "false", "true")),
" // Integer to Excel column: 0 -> A, 1 -> B, ..., 25 -> Z, 26 -> AA, ...",
" var XLcolumn = function(j){", # https://codegolf.stackexchange.com/a/163919
" return j < 0 ? '' : XLcolumn(j/26-1) + String.fromCharCode(j % 26 + 65);",
" };",
" // Get sheet.",
" var sheet = xlsx.xl.worksheets['sheet1.xml'];",
" // Get a clone of the sheet data. ",
" var sheetData = $('sheetData', sheet).clone();",
" // Clear the current sheet data for appending rows.",
" $('sheetData', sheet).empty();",
" // Row count in Excel sheet.",
" var rowCount = 1;",
" // Iterate each row in the sheet data.",
" $(sheetData).children().each(function (index) {",
" // Used for DT row() API to get child data.",
" var rowIndex = title ? index - 2 : index - 1;",
" // Don't process row if it's the title row or the header row.",
" var i0 = title ? 1 : 0;",
" if (index > i0) {",
" // Get row",
" var row = $(this.outerHTML);",
" // Set the Excel row attr to the current Excel row count.",
" row.attr('r', rowCount);",
" // Iterate each cell in the row to change the row number.",
" row.children().each(function (index) {",
" var cell = $(this);",
" // Set each cell's row value.",
" var rc = cell.attr('r');",
" rc = rc.replace(/\\d+$/, \"\") + rowCount;",
" cell.attr('r', rc);",
" });",
" // Get the row HTML and append to sheetData.",
" row = row[0].outerHTML;",
" $('sheetData', sheet).append(row);",
" rowCount++;",
" // Get the child data - could be any data attached to the row.",
" var childData = table.row(':eq(' + rowIndex + ')').data()[ncols-1];",
" if (childData.length > 0) {",
" var colNames = Object.keys(childData[0]);",
" // Prepare Excel formatted row",
" var headerRow = '<row r=\"' + rowCount +",
" '\"><c t=\"inlineStr\" r=\"A' + rowCount +",
" '\"><is><t></t></is></c>';",
" for(let i = 0; i < colNames.length; i++){",
" headerRow = headerRow +",
" '<c t=\"inlineStr\" r=\"' + XLcolumn(i+1) + rowCount +",
" '\" s=\"7\"><is><t>' + colNames[i] +",
" '</t></is></c>';",
" }",
" headerRow = headerRow + '</row>';",
" // Append header row to sheetData.",
" $('sheetData', sheet).append(headerRow);",
" rowCount++; // Inc excel row counter.",
" }",
" // The child data is an array of rows",
" for(let c = 0; c < childData.length; c++){",
" // Get row data.",
" var child = childData[c];",
" // Prepare Excel formatted row",
" var childRow = '<row r=\"' + rowCount +",
" '\"><c t=\"inlineStr\" r=\"A' + rowCount +",
" '\"><is><t></t></is></c>';",
" var i = 0;",
" for(let colname in child){",
" childRow = childRow +",
" '<c t=\"inlineStr\" r=\"' + XLcolumn(i+1) + rowCount +",
" '\" s=\"5\"><is><t>' + child[colname] +",
" '</t></is></c>';",
" i++;",
" }",
" childRow = childRow + '</row>';",
" // Append row to sheetData.",
" $('sheetData', sheet).append(childRow);",
" rowCount++; // Inc excel row counter.",
" }",
" // Just append the header row and increment the excel row counter.",
" } else {",
" $('sheetData', sheet).append(this.outerHTML);",
" rowCount++;",
" }",
" });",
"}"
)
datatable(
Dat, callback = callback, rownames = rowNames, escape = -colIdx-1,
extensions = "Buttons",
options = list(
dom = "Bfrtip",
columnDefs = list(
list(visible = FALSE, targets = ncol(Dat)-1+colIdx),
list(orderable = FALSE, className = 'details-control', targets = colIdx),
list(className = "dt-center", targets = "_all")
),
buttons = list(
list(
extend = "excel",
exportOptions = list(
orthogonal = "export",
columns = 0:(ncol(Dat)-2)
),
title = excelTitle,
orientation = "landscape",
customize = JS(js)
)
)
)
)
EDIT 2
In callback_js, replace
" var dataset = [];",
" var n = d.length - 1;",
" for(var i = 0; i < d[n].length; i++){",
" var datarow = $.map(d[n][i], function (value, index) {",
" return [value];",
" });",
" dataset.push(datarow);",
" }",
" var id = 'table#' + childId;",
" if (Object.keys(d[n][0]).indexOf('_details') === -1) {",
" var subtable = $(id).DataTable({",
" 'data': dataset,",
" 'autoWidth': true,",
" 'deferRender': true,",
" 'info': false,",
" 'lengthChange': false,",
" 'ordering': d[n].length > 1,",
" 'order': [],",
" 'paging': true,",
" 'scrollX': false,",
" 'scrollY': false,",
" 'searching': false,",
" 'sortClasses': false,",
" 'pageLength': 50,",
" 'rowCallback': rowCallback,",
" 'headerCallback': headerCallback,",
" 'footerCallback': footerCallback,",
" 'columnDefs': [",
" {targets: [0, 9, 10, 11], visible: false},",
" {targets: '_all', className: 'dt-center'}",
" ]",
" });",
" } else {",
" var subtable = $(id).DataTable({",
" 'data': dataset,",
" 'autoWidth': true,",
" 'deferRender': true,",
" 'info': false,",
" 'lengthChange': false,",
" 'ordering': d[n].length > 1,",
" 'order': [],",
" 'paging': true,",
" 'scrollX': false,",
" 'scrollY': false,",
" 'searching': false,",
" 'sortClasses': false,",
" 'pageLength': 50,",
" 'rowCallback': rowCallback,",
" 'headerCallback': headerCallback,",
" 'footerCallback': footerCallback,",
" 'columnDefs': [",
" {targets: [0, 9, 10, 11], visible: false},",
" {targets: -1, visible: false},",
" {targets: 0, orderable: false, className: 'details-control'},",
" {targets: '_all', className: 'dt-center'}",
" ]",
" }).column(0).nodes().to$().css({cursor: 'pointer'});",
" }",
with
" var n = d.length - 1;",
" var id = 'table#' + childId;",
" var columns = Object.keys(d[n][0]).map(function(x){",
" return {data: x, title: x};",
" });",
" if (Object.keys(d[n][0]).indexOf('_details') === -1) {",
" var subtable = $(id).DataTable({",
" 'data': d[n],",
" 'columns': columns,",
" 'autoWidth': true,",
" 'deferRender': true,",
" 'info': false,",
" 'lengthChange': false,",
" 'ordering': d[n].length > 1,",
" 'order': [],",
" 'paging': true,",
" 'scrollX': false,",
" 'scrollY': false,",
" 'searching': false,",
" 'sortClasses': false,",
" 'pageLength': 50,",
" 'rowCallback': rowCallback,",
" 'headerCallback': headerCallback,",
" 'footerCallback': footerCallback,",
" 'columnDefs': [",
" {targets: [0, 9, 10, 11], visible: false},",
" {targets: '_all', className: 'dt-center'}",
" ]",
" });",
" } else {",
" var subtable = $(id).DataTable({",
" 'data': d[n],",
" 'columns': columns,",
" 'autoWidth': true,",
" 'deferRender': true,",
" 'info': false,",
" 'lengthChange': false,",
" 'ordering': d[n].length > 1,",
" 'order': [],",
" 'paging': true,",
" 'scrollX': false,",
" 'scrollY': false,",
" 'searching': false,",
" 'sortClasses': false,",
" 'pageLength': 50,",
" 'rowCallback': rowCallback,",
" 'headerCallback': headerCallback,",
" 'footerCallback': footerCallback,",
" 'columnDefs': [",
" {targets: [0, 9, 10, 11], visible: false},",
" {targets: -1, visible: false},",
" {targets: 0, orderable: false, className: 'details-control'},",
" {targets: '_all', className: 'dt-center'}",
" ]",
" }).column(0).nodes().to$().css({cursor: 'pointer'});",
" }",
Moreover, you probably don't want the hidden columns in the Excel file. So replace this code:
" if (childData.length > 0) {",
" var colNames = Object.keys(childData[0]);",
" // Prepare Excel formatted row",
......
" // Append row to sheetData.",
" $('sheetData', sheet).append(childRow);",
" rowCount++; // Inc excel row counter.",
" }",
with
" if (childData.length > 0) {",
" var colNames = Object.keys(childData[0]).slice(1,9);",
" // Prepare Excel formatted row",
" var headerRow = '<row r=\"' + rowCount +",
" '\"><c t=\"inlineStr\" r=\"A' + rowCount +",
" '\"><is><t></t></is></c>';",
" for(let i = 0; i < colNames.length; i++){",
" headerRow = headerRow +",
" '<c t=\"inlineStr\" r=\"' + XLcolumn(i+1) + rowCount +",
" '\" s=\"7\"><is><t>' + colNames[i] +",
" '</t></is></c>';",
" }",
" headerRow = headerRow + '</row>';",
" // Append header row to sheetData.",
" $('sheetData', sheet).append(headerRow);",
" rowCount++; // Inc excel row counter.",
" }",
" // The child data is an array of rows",
" for(let c = 0; c < childData.length; c++){",
" // Get row data.",
" var child = childData[c];",
" // Prepare Excel formatted row",
" var childRow = '<row r=\"' + rowCount +",
" '\"><c t=\"inlineStr\" r=\"A' + rowCount +",
" '\"><is><t></t></is></c>';",
" for(let i = 0; i < colNames.length; i++){",
" childRow = childRow +",
" '<c t=\"inlineStr\" r=\"' + XLcolumn(i+1) + rowCount +",
" '\" s=\"5\"><is><t>' + child[colNames[i]] +",
" '</t></is></c>';",
" }",
" childRow = childRow + '</row>';",
" // Append row to sheetData.",
" $('sheetData', sheet).append(childRow);",
" rowCount++; // Inc excel row counter.",
" }",
EDIT 3
This doesn't work if there are some periods in the column names of a child table. Here is the fix:
" var columns = Object.keys(d[n][0]).map(function(x){",
" return {data: x.replace('.', '\\\\\\.'), title: x};",
" });",

Convert Cheat Engine base address

I found a memory address and used Cheat Engine's pointer scan to get referring pointers. To use it in a script I need a base address, which is [game.exe+009274]. How to convert this to an address for use in AutoIt script?
I use NomadMemory.au3 UDF.
I have written 2 function some time ago. One to load all the modules loaded with the process and one to get the base address of the module you need.
Both might be handy here.
Local $iPID = WinGetProcess("app.exe")
Local $sLoadedModules = _ProcessGetLoadedModules($iPID)
Local $My_dll = _MemoryModuleGetBaseAddress($iPID, "My.dll")
For $i = 0 To UBound($sLoadedModules) - 1
ConsoleWrite($sLoadedModules[$i] & #LF) ; find your process here
Next
ConsoleWrite($My_dll & #LF)
Func _ProcessGetLoadedModules($iPID)
Local Const $PROCESS_QUERY_INFORMATION = 0x0400
Local Const $PROCESS_VM_READ = 0x0010
Local $aCall, $hPsapi = DllOpen("Psapi.dll")
Local $hProcess, $tModulesStruct
$tModulesStruct = DllStructCreate("hwnd [200]")
Local $SIZEOFHWND = DllStructGetSize($tModulesStruct) / 200
$hProcess = _WinAPI_OpenProcess(BitOR($PROCESS_QUERY_INFORMATION, $PROCESS_VM_READ), False, $iPID)
If Not $hProcess Then Return SetError(1, 0, -1)
$aCall = DllCall($hPsapi, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($tModulesStruct), "dword", DllStructGetSize($tModulesStruct), "dword*", "")
If $aCall[4] > DllStructGetSize($tModulesStruct) Then
$tModulesStruct = DllStructCreate("hwnd [" & $aCall[4] / $SIZEOFHWND & "]")
$aCall = DllCall($hPsapi, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($tModulesStruct), "dword", $aCall[4], "dword*", "")
EndIf
Local $aReturn[$aCall[4] / $SIZEOFHWND]
For $i = 0 To UBound($aReturn) - 1
$aCall = DllCall($hPsapi, "dword", "GetModuleFileNameExW", "ptr", $hProcess, "ptr", DllStructGetData($tModulesStruct, 1, $i + 1), "wstr", "", "dword", 65536)
$aReturn[$i] = $aCall[3]
Next
_WinAPI_CloseHandle($hProcess)
DllClose($hPsapi)
Return $aReturn
EndFunc ;==>_ProcessGetLoadedModules
Func _MemoryModuleGetBaseAddress($iPID, $sModule)
If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
If Not IsString($sModule) Then Return SetError(2, 0, 0)
Local $PSAPI = DllOpen("psapi.dll")
Local $hProcess
Local $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020)
If $iPID > 0 Then
Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
If $hProcess[0] Then
$hProcess = $hProcess[0]
EndIf
EndIf
Local $Modules = DllStructCreate("ptr[1024]")
Local $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
If $aCall[4] > 0 Then
Local $iModnum = $aCall[4] / 4
Local $aTemp
For $i = 1 To $iModnum
$aTemp = DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
If $aTemp[3] = $sModule Then
DllClose($PSAPI)
Return Ptr(DllStructGetData($Modules, 1, $i))
EndIf
Next
EndIf
DllClose($PSAPI)
Return SetError(-1, 0, 0)
EndFunc ;==>_MemoryModuleGetBaseAddress

How to Display images in a row and next to each other plus view png & gif ASP

The code below first displays folders as hyperlinks, you can click into these folders and if they contain JPG's it will display them.
Is it possible to make these images display in a row and also to show the PNG's & GIF's in the folder also.
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
qfolder = request.querystring("f")
if qfolder = "" then
folderspec = server.mappath(".")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder(folderspec)
Set folcoll = demofolder.SubFolders
For Each subfol in folcoll
folsize = left((subfol.size/1000000), 3)
folist = folist & "<a href='?f=" & subfol.name & "'><strong title='view'></strong> " & subfol.Name & "" & vbcrlf
folist = folist & "<BR>"
Next
set filesys = nothing
Response.Write folist
else
filepath = server.mappath(".") & "\" & qfolder
captionfile = filepath & "\captions.txt"
Set filesys = CreateObject("Scripting.FileSystemObject")
Dim SomeArray()
'caption part
If filesys.FileExists(captionfile) then
set file = filesys.GetFile(captionfile)
Set TextStream = file.OpenAsTextStream(ForReading,TristateUseDefault)
captioncount = 0
Do While Not TextStream.AtEndOfStream
Line = TextStream.readline
ReDim Preserve SomeArray(captioncount)
SomeArray(captioncount) = line
'response.write captioncount & " " & somearray(captioncount) & "<br>"
captioncount = captioncount + 1
'Response.write Line
Loop
textStream.close
end if
'folder part
Set demofolder = filesys.GetFolder(filepath)
Set filecoll = demofolder.Files
filecount = 0
For Each file in filecoll
Ext = UCase(Right(File.Path, 3))
If Ext = "JPG" OR Ext = "GIF" Then
on error resume next
data = SomeArray(filecount)
on error goto 0
hrefpath = qfolder & "/" & file.name
imagepath = "<strong>" & data & "</strong><br><a href='" & hrefpath & "' title='free image gallery' border=0><img src='" & hrefpath & "' border='" & border_size & "' title=""" & data & """ style='border-color: " & border_color & ";'></a><br>"
filist = filist & imagepath & vbcrlf
filist = filist & "<BR>"
filecount = filecount + 1
data = ""
end if
Next
set filesys = Nothing
filist = filist & "<br><small><a href='http://www.allscoop.com/' target='_blank'>allscoop free image gallery</a></small>"
%>
<h3>«
<%=qfolder%></h3>
<p><%=filist%></p>
<% end if %>
Thanks
Ross
All you need to do is remove the final 2

How to Display images 100x75, and on click, display them in original size. ASP classic

The code below first displays folders as hyperlinks, you can click into these folders and if they contain JPG's it will display them.
Is it possible to make these images display with attributes width="100" height="75" but still allow me to click them and have them display original size?
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
qfolder = request.querystring("f")
if qfolder = "" then
folderspec = server.mappath(".")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder(folderspec)
Set folcoll = demofolder.SubFolders
For Each subfol in folcoll
folsize = left((subfol.size/1000000), 3)
folist = folist & "<a href='?f=" & subfol.name & "'><strong title='view'></strong> " & subfol.Name & "" & vbcrlf
folist = folist & "<BR>"
Next
set filesys = nothing
Response.Write folist
else
filepath = server.mappath(".") & "\" & qfolder
captionfile = filepath & "\captions.txt"
Set filesys = CreateObject("Scripting.FileSystemObject")
Dim SomeArray()
'caption part
If filesys.FileExists(captionfile) then
set file = filesys.GetFile(captionfile)
Set TextStream = file.OpenAsTextStream(ForReading,TristateUseDefault)
captioncount = 0
Do While Not TextStream.AtEndOfStream
Line = TextStream.readline
ReDim Preserve SomeArray(captioncount)
SomeArray(captioncount) = line
'response.write captioncount & " " & somearray(captioncount) & "<br>"
captioncount = captioncount + 1
'Response.write Line
Loop
textStream.close
end if
'folder part
Set demofolder = filesys.GetFolder(filepath)
Set filecoll = demofolder.Files
filecount = 0
For Each file in filecoll
Ext = UCase(Right(File.Path, 3))
If Ext = "JPG" OR Ext = "GIF" Then
on error resume next
data = SomeArray(filecount)
on error goto 0
hrefpath = qfolder & "/" & file.name
imagepath = "<strong>" & data & "</strong><br><a href='" & hrefpath & "' title='free image gallery' border=0><img src='" & hrefpath & "' border='" & border_size & "' title=""" & data & """ style='border-color: " & border_color & ";'></a><br>"
filist = filist & imagepath & vbcrlf
filist = filist & "<BR>"
filecount = filecount + 1
data = ""
end if
Next
set filesys = Nothing
filist = filist & "<br><small><a href='http://www.allscoop.com/' target='_blank'>allscoop free image gallery</a></small>"
%>
<h3>«
<%=qfolder%></h3>
<p><%=filist%></p>
<% end if %>
Thanks
You need to update a single line where tag is created:
imagepath = "<strong>" & data & "</strong><br><a href='" & hrefpath & _
"' title='free image gallery' border=0><img width=100 height=75 src='" &_
hrefpath & "' border='" & border_size & "' title=""" & data &_
""" style='border-color: " & border_color & ";'></a><br>"
Just in case here is complete script:
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
qfolder = request.querystring("f")
if qfolder = "" then
folderspec = server.mappath(".")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder(folderspec)
Set folcoll = demofolder.SubFolders
For Each subfol in folcoll
folsize = left((subfol.size/1000000), 3)
folist = folist & "<a href='?f=" & subfol.name & "'><strong title='view'></strong> " & subfol.Name & "" & vbcrlf
folist = folist & "<BR>"
Next
set filesys = nothing
Response.Write folist
else
filepath = server.mappath(".") & "\" & qfolder
captionfile = filepath & "\captions.txt"
Set filesys = CreateObject("Scripting.FileSystemObject")
Dim SomeArray()
'caption part
If filesys.FileExists(captionfile) then
set file = filesys.GetFile(captionfile)
Set TextStream = file.OpenAsTextStream(ForReading,TristateUseDefault)
captioncount = 0
Do While Not TextStream.AtEndOfStream
Line = TextStream.readline
ReDim Preserve SomeArray(captioncount)
SomeArray(captioncount) = line
'response.write captioncount & " " & somearray(captioncount) & "<br>"
captioncount = captioncount + 1
'Response.write Line
Loop
textStream.close
end if
'folder part
Set demofolder = filesys.GetFolder(filepath)
Set filecoll = demofolder.Files
filecount = 0
For Each file in filecoll
Ext = UCase(Right(File.Path, 3))
If Ext = "JPG" OR Ext = "GIF" Then
on error resume next
data = SomeArray(filecount)
on error goto 0
hrefpath = qfolder & "/" & file.name
imagepath = "<strong>" & data & "</strong><br><a href='" & hrefpath & "' title='free image gallery' border=0><img width=100 height=75 src='" & hrefpath & "' border='" & border_size & "' title=""" & data & """ style='border-color: " & border_color & ";'></a><br>"
filist = filist & imagepath & vbcrlf
filist = filist & "<BR>"
filecount = filecount + 1
data = ""
end if
Next
set filesys = Nothing
filist = filist & "<br><small><a href='http://www.allscoop.com/' target='_blank'>allscoop free image gallery</a></small>"
%>
<h3>«
<%=qfolder%></h3>
<p><%=filist%></p>
<% end if %>

Dllcall autoit partially getting results

I am having problem with the following code in autoit.
it is suppose to list all printers available in my system and the curresponding papernames supported by each printer.
but am getting only the printer names ans series of '0s' which is suppose to be the papernames
#include <Debug.au3>
#include <String.au3>
Const $DC_BINS = 6
Const $DC_BINNAMES = 12
Const $DC_PAPERNAMES = 16
Const $DC_PAPERS = 2
Const $DC_PAPERSIZE = 3
Dim $BinNameList
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colInstalledPrinters = $objWMIService.ExecQuery ("Select Name, PortName from Win32_Printer")
For $objPrinter In $colInstalledPrinters
$result = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERS, "str", Chr(0), "long", 0)
$s_struct = ""
_DebugSetup ($s_struct)
$s_struct=_StringRepeat("0", $result[0]*64)
;$s_struct = StringTrimRight($s_struct, 1)
$struct = DllStructCreate($s_struct)
$result2 = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERNAMES, "ptr", DllStructGetPtr($struct), "long", 0)
_DebugOut ( $objPrinter.Name)
For $i = 0 To $result[0]-1
_DebugOut (DllStructGetData($struct, $i))
Next
$struct = 0
Next
Check this out: http://msdn.microsoft.com/en-us/library/aa394363(v=vs.85).aspx
Example that uses just WMI:
#include <Array.au3>
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colInstalledPrinters = $objWMIService.ExecQuery ("Select * from Win32_Printer",Default,48)
For $objPrinter In $colInstalledPrinters
$arr = $objPrinter.PrinterPaperNames
_ArrayDisplay($arr, $objPrinter.Name)
Next
Or try this which prints the actual paper names (run in SciTE so you can see the output from ConsoleWrite):
Const $DC_PAPERS = 2
Const $DC_PAPERSIZE = 3
Const $DC_PAPERNAMES = 16
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colInstalledPrinters = $objWMIService.ExecQuery ("Select Name, PortName from Win32_Printer")
For $objPrinter In $colInstalledPrinters
$result = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERS, "str", Chr(0), "long", 0)
$s_struct = ""
$s_struct2 = ""
For $i = 1 To $result[0]
$s_struct = $s_struct & "char[64];"
Next
For $i = 1 To $result[0]
$s_struct2 &= "long x;long y;"
Next
$s_struct = StringTrimRight($s_struct, 1)
$s_struct2 = StringTrimRight($s_struct2, 1)
$j = 1
$struct = DllStructCreate($s_struct)
$pointStruct = DllStructCreate($s_struct2)
$result2 = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERNAMES, "ptr", DllStructGetPtr($struct), "long", 0)
$result3 = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $objPrinter.Name, "str", $objPrinter.PortName, "int", $DC_PAPERSIZE, "ptr", DllStructGetPtr($pointStruct), "long", 0)
ConsoleWrite($objPrinter.Name & " on Port: " & $objPrinter.PortName & #CRLF)
For $i = 1 To $result[0]
ConsoleWrite(DllStructGetData($struct, $i) & " (" & DllStructGetData($pointStruct, $j) & "mm x " & DllStructGetData($pointStruct, $j + 1) & "mm)" & #CRLF)
$j += 2
Next
$struct = 0
$pointStruct = 0
Next

Resources