How to interface Windows Search with Emacs - windows

How can I access Windows Search index data from Emacs? Knowing this would be useful for example when writing a minor mode that integrates Windows Search into anything mode or ido-mode.
By Windows Search, I mean the Windows 7 feature that lets you find documents by pressing Start and typing part of document file names (or part of document contents).

Here is a little Python script providing a command line utility for Windows Search. You need to install Python for Windows extensions to use it.

Accessing Windows Search from within emacs is going to be a bit difficult because the API Microsoft provides is strongly skewed towards the Microsoft programming environment. Judging by the MSDN docs, the easiest path would be putting together a SQL query that Windows Search will accept and sending that to a PowerShell/VB script that knows how to send that query to Windows Search. You'd then tell anything/ido/icicles to incrementally send input to such a script, parse the results, and display those.
The task that you are attempting is very difficult, and much of the difficulty comes from the fact that you are trying to get two programs from very different worlds of programming to talk to one another. Completely apart from the FSF/GNU folks actively disliking Microsoft, the design of the Windows API means that the least-effort way of dealing with Windows is to use the Microsoft toolchain. This in contrast to the Unix "API" of sending plain text through intermediary programs, pipes, and sockets.

Related

What's the recommended tech to program Windows shell?

I am developing a small tool that can detecting which folders are being opened in windows explorer and bring it to front if a specific address has been opened.
I can use both C# and C++ and finally pick C# as it is easier than C++ to accomplish the same target. Then I googled the internet and knowing COM object SHDocVw.ShellWindows can help collect all windows being opened. Then I start looking for Microsoft document to see if any functions can help to achieve my other requirements. However, when I search shell related documents: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ff521731(v=vs.85) I am warned that "We're no longer updating this content regularly. Check the Microsoft Product Lifecycle for information about how this product, service, technology, or API is supported." Moreover, some documents even say these techs will be deprecated in Win11 (See the following screenshot)
I am wondering what the status of these Shell related technical. If these are being deprecated. What's the alternative solution? I don't want my tool stop working when start using new Windows. Meanwhile, I am confusing in the study routine of learning Windows desktop technical. Looks like so many technical to achieve the same targets. Is there anyone can give me some road maps?
Last thing, it's really frustrating to search COM object documents at Microsoft sites. Is this tech going down?
Microsoft has been trying to kill win32/desktop applications since Windows 8. That parts of the documentation is labeled as "legacy" is not something I would worry too much about. Some of the shell functions have been marked as deprecated for 20 years but still work fine today and too many applications rely on them for Microsoft to successfully remove them.
The Internet Explorer warning is different and IE might actually go away but that does not affect IShellWindows which is also used by Explorer.exe and 3rd-party applications. Its implementation lives in a shell DLL and not in IE.

Finding PowerShell Cmdlets equivalent to GUI actions

I would like to know where I could find good resources/documentation on configuring a new Windows10 installation using Powershell scripts. I know bash but I'm completely new to Powershell.
When I search google, all I can find about automatically configuring Windows relates to Windows Deployment Services. But I don't have and don't want a Windows Server and simply running a few scripts after each installation is sufficient for me.
I found a few scripts that solve some of the things I want to do:
https://github.com/FlatlanderWoman/winCleaner
https://github.com/hahndorf/Set-Privacy
But for everything else, when I look into the TechNet Library I find it very hard to find anything useful. And when I do find something, it looks outdated:
https://technet.microsoft.com/en-us/library/hh852115.aspx
The problem is: I known the GUI-way of configuring everything I want, but I don't know how to find the corresponding commandlets to do the same with Powershell.
Is there some kind of event listener I could use to find the Cmdlets? Or does anyone have some resources/documentation to recommend? Is the TechNet Library really the established way to find these commands?
Thank you.
Unfortunately PowerShell was only really implemented in Windows 7 (yes I know it was available for XP but not preinstalled) and even then it was kind of like an addon rather than part of the core OS. Windows 8 and 10 have further improved functionality but still for the most part do not use it for their own settings and functions as most home users would have no use for it.
However there is nearly always a way to do whatever you need to, I have a script that configures servers from scratch, renaming the server, installing requisite software and features, copying files, configuring VSS, right down to putting the Computer icon on the desktop. You just have to make a list of everything you want to do, then Google each one.
For example: https://www.google.co.uk/search?q=powershell+put+computer+on+desktop - at time of writing the first result is a TechNet script pointing at a registry key. Tidy as necessary, whack into your build script and move on to the next item.
As of yet there's nothing I've found I've been unable to do with PowerShell, but the vast majority of it has not been directly with cmdlets. There's a lot of registry tweaking and command line stuff like msiexec or schtasks, some COM objects and an awkward Type I had to create and use to set the DNS suffix.
Overall I think it's still easier to do all this in PowerShell than any other scripting language and it's more flexible than premade tools, not because it has so much functionality built-in but because it can access .NET and COM which gives you broad access to all the half-baked stuff MS have wedged in over the years.

Autotext for Windows 7

'm creating a small accessibility feature in Visual C++ 2010 that I will use for myself for replacing bits of text anywhere within Windows 7. Something similar to the AutoText feature in Word. It should replace whole words only too.
For example, replace u with you but should not have you as yoyou. When the user types the first few letters of a known word or sentence that is stored in the autotext, i want to replace it with something.
I don't want a console program but a small application that runs in the background, perhaps in the tray that whenever its not needed, i can just quit it and it would stop matching.
I am learning Win32 programming and I am a fairly good at programming so any tips for me on what API/classes I can jump directly to and learn first.
Thank you.
You can probbaly get the information and events you want using CBT hooks and/or the accessability APIs.
There are tons of such programs available for such purpose already.
Try http://www.autotext-software.com or http://www.phraseexpress.com (This is a Autotext power tool). Both are free.

MS Access full text and file search

I am trying to integrate the Windows desktop file search feature into MSAccess to search files based on content .
For eg:
I want to search for all the files containing "Noble" in its content( preferably it also searches PDF content ) in a specific fodler(s) form MS Access.
Can anyone suggest good place to start?
I've been down this road. Windows Search or Google Search are quite problematic, particularly if you want to search data on a server, because you have to maintain indexes on each client workstation. There's a server version for Windows Search but the API is very complicated.
Office versions from 97 to 2003 provided a FileSearch object that was quite versatile, but that was removed in Office 2007.
Because of that, I coded up a FileSearch class module for use in Access to replace the core functionality provided by the old FileSearch object. You can find the code on my website. It still needs a lot of work, but I've had in production use since June 2009. It does have some issues on Vista/Win7 if you try to search folders that aren't available to non-admin users, and some other problems, too. I've wanted to get back to it and change the progress bar to use WithEvents, but as I've already got a working implementation for the two applications where I'm using it, it wasn't really worth my time.
Try it and see if you have any problems. For searching files for strings in those files, it works pretty well (much faster than the built-in WinXP search functionality!), but it's not going to be as fast as Vista/Win7's search, since it's not index-based.
At work I use Google Desktop because we're still on Windows XP and I don't know if that is the reason, but I'm not impressed with Windows Search.
I don't even think you can go into Access itself and do a search to look everywhere (data, objects, code, etc.).

Getting the path & filename of the open document in any Windows application

Goal
Let me start with my final vision of what I'd like to be able to do first: In Windows, I'd like to be able to use a global keyboard shortcut that I define (say, Ctrl+Alt+C) to copy the full path and filename of the open document in the foreground application to the clipboard.
This would be useful to, for example, be able to subsequently paste the path & filename into an "Open File" dialog in an email client to attach that document to an email, without having to manually browse to the target document in the filesystem.
Specific Question
Now, the specific part of how to do this that I'm interested in how to implement is: How can I get the path and filename of the current "open document" of any arbitrary currently-running Windows application. (If this can't be done with any Windows application, then the next best thing would be for this to work with as many applications as possible.)
Obviously, this wouldn't apply to some applications that don't necessarily have the concept of a "currently open document" that corresponds to a file on the local filesystem, such as an email client, an IM client, or (usually) a web browser.
Application-Specific Solutions
I'm aware that it's possible to write application-specific solutions to do this. For example, the following MS Word VBA subroutine will copy the filename and path of the open document in Word to the clipboard:
Dim myDataObject As DataObject
Set myDataObject = New DataObject
myDataObject.SetText ActiveDocument.FullName
myDataObject.PutInClipboard
However, what I really want is something that will work for any of the applications on my system (or, again, for as many of them as reasonably possible) without having to try and write an application-specific solution for each one.
Idea: Recent Documents Folder
One idea: Could the Recent Documents folder (and/or its underlying Windows APIs) somehow be leveraged to help with this? It seems to have information about the same concept of "open documents" that I'm interested in here, that apparently applies across various application types. (Looking at the contents of the Recent Documents folder on my machine, I see entries in there that were apparently made for documents that I opened with various applications including MS Word, MS Excel, Eclipse, Adobe Acrobat Reader, Paint.NET, TOAD, and Notepad2.)
Preferred Solution Language
I'd prefer solutions in C# or C++ code, but I'm open to any suggestions for how to go about doing this, regardless of implementation language!
Windows 7?
Update 11/2009: Now that Windows 7 is widely available, I figured it might be worth coming back to this question and asking: Does Windows 7 provide any new APIs, or any other mechanism, that would help with what I'm trying to accomplish here?
The best you could probably do is look at the recent documentation registry keys, and get the list of most recent documents. Some sample code for working with this data is in this CodeProject article. This is saved in:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs
However, this isn't going to show you whether a document is currently open or not. You could potentially check the title of all open applications, since many applications put document names in their window titles, but this is not a requirement, and many applications do not do that.
There is no mandatory mechanism for an application to specify its open document, so this is not generically possible.

Resources