Start X1 with already selected on a specific tab

Check in here for general discussion about Search Version 8

Moderator: Mods

Start X1 with already selected on a specific tab

Postby schwarzm » Wed Aug 07, 2019 6:44 am

Greetings. Right now, X1 starts up always on the "All" tab. I'd like it to automatically switch to the "Email" tab. Is there a way, possibly via command-line, to cause this behavior?

Using X1 Search 8.4.1.2 build 50003 qx (64-bit)

Thank you.
schwarzm
 
Posts: 5
Joined: Thu Dec 27, 2018 6:41 am

Re: Start X1 with already selected on a specific tab

Postby Chris Wheaton » Thu Aug 08, 2019 9:58 am

Hello Matthew,

The X1 interface will open in the search from which the interface was most recently closed. Therefore, if you'd prefer it to launch with a focus on the Outlook > All Email search, simply select that search before your shutdown for the evening. Click the Main Menu Button, then Exit from the Navigation Panel on the left.

On your next restart of X1, it will open in the Outlook > All Email search.
Sincerely,

Chris Wheaton
Technical Support
Customer Care Rep.
______________________

www.X1.com
Chris Wheaton
X1 Rep
X1 Rep
 
Posts: 301
Joined: Tue Dec 23, 2008 1:00 pm
Location: Pasadena, CA

Re: Start X1 with already selected on a specific tab

Postby schwarzm » Fri Aug 09, 2019 4:57 am

Ah. That does work.

It isn't working for me because I've been closing X1 with a batch file that calls "taskkill /f /FI "IMAGENAME eq x1*".

Thank you.
schwarzm
 
Posts: 5
Joined: Thu Dec 27, 2018 6:41 am

Re: Start X1 with already selected on a specific tab

Postby Chris Wheaton » Fri Aug 09, 2019 7:39 am

Matt,

Frankly sir, I wouldn't use Taskkill like that unless absolutely necessary. It is a very abrupt way to terminate a program; akin to stopping your car by crashing into a tree rather than applying the break, placing it in park, and terminating the ignition, which is the orderly process for stopping your car. What I've provided to you is the orderly process for stopping X1.

Sincerely,

Chris Wheaton
Sincerely,

Chris Wheaton
Technical Support
Customer Care Rep.
______________________

www.X1.com
Chris Wheaton
X1 Rep
X1 Rep
 
Posts: 301
Joined: Tue Dec 23, 2008 1:00 pm
Location: Pasadena, CA

Re: Start X1 with already selected on a specific tab

Postby Jogy » Fri Aug 09, 2019 8:58 am

Hi,

As Chris said, killing X1 processes is not advisable, it can lead to index corruption.

If you need to close X1 processes programmatically, here are two ways:

1. Make sure the "Shutdown indexing on application close" option is turned on, and execute the command
Code: Select all
"c:\Program Files\X1 Search\X1.exe" -shutdown
Note that this will work only with latest versions, I think 8.6.1 and up

2. Execute this simple PowerShell script that sends an EndSession message to X1 processes:
Code: Select all
Get-Process "X1" | Foreach-Object { $HWND = $_.MainWindowHandle }

$WM_ENDSESSION = 0x16
#Store the C# signature of the PostMessage function.
$signature = @"
[DllImport("user32.dll")]
public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);
"@
#Add the PostMessage function as a static method of a class
$PostMessage = Add-Type -MemberDefinition $signature -Name "Win32SendMessage" -Namespace Win32Functions -PassThru
#Invoke the PostMessage Function
$PostMessage::PostMessage($HWND, $WM_ENDSESSION, 0, 0)
Jogy
X1 Super User
X1 Super User
 
Posts: 375
Joined: Mon Oct 31, 2011 9:19 am

Re: Start X1 with already selected on a specific tab

Postby schwarzm » Fri Aug 09, 2019 10:27 am

The powershell script worked perfectly! Thanks so much!

I don't have the latest version in my company, so can't use the -shutdown command yet.

Thanks again.
schwarzm
 
Posts: 5
Joined: Thu Dec 27, 2018 6:41 am

Re: Start X1 with already selected on a specific tab

Postby schwarzm » Fri Aug 09, 2019 10:44 am

Follow-up question: that powershell script only seems to work if I happen to have the X1 Window up. If I have the window closed (minimized to systray) then the script has no effect. Is that expected behavior?
schwarzm
 
Posts: 5
Joined: Thu Dec 27, 2018 6:41 am

Re: Start X1 with already selected on a specific tab

Postby Jogy » Fri Aug 09, 2019 7:50 pm

Hi,

try to add this at the end of the previous script:

Code: Select all
$Win32API = Add-Type -Name Funcs -Namespace Win32 -PassThru -MemberDefinition @'
    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(string lpClassName, IntPtr lpWindowName);

    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(IntPtr lpClassName, string lpWindowName);
'@

$HWND2 = $Win32API::FindWindow([IntPtr]::Zero, 'X1 Search')

$PostMessage::PostMessage($HWND2, $WM_ENDSESSION, 0, 0)


This should handle the case when X1 is minimized in the system tray.
Jogy
X1 Super User
X1 Super User
 
Posts: 375
Joined: Mon Oct 31, 2011 9:19 am

Re: Start X1 with already selected on a specific tab

Postby Jogy » Fri Aug 09, 2019 8:28 pm

Here is a slightly reordered full content of the PowerShell script for gracefully closing X1:

Code: Select all
Get-Process "X1" | Foreach-Object { $HWND = $_.MainWindowHandle }

$Win32API = Add-Type -Name Funcs -Namespace Win32 -PassThru -MemberDefinition @'
    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(string lpClassName, IntPtr lpWindowName);

    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(IntPtr lpClassName, string lpWindowName);
'@

$HWND2 = $Win32API::FindWindow([IntPtr]::Zero, 'X1 Search')

$WM_ENDSESSION = 0x16
#Store the C# signature of the PostMessage function.
$signature = @"
[DllImport("user32.dll")]
public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);
"@
#Add the PostMessage function as a static method of a class
$PostMessage = Add-Type -MemberDefinition $signature -Name "Win32SendMessage" -Namespace Win32Functions -PassThru

#Invoke the PostMessage Function
$PostMessage::PostMessage($HWND, $WM_ENDSESSION, 0, 0)

if ($HWND -ne $HWND2) { $PostMessage::PostMessage($HWND2, $WM_ENDSESSION, 0, 0) }


Jogy
Jogy
X1 Super User
X1 Super User
 
Posts: 375
Joined: Mon Oct 31, 2011 9:19 am

Re: Start X1 with already selected on a specific tab

Postby schwarzm » Mon Aug 12, 2019 5:41 am

That works perfectly!! Thanks so much!
schwarzm
 
Posts: 5
Joined: Thu Dec 27, 2018 6:41 am


Return to General Discussion V8

Who is online

Users browsing this forum: DennisLauct, Kenward, Pavloseqv and 28 guests