How to detect Explorer Window - Forum

Forum Navigation
You need to log in to create posts and topics.

How to detect Explorer Window

I am working on an application that makes it easier to copy text from any text application to any other application that can receive text. I am using global keyboard hooks that perform global Neo SendKeys operations.

It works fairly well in text applications. However, if the user mistakingly presses any of the global Hotkeys in Windows Explorer (and several other applications) then it will cause serious havoc...

Starting with Windows Explorer. Is there any way Neo can detect whether it concerns an Explorer window before sending keys, and then Return(don't do anything)? If so, how do I implement that?

For instance, in the Subroutine I'm using:

:Bring Over
SendKeys "" "{CtrlDn}a{CtrlUp}{CtrlDn}x{CtrlUp}"
SendKeys "" "{AltDn}{Esc}{AltUp}"
Delay "250"
SendKeys "" "{CtrlDn}v{CtrlUp} "
SendKeys "" "{Right}"
Delay "150"
SendKeys "" "{AltDn}{Tab}{AltUp}"



Observe the [NameClass] variable as you navigate through windows. And then you can use if.
zmFunctions plugin.

Uploaded files:
  • You need to login to have access to uploads.
Vadim has reacted to this post.

Thanks Mishem,

Yes, I have the zmFunctions plug-in and I understand the timer approach. I found the ClassName of Windows Explorer to be any of the following (but the first is probably the correct one):


In my app there is no need to determine a specific Explorer window name (like Documents, My Music, My pictures etc.), instead I want my SendKeys script to not work as soon as any Windows Explorer window is encountered. So basically I would just need to "blacklist" CabinetWClass in my app?

Would it be possible to give me a working example of this in my above SendKeys script?

It can be done in different ways.

You can then add other window classes to the blacklist if problems arise with them too.

Uploaded files:
  • You need to login to have access to uploads.

Thanks Mishem,

But for some reason, this is not working. I made it part of the Subroutine (because the Timer caused a bit of a ruckus)... Like so:

:Bring Over
zmGetForegroundWindow "[HNWD]"
zmGetWindowTitle "[HNWD]" "[NameClass]" "[Title]"
SearchStr "[NameClass]" "[blacklist]" "[Result]" ""
If "[Result]" "=" "0"
SendKeys "" "{CtrlDn}a{CtrlUp}{CtrlDn}c{CtrlUp}"
SendKeys "" "{AltDn}{F4}{AltUp}"
SendKeys "" "{Right}"
SendKeys "" "{Enter}"
Delay "500"
SendKeys "" "{CtrlDn}v{CtrlUp} "

But it seems to completely ignore the blacklist, even though it's in the PubDir. It just performs the SendKeys every time...


How is the subroutine launched? Through a button? When you click a button, the top window at that moment becomes the one in which the button is located.

I uploaded the project for you to test. It's a tray application.

Once it's running Open up WordPad and then Notepad. Type something in Notepad and then press:

Shift+` (this is a global hotkey via NeoBookKB plug-in).

You will see that the Notepad contents will be pasted into Wordpad (and closing Notepad). At least, that's what it should do.

Even though, both applications are in the blacklist...

I also tried using the [Title] variable to see if that would make a difference, but it does not appear to work either...

I added some additional classes to the blacklist to try.

Uploaded files:
  • You need to login to have access to uploads.

1. Your result will always be 0, since the [blacklist] variable is empty. Do you need to first load a list from a file into a variable?

FileRead "[PubDir]blacklist.txt" "All" "[blacklist]"
kbAddHotKey "Shift+`" "Bring Over"

2. VisualNeoWin does not work with UTF-16 encoding. Therefore, the blacklist must be in ANSI encoding.

Uploaded files:
  • You need to login to have access to uploads.
luishp, Vadim and Talker have reacted to this post.

Thanks so much Mishem! Indeed now it works :-).

One final request. For users to be able to modify the blacklist text file themselves, it would be handy if it was automatically placed in a subfolder of their Documents folder:

"C:\Users\username\Documents\Bring Over App\blacklist.txt"

Is it possible to make the application check on boot up if that file exists? If not, could it write the text file to that location (including the current blacklist entries)?

From that point on users would be able to add new entries on their own.

Like that. You need to solve such simple problems yourself.
I provided an example with the ability to add to the blacklist directly from the system tray.

Uploaded files:
  • You need to login to have access to uploads.
Vadim has reacted to this post.

Great idea to be able to edit the blacklist directly from the system tray :-).
It all works.

Thanks again. A great lesson!

Open chat
Do you need more info?
Hi, do you have any doubt?