Forum Discussion
Oferv
12 years agoSuper Contributor
Hi David,
I have found a way to search the text for specific substring but,how can i make sure the substring has truly been found in the text.i can see it selected but i want a return value to make sure it's truly been found.
here is the function i'm using:
//USEUNIT SelectSpecificPage
//USEUNIT Math
//Performing text search in a document
function SearchTextInADocument()
{
//Get the number of display documents
NumberOfDocuments = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["ChildCount"] - 4
//Run over each document to perform a text search
for(i = 1; i <= NumberOfDocuments; i++)
{
//Get the document name and click it
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("TabItem", "", i)["Click"]()
//Get document index
DocumentIndex = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("TabItem", "", i)["WPFControlIndex"]
//Get the name to drag and drop
TabName = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("TabItem", "", i)["Header"]["Title"]["OleValue"]
Log["Message"]("Clicking document " + TabName)
// //Get all childrens
// var Childrens = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["DocumentGrid"]["DocumentGridPage1"]["Border"]["DocumentPageView"]["DocumentPageHost"]["FixedPage"]["WPFObject"]("LINK_" + (DocumentIndex + 1))["WPFObject"]("Canvas", "", 1)["FindAllChildren"]("WPFControlText", "*", 5);
// var Childrens = (new VBArray(Childrens))["toArray"]();
// CanvasCount = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("DockPanel", "", 1)["WPFObject"]("ContentControl", "", 1)["WPFObject"]("DocumentDialog", "", 1)["WPFObject"]("Grid", "", 1)["WPFObject"]("docViewer")["WPFObject"]("DocumentGrid")["WPFObject"]("DocumentGridPage", "", 1)["WPFObject"]("Border", "", 1)["WPFObject"]("DocumentPageView", "", 1)["WPFObject"]("DocumentPageHost", "", 1)["WPFObject"]("FixedPage", "", 1)["WPFObject"]("LINK_" + (DocumentIndex + 1))["WPFObject"]("Canvas", "", 1)["ChildCount"]
// //Get text peace to search for specific selected document
// CanavasToSelect = Math["RandomInt"](1, CanvasCount)
//Select all the text from the document
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["Keys"]("^a");
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["Keys"]("^c");
// //Right click to select copy
// Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["DocumentGrid"]["DocumentGridPage1"]["Border"]["DocumentPageView"]["DocumentPageHost"]["FixedPage"]["ClickR"]();
// //Moves the mouse cursor to the menu item specified and then simulates a single click.
// Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["PopupMenu"]["Click"]("Copy");
//Get all the text display in the document
Text = Sys["Clipboard"]
//Get the text lengh
TextLengh = aqString["GetLength"](Text)
//Set start position to serahc from
SearchStartPosition = Math["RandomInt"](1, TextLengh - 100)
//Get the text to serahc
TextLenghToSearch = Math["RandomInt"](1, 100)
//Get the random sub string
SubStringToSearch = aqString["SubString"](Text, SearchStartPosition, TextLenghToSearch)
//Logging the sub string to search
Log["Message"]("Searching for substring " + SubStringToSearch + ".In document " + TabName)
//Click the search field
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["Click"]();
//Click select all and delete
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["Keys"]("^a[Del]");
// //DBClick on 'FindTextBox' object.
// Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["DblClick"]();
//Enters 'The Text To Search' in the 'FindTextBox' object.
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["Keys"](SubStringToSearch);
//Clicks the 'FixedPage' object.
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["DocumentGrid"]["DocumentGridPage1"]["Border"]["DocumentPageView"]["DocumentPageHost"]["FixedPage"]["Click"](377, 17);
//Enters '^[Home]' in the 'docViewer' object.
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["Keys"]("^[Home]");
//Click the 'Find Next' button
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["WPFObject"]("FindNextButton")["Click"]()
}
}
I have found a way to search the text for specific substring but,how can i make sure the substring has truly been found in the text.i can see it selected but i want a return value to make sure it's truly been found.
here is the function i'm using:
//USEUNIT SelectSpecificPage
//USEUNIT Math
//Performing text search in a document
function SearchTextInADocument()
{
//Get the number of display documents
NumberOfDocuments = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["ChildCount"] - 4
//Run over each document to perform a text search
for(i = 1; i <= NumberOfDocuments; i++)
{
//Get the document name and click it
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("TabItem", "", i)["Click"]()
//Get document index
DocumentIndex = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("TabItem", "", i)["WPFControlIndex"]
//Get the name to drag and drop
TabName = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("TabItem", "", i)["Header"]["Title"]["OleValue"]
Log["Message"]("Clicking document " + TabName)
// //Get all childrens
// var Childrens = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["DocumentGrid"]["DocumentGridPage1"]["Border"]["DocumentPageView"]["DocumentPageHost"]["FixedPage"]["WPFObject"]("LINK_" + (DocumentIndex + 1))["WPFObject"]("Canvas", "", 1)["FindAllChildren"]("WPFControlText", "*", 5);
// var Childrens = (new VBArray(Childrens))["toArray"]();
// CanvasCount = Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["WPFObject"]("Grid", "", 1)["WPFObject"]("DocumentViewTabControl")["WPFObject"]("ScrollableTabControlScreen")["WPFObject"]("DockPanel", "", 1)["WPFObject"]("ContentControl", "", 1)["WPFObject"]("DocumentDialog", "", 1)["WPFObject"]("Grid", "", 1)["WPFObject"]("docViewer")["WPFObject"]("DocumentGrid")["WPFObject"]("DocumentGridPage", "", 1)["WPFObject"]("Border", "", 1)["WPFObject"]("DocumentPageView", "", 1)["WPFObject"]("DocumentPageHost", "", 1)["WPFObject"]("FixedPage", "", 1)["WPFObject"]("LINK_" + (DocumentIndex + 1))["WPFObject"]("Canvas", "", 1)["ChildCount"]
// //Get text peace to search for specific selected document
// CanavasToSelect = Math["RandomInt"](1, CanvasCount)
//Select all the text from the document
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["Keys"]("^a");
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["Keys"]("^c");
// //Right click to select copy
// Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["DocumentGrid"]["DocumentGridPage1"]["Border"]["DocumentPageView"]["DocumentPageHost"]["FixedPage"]["ClickR"]();
// //Moves the mouse cursor to the menu item specified and then simulates a single click.
// Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["PopupMenu"]["Click"]("Copy");
//Get all the text display in the document
Text = Sys["Clipboard"]
//Get the text lengh
TextLengh = aqString["GetLength"](Text)
//Set start position to serahc from
SearchStartPosition = Math["RandomInt"](1, TextLengh - 100)
//Get the text to serahc
TextLenghToSearch = Math["RandomInt"](1, 100)
//Get the random sub string
SubStringToSearch = aqString["SubString"](Text, SearchStartPosition, TextLenghToSearch)
//Logging the sub string to search
Log["Message"]("Searching for substring " + SubStringToSearch + ".In document " + TabName)
//Click the search field
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["Click"]();
//Click select all and delete
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["Keys"]("^a[Del]");
// //DBClick on 'FindTextBox' object.
// Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["DblClick"]();
//Enters 'The Text To Search' in the 'FindTextBox' object.
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["FindTextBoxGrid"]["FindTextBox"]["Keys"](SubStringToSearch);
//Clicks the 'FixedPage' object.
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["DocumentGrid"]["DocumentGridPage1"]["Border"]["DocumentPageView"]["DocumentPageHost"]["FixedPage"]["Click"](377, 17);
//Enters '^[Home]' in the 'docViewer' object.
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["Keys"]("^[Home]");
//Click the 'Find Next' button
Aliases["FusionDesktop"]["HwndSource_MainWindow"]["MainWindow"]["Grid"]["TabControl"]["Grid"]["ContentPanel"]["PART_SelectedContentHost"]["Grid"]["DocumentViewTabControl"]["ScrollableTabControlScreen"]["DockPanel"]["ContentControl"]["DocumentDialog"]["Grid"]["docViewer"]["FindToolbar"]["FindTextBoxBorder"]["StackPanel"]["WPFObject"]("FindNextButton")["Click"]()
}
}
Related Content
- 10 months agolodecesa
- 9 months agoMehwishDaud
- 2 years agorodm0001
Recent Discussions
- 2 days agoMW_Didata