How to use _IEFormElementRadioSelect without finding a Form - automation

I need this script to work, but without using _IEFormGetObjByName or _IEFormGetCollection, and while knowing only the Name of the radio buttons.
$oIE = _IE_Example ("form")
$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName ("input")
For $element In $oArray
If $element.Name = "radioExample" Then
_IEFormElementRadioSelect ($oDoc,2, "radioExample", 1, "byIndex")
msgbox(0,"","Found it")
Endif
Next
_IEFormElementGetValue & _IEAction work great, just reference them to the $oElement, and search for an appropriate $element.Name, but I can't get the _IEFormElementRadioSelect to work.
The only difference between the _IEFormElementRadioSelect command from the example script found in the AutoIt helpfile is the reference to $oDoc. In the helpfile this is $oForm, which is found with a _IEFormGetObjByName, which I can't use (the site I'm automating doesn't return any forms).

Replace your _IEFormElementRadioSelect with _IEAction($element, "click")
Try this example; you can see the radio items being selected as the script runs:
#include <IE.au3>
$oIE = _IE_Example("form")
$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName("input")
For $element In $oArray
If $element.Name = "radioExample" Then
_IEAction($element, "click")
Sleep(2000)
EndIf
Next

Related

Janus GridEX - C# How to show multi-line header using columnsets at runtime?

I have already tried:
How to wrap header caption in Janus GridEx
and
https://www.c-sharpcorner.com/forums/table-column-set
and looked through Janus documentation at http://codelibraries.blogspot.com/search/label/Janus%20GridEX.
I have a business requirement to show wrapped column header. For example, if column header is:
This is column header
need to show
This is column
header
As it is right now (before I tried implementing code for this requirement), code looked like:
dgMulti.SetDataBinding(bulkTable, "")
dgMulti.RetrieveStructure()
Dim column As Janus.Windows.GridEX.GridEXColumn
For Each column In dgMulti.RootTable.Columns
column.Width = 150
Next
where bulkTable is a System.Data.DataTable object.
After visiting above links, I tried suggestions and used ColumnSets as shown below and added after above code:
Dim CSET As New Janus.Windows.GridEX.GridEXColumnSet()
CSET.Caption = "YourCaption"
CSET.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center
CSET.ColumnCount = 2
CSET.Width = 150
CSET.Key = "YourCaptionKey"
' FOLLOWING LINE THROW ERROR
**CSET.Add(New Janus.Windows.GridEX.GridEXColumn(dgMulti.RootTable.Columns(0).Key, dgMulti.RootTable.Columns(0).ColumnType), 0, 1)
CSET.Add(New Janus.Windows.GridEX.GridEXColumn(dgMulti.RootTable.Columns(1).Key, dgMulti.RootTable.Columns(1).ColumnType), 0, 2)**
dgMulti.RootTable.ColumnSets.Add(CSET)
dgMulti.RootTable.ColumnSetHeaderLines = 2
dgMulti.RootTable.CellLayoutMode = Janus.Windows.GridEX.CellLayoutMode.UseColumnSets
Error: Operation is not valid due to the current state of the object.
Can you please help what I am missing? I believe I need to somehow link the columns with ColumnSets but how?
You don't need columnsets for this.
I can't get a deeplink to the janus forums thread with this answer, but here is the copy/pasted answer:
You can put a CR Character if you can determine where to wrap.
in e.g.
Column.Caption = Now.ToString("ddd" & vbCr & "d MMM");
You can see the janus support forums here: https://www.janusys.com. Click through to the Winforms GridEX forum, and use search phrase "wrap".
The website is basically unusable in Firefox, I fallback to Chrome to browse.
Dim CSET As New Janus.Windows.GridEX.GridEXColumnSet()
CSET.Caption = "YourCaption"
CSET.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center
CSET.ColumnCount = 2
CSET.Width = 150
CSET.Key = "YourCaptionKey"
dgMulti.RootTable.ColumnSets.Add(CSET)
CSET.Add(dgMulti.RootTable.Columns.Add("Yourcolumnkey"), 0, 0)
CSET.Add(dgMulti.RootTable.Columns.Add("Yourcolumnkey"), 0, 1)
dgMulti.RootTable.ColumnSetHeaderLines = 2
dgMulti.RootTable.CellLayoutMode = Janus.Windows.GridEX.CellLayoutMode.UseColumnSets

Still not understanding settingwithcopy warning

I want to isolate a string but I keep getting a setting with copy error. I read the other threads on settingwithcopy warnings but I don't understand why those solutions don't work here.
I've tried using:
df['Title'][i] = delBy[i]
df.Title[i] = delBy[i]
df[df.Title][i] = delBy[i]
df.loc[df.Title][i] = delBy[i]
df.loc[i]['Title'] = delBy[i]
Actual code:
delBy = df['Title'].str.extract(r'(.+?)(?= [bB]y)', expand = False)
for i in df.index:
if pd.notna(delBy[i]) == True:
df['Title'][i] = delBy[i]
else:
continue
If title has keywords by or By (ex: Animal by John) keep only title (Animal). Leave other titles alone (ex: Meditations)
It looks that you want to delete "by ..." part, where it can be done.
Then start from:
delBy = df.Title.str.extract(r'(.+?)(?= [bB]y)', expand = False).dropna()
(note that I added .dropna()).
Then, instead of your loop, just update this column (in place):
df.Title.update(delBy)
A shorter solution, isn't it?

Unable to save the file in specified location using Autoit

Followed the below steps to save a file in desired location:
Step1: Save As window getting opened(with the default downloads location, with file name as DOC)
Step2: entering the file name as "D:\temp\sample.pdf" (which is getting entered in the edit bar)
Step3: clicking the save button (button clicked, file downloaded in the default location rather than the "D:\temp" location)
I have created an .exe with the below .au3 script
WinWait("[CLASS:#32770]","",10)
Sleep(2000)
ControlSetText("Save As", "", "Edit1", $CmdLine[1])
Sleep(5000)
ControlClick("Save As", "", "Button1");
Sleep(5000)
On clicking save, it is getting saved in the default location rather than the specified location.
The below code, executing the script.
IO.popen('autoit_script.exe D:\temp') #Ruby Code
Is there a way to sort it out?
It depends on the software you are trying to automate but usually this happens because the software is not recognizing there is a change in the file save path box. The problem is in how ControlSetText works. Try using ControlSend with some error checking to make sure the file path you are try to set is getting put in right. Sometimes you have to play with a few different variations to see what works with the software you are automating. Here are two examples you can try:
Example one:
WinWait("[CLASS:#32770]", "", 10)
If Not #error Then ;make sure the window was found
$hWin = WinGetHandle("[CLASS:#32770]") ;get window handle
ControlSetText($hWin, "", "Edit1", $CmdLine[1]) ;set text
ControlFocus($hWin, "", "Edit1") ;just to make sure we have focus
ControlSend($hWin, "", "Edit1", "{ENTER}")) ;should work like click button 1 but you will have to check
;better then a sleep
$hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
Do
Until WinExists($hWin) = 0 Or TimerDiff($hTimer) >= 10000
EndIf
Example two:
WinWait("[CLASS:#32770]", "", 10)
If Not #error Then ;make sure the window was found
$hWin = WinGetHandle("[CLASS:#32770]") ;get window handle
While 1
ControlSetText($hWin, "", "Edit1", "") ;just makes sure there is no text in the control text
ControlFocus($hWin, "", "Edit1") ;just to make sure we have focus
ControlSend($hWin, "", "Edit1", $CmdLine[1])) ;set text using ControlSend
If ControlGetText($hWin, "", "Edit1") = $CmdLine[1] Then ExitLoop ;makes sure that the control got ALL of the text before exiting loop
WEnd
ControlClick($hWin, "", "Button1");
;better then a sleep
$hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
Do
Until WinExists($hWin) = 0 Or TimerDiff($hTimer) >= 10000
EndIf

dnn 7+ search is not indexing custom module items

I have a dnn 7.2.2 development site running under dnndev.me on my local machine. I have created a simple product catalogue module and am trying to integrate the new search for dnn 7.
Here is the implementation of ModuleSearchBase in my feature/business controller
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Search
Imports DotNetNuke.Common.Globals
Namespace Components
Public Class FeatureController
Inherits ModuleSearchBase
Implements IUpgradeable
Public Overrides Function GetModifiedSearchDocuments(moduleInfo As ModuleInfo, beginDate As Date) As IList(Of Entities.SearchDocument)
Try
Dim SearchDocuments As New List(Of Entities.SearchDocument)
'get list of changed products
Dim vc As New ViewsController
Dim pList As List(Of vw_ProductList_Short_Active) = vc.GetProduct_Short_Active(moduleInfo.PortalID)
If pList IsNot Nothing Then
''for each product, create a searchdocument
For Each p As vw_ProductList_Short_Active In pList
Dim SearchDoc As New Entities.SearchDocument
Dim ModID As Integer = 0
If p.ModuleId Is Nothing OrElse p.ModuleId = 0 Then
ModID = moduleInfo.ModuleID
Else
ModID = p.ModuleId
End If
Dim array() As String = {"mid=" + ModID.ToString, "id=" + p.ProductId.ToString, "item=" + Replace(p.Name, " ", "-")}
Dim DetailUrl = NavigateURL(moduleInfo.TabID, GetPortalSettings(), "Detail", array)
With SearchDoc
.AuthorUserId = p.CreatedByUserId
.Body = p.ShortInfo
.Description = p.LongInfo
.IsActive = True
.PortalId = moduleInfo.PortalID
.ModifiedTimeUtc = p.LastUpdatedDate
.Title = p.Name + " - " + p.ProductNumber
.UniqueKey = Guid.NewGuid().ToString()
.Url = DetailUrl
.SearchTypeId = 2
.ModuleId = p.ModuleId
End With
SearchDocuments.Add(SearchDoc)
Next
Return SearchDocuments
Else
Return Nothing
End If
Catch ex As Exception
LogException(ex)
Return Nothing
End Try
End Function
End Class
End Namespace
I cleared the site cache and then I manually started a search re-index. I can see from the host schedule history that the re-index is run and completes.
PROBLEM
None of the items in the above code are added to the index. I even used the Luke Inspector to look into the lucene index and that confirms that these items are not added.
QUESTION
I need help figuring out why these items are not getting added or I need help on how to debug the indexing to see if anything is going run during that process.
Thanks in Advance
JK
EDIT #1
I ran the following procedure in Sql Server to see if the module is even listed in the search modules:
exec GetSearchModules[PortalId]
The module in question does appear in this list. The indexing is called for the featureController, but the results are not added to the lucene index. Still need help.
EDIT #2
So I upgraded to 7.3.1 in the hopes that something during the installation would fix this issue. But it did not. The search documents are still getting created/ returned by the GetModifiedSearchDocuments function but the documents are not being added to the Lucene index and therefore do not appear in the search results.
EDIT #3
The break point is not getting hit like i thought after the upgrade, but I added a try catch to log exceptions and the following error log is getting created when I try to manually re-index (cleaned up to keep it short)
AssemblyVersion:7.3.1
PortalID:-1
PortalName:
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:d0a443da-3d68-4b82-afb3-8c9183cf8424
InnerException:Sequence contains more than one matching element
Method:System.Linq.Enumerable.Single
StackTrace:
Message:
System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at DotNetNuke.Services.Scheduling.Scheduler.CoreScheduler.LoadQueueFromTimer()
at DotNetNuke.Services.Scheduling.Scheduler.CoreScheduler.Start()
Source:
Server Name: KING-PC
EDIT #4
Okay, I fixed the problem in edit three following This Disucssion on the DNN issue tracker, but still no items being added to the lucene index.
The breakpoint is hit, and once i leave the debugger running for a while i get the following error:
{"Exception of type 'Lucene.Net.Index.MergePolicy+MergeException' was
thrown."} {"Cannot overwrite:
C:\websites\dnndev.me\App_Data\Search\_1f0.fdt"}
Looks like a permission error. I'll see what I can work out
J King,
I just finished a series on DNNHero.com on Implementing Search in your Module. Parts 3 and 4 are implementing and debugging your ModuleSearchBase implementation.
EDIT: Remove your assignment to the SearchTypeId in your implementation
Also, here is a sample snippet to see how i am setting the attributes of the SearchDocument. Again, watch my video for a whole bunch of other potential pitfalls in the Search implementation.
SearchDocument doc = new SearchDocument
{
UniqueKey = String.Format("{0}_{1}_{2}",
moduleInfo.ModuleDefinition.DefinitionName, moduleInfo.PortalID, item.ItemId),
AuthorUserId = item.AssignedUserId,
ModifiedTimeUtc = item.LastModifiedOnDate.ToUniversalTime(),
Title = item.ItemName,
Body = item.ItemDescription,
Url = "",
CultureCode = "en-US",
Description = "DotNetNuclear Search Content Item",
IsActive = true,
ModuleDefId = moduleInfo.ModuleDefID,
ModuleId = item.ModuleId,
PortalId = moduleInfo.PortalID,
TabId = tab
};

How can I set a global variable from a script/command line?

I'm trying to create a little menu to switch from "YouCompleteMe" to "Supertab" and vice versa.
function! TabFunction()
if !exists("g:WhatTab")
let g:WhatTab = "Tab function?"
endif
if !exists("g:MenuTab_choices")
let g:MenuTab_choices = "&SuperTab\n&YouCompleteMe"
endif
let n = confirm(g:WhatTab, g:MenuTab_choices, "Question")
if n == 1
let g:SuperTabMappingForward = '<Tab>'
let g:SuperTabMappingBackward = '<S-Tab>'
let g:ycm_key_list_select_completion = ['<C-Tab>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-S-Tab>', '<Up>']
elseif n == 2
let g:SuperTabMappingForward = '<C-Tab>'
let g:SuperTabMappingBackward = '<C-S-Tab>'
let g:ycm_key_list_select_completion = ['<Tab>', '<Down>']
let g:ycm_key_list_previous_completion = ['<S-Tab>', '<Up>']
endif
endfun
This doesn't work.
When I try to check the value of these variables from the commandline
:echo 'global variable'
the values are correct but they don't work as expected.
Is it not possible to declare a global variable like this?
The use of the g: variable prefix ensures that the global variables are set from within a function; this is correct. Your problem is that the plugin configuration variables like g:SuperTabMappingForward are only evaluated once during plugin load (when Vim starts up), but not during runtime. This mechanism wasn't meant for dynamic reconfiguration.
Solutions
Instead of toggling the (ignored) config variables, you have to do the remapping yourself. At least SuperTab defines corresponding <Plug>... targets; I guess YCM does this, too:
if n == 1
imap <Tab> <Plug>SuperTabForward
...
elseif n == 2
imap <C-Tab> <Plug>SuperTabForward
Alternatively, the brute-force variant would be to reload the plugins (:runtime plugin/supertab.vim) to get the changed global variable values to be considered, but that's very inefficient, may cause errors, and makes you work around plugin load guards in addition.