Sign in to follow this  
Followers 0
Tukata

How To Detect When A Folder Is Opened ?

34 posts in this topic

#1 ·  Posted (edited)

I need a script to give me a message each time when user opens a certain folder ($FolderPath) with explorer.

Many thanks in advance

Tuk

Edited by Tukata

Share this post


Link to post
Share on other sites



nice pic nitro...

BTW.... can you deliver that???

lol

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Valuater

Your script simply opens C:\Program Files.

What I need is to run a loop and every time I open any folder, to get a message which tells me which folder I opened.

Thanks

Tuk

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Valuater

Your script simply opens C:\Program Files.

What I need is to run a loop and every time I open any folder, to get a message which tells me which folder I opened.

Thanks

Tuk

do i have to hold your friggin hand

#include <GUIConstants.au3>

$folder = FileSelectFolder("Choose a folder.", "")

Run("explorer.exe " & $folder)
WinWaitActive("")
$window = WinGetTitle("")

Sleep(5000)

While 1

If WinActive($window) Then MsgBox(0,"Found", "The window is active" & @CRLF & $window, 2)

Sleep(15000)

WEnd

like some fries with that????

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Do they come with a toy?

Share this post


Link to post
Share on other sites

Do they come with a toy?

LMAO..... :)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Well...either I don't understand the script or this is not what i need.

I have $folder="C:\Folder" and I want to run a script that will detect each time when $folder is opened.

Thanks

Tuk

Share this post


Link to post
Share on other sites

Try this:

While 1
    $OpenExplorer = _GetOpenExplorer()
    If $OpenExplorer Then MsgBox(64, 'Info', $OpenExplorer)
    Sleep(10)
WEnd

Func _GetOpenExplorer()
    $OptTitleMode = Opt('WinTitleMatchMode', 4)
    Local $ExplorerTitle1 = WinGetTitle('Classname=ExploreWClass')
;Local $ExplorerTitle2 = WinGetTitle('Classname=CabinetWClass'); Check to see if this one is needed
    If WinExists($ExplorerTitle1) Then;Or WinExists($ExplorerTitle2) Then; Uncomment this line and the above if you want to use CabinetWClass also
        Opt('WinTitleMatchMode', $OptTitleMode)
        Return $ExplorerTitle1
    EndIf
    Opt('WinTitleMatchMode', $OptTitleMode)
    Return 0
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Try this:

While 1
    $OpenExplorer = _GetOpenExplorer()
    If $OpenExplorer Then MsgBox(64, 'Info', $OpenExplorer)
    Sleep(10)
WEnd

Func _GetOpenExplorer()
    $OptTitleMode = Opt('WinTitleMatchMode', 4)
    Local $ExplorerTitle1 = WinGetTitle('Classname=ExploreWClass')
;Local $ExplorerTitle2 = WinGetTitle('Classname=CabinetWClass'); Check to see if this one is needed
    If WinExists($ExplorerTitle1) Then;Or WinExists($ExplorerTitle2) Then; Uncomment this line and the above if you want to use CabinetWClass also
        Opt('WinTitleMatchMode', $OptTitleMode)
        Return $ExplorerTitle1
    EndIf
    Opt('WinTitleMatchMode', $OptTitleMode)
    Return 0
EndFunc
It does come with a toy!

Share this post


Link to post
Share on other sites

While 1
    $OpenExplorer = _GetOpenExplorer()
    If $OpenExplorer Then MsgBox(64, 'Info', $OpenExplorer)
    Sleep(1000)
WEnd

Func _GetOpenExplorer()
    $OptTitleMode = Opt('WinTitleMatchMode', 4)
Local $ExplorerTitle2 = WinGetTitle('Classname=CabinetWClass')
    If WinExists($ExplorerTitle2) Then
        Opt('WinTitleMatchMode', $OptTitleMode)
        Return $ExplorerTitle2
    EndIf
    Opt('WinTitleMatchMode', $OptTitleMode)
    Return 0
EndFunc

This code works but it detect any folder opened.

I need to detect only a specific folder: C:\Folder

Where do I add this ?

Thank you

Tuk

Share this post


Link to post
Share on other sites

If $OpenExplorer = "C:\Folder" Then MsgBox(64, 'Info', $OpenExplorer)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

If it's a specific file then do what Val has shown, if it is the folder specific, with other files inside, and you want any and all of them, you might try:

If StringInStr($OpenExplorer, 'C:\Folder') Then MsgBox(64, 'Info', $OpenExplorer)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I must be doing something wrong. Here are your both options as I used them but didn't work. Please help, thank you.

While 1
    $OpenExplorer = _GetOpenExplorer()
    If $OpenExplorer = "C:\Folder" Then MsgBox(64, 'Info', $OpenExplorer)
    Sleep(1000)
WEnd

Func _GetOpenExplorer()
    $OptTitleMode = Opt('WinTitleMatchMode', 4)
Local $ExplorerTitle2 = WinGetTitle('Classname=CabinetWClass')
    If WinExists($ExplorerTitle2) Then
        Opt('WinTitleMatchMode', $OptTitleMode)
        Return $ExplorerTitle2
    EndIf
    Opt('WinTitleMatchMode', $OptTitleMode)
    Return 0
EndFunc

While 1
    $OpenExplorer = _GetOpenExplorer()
     If StringInStr($OpenExplorer, 'C:\Folder') Then MsgBox(64, 'Info', $OpenExplorer)
    Sleep(1000)
WEnd

Func _GetOpenExplorer()
    $OptTitleMode = Opt('WinTitleMatchMode', 4)
Local $ExplorerTitle2 = WinGetTitle('Classname=CabinetWClass')
    If WinExists($ExplorerTitle2) Then
        Opt('WinTitleMatchMode', $OptTitleMode)
        Return $ExplorerTitle2
    EndIf
    Opt('WinTitleMatchMode', $OptTitleMode)
    Return 0
EndFunc

Share this post


Link to post
Share on other sites

Ahh, your not going to get the directory name in that, it's simply picking up the title of the window, if the title of the window doesn't show the directory it is in, you won't get it.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Is that means I can't detect when user opens "C:\Folder" ?

Thank you

Tuk

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

HotKeySet( "{Esc}", "exit_now" )

$folder = "C:\"

While 1
    If ControlGetText( "", "", 41477 ) = $folder Then
        MsgBox( 0, "ALERT", "Folder opened!" )
    EndIf
    
    Sleep( 250 )
WEnd

Func exit_now()
   Exit 
EndFunc

This code works for me. You might have to change 41477 to a dif control ID. Open my computer and launch the AutoItInfo Tool and get the control id of the edit field where it says my computer.

Edited by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Don N

Yes ! Your code works perfect.

I am not expert so can you explain this "41477 to a dif control ID" issue ? -

Must I make the changes ?

Will your script work on all OS ?

Thank you very much

Tuk

Edited by Tukata

Share this post


Link to post
Share on other sites

The 41477 is the control id of the edit box that displays your current folder location when browising folders on your computer. Not sure if it will work on all os's as i can only test it on my copy here which is Win 2k SP4. Should work on all windows relaeses with the fact that you might have to change the contorl id, but other than that it is compatible with all windows releases.

This is what im talking about:

http://www.autoitscript.com/fileman/users/newLogic/control%20id%20example.gif

Hope that helps!


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0