Hi Irina,
Thanks,the problem i'm facing is that the items i'm selecting are by design not display on screen all time.i'll explain,i need to select few pages from a document who's containing 100 pages and delete this pages.on screen i can view only 3 pages at a time means, TC won't map all other pages except from this "exposed" pages.so i need to click the CTRL button and then tell TC what page i currently want to select and click it,and like that i'll choose all the pages i want to delete while CTRL is down and in the end i'll click the delete button.this function i wrote does that.the only problem i'm facing is that i think that the Sys["Desktop"]["KeyDown"](Win32API.VK_CONTROL) is doing some problems because when(after selecting all pages)clicking the delete only the last page selected has been deleted although all other selected pages are selected.
//Mark few selected pages and delete it all at once
function DeleteFewSelectedPagesAllAtOnce()
{
//Get the number of pages currently in target view
NumberOfPagesInTargetBeforeDeletion = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["wItemCount"]
//Select a random number of pages to delete
Loop = RandomInt(1, NumberOfPagesInTargetBeforeDeletion)
//Click Home keyboard key
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]("ListBoxItem")["Keys"]("[Home]");
//De-select the first page
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["ListBoxItem"]["Keys"]("^ ");
//Get the number of pages currently in target view
NumberOfPagesInTargetAfterDeletion = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["wItemCount"]
//Creating the pages array
PagesArray = new Array()
for(Position = 1;Position<=NumberOfPagesInTargetBeforeDeletion;Position++)
PagesArray[Position] = Position
//Press the CTRL button and holds it untill finish selecting the pages to delete
Sys["Desktop"]["KeyDown"](Win32API.VK_CONTROL)
//Loop through the pages and delete them
for(i = 1; i <= Loop; i++)
{
//Get the array length
ArrayLength = PagesArray.length
//Select current page to delete
SelectedPage = RandomInt(1, ArrayLength - 1)
var listBox = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"];
var item = listBox.Items.Item(PagesArray[SelectedPage]-1);
listBox.ScrollIntoView(item)
//Log the deleted page number in the document
Log["Message"]("Page number " + PagesArray[SelectedPage] + " will be selected and deleted")
//Wait for the selected page to scrolled into view
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["WaitWPFObject"]("ListBoxItem", "", PagesArray[SelectedPage]["Exists"])
//Click the selected page
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["WPFObject"]("ListBoxItem", "", PagesArray[SelectedPage])["Click"]()
//Deleteing the selected page number from the pages array so it won't be selected again
PagesArray.splice(SelectedPage, 1)
}
//Release the ctrl button
Sys["Desktop"]["KeyUp"](Win32API.VK_CONTROL)
//Click the Del keyboard key to delete the page
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["WPFObject"]("ListBoxItem", "", SelectedPage)["Keys"]("[Del]")
//Get the number of pages currently in target view
NumberOfPagesInTargetAfterDeletion = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["AssemblyViewTabControl"]["Grid"]["Grid2"]["UserControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentViewer"]["m_thumbnails"]["wItemCount"]
//Log the total number of pages in the document before start deleting and after
Log["Message"]("Number of pages in document before deletion was " + NumberOfPagesInTargetBeforeDeletion + " ,Number of pages in document after deletion is " + NumberOfPagesInTargetAfterDeletion)
if(NumberOfPagesInTargetAfterDeletion == (NumberOfPagesInTargetBeforeDeletion - (i - 1)))
Log["Message"]("The number of document currently deleted " + (NumberOfPagesInTargetBeforeDeletion-NumberOfPagesInTargetAfterDeletion) + " is correct")
else
Log["Warning"]("The number of document currently deleted " + (NumberOfPagesInTargetBeforeDeletion-NumberOfPagesInTargetAfterDeletion) + " isn't correct")
//ResetProject["ResetProject"]()
}
do you think also that the problem the pages are not being deleted properly is because of the use i'm doing of Sys["Desktop"]["KeyDown"](Win32API.VK_CONTROL)? and if so how can use ListBox.ClickItem here?
sorry for the long and thx