Jump to content

How To Detect When A Folder Is Opened ?


Recommended Posts

  • Moderators

I would just use the ClassNameNN

MsgBox(0, '', _GetFileInUse())
Func _GetFileInUse()
    $OptWindowMode = Opt('WinTitleMatchMode', 4)
    Local $WinClass = 'classname=ExploreWClass'
    Local $FileInUse = ControlGetText($WinClass, '', 'Edit1')
    Opt('WinTitleMatchMode', $OptWindowMode)
    Return $FileInUse
EndFunc

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.

Link to comment
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.

I am completely new to autoit and desktop programming in general (I'm a webdeveloper). Could I ask where you obtain the control id of objects in windows?

Link to comment
Share on other sites

  • Moderators

I am completely new to autoit and desktop programming in general (I'm a webdeveloper). Could I ask where you obtain the control id of objects in windows?

If you are going to be doing Browser options you will need to look at IE.au3

and you can find the IE.au3 Help File here

As for how we find ControlID's in other applications, we use the AutoIt Window Info Tool

Start >> All Programs >> AutoItv3 >>

Edit:

Tad slow to the Valanizer!

Edited by SmOke_N

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.

Link to comment
Share on other sites

I would just use the ClassNameNN

MsgBox(0, '', _GetFileInUse())
Func _GetFileInUse()
    $OptWindowMode = Opt('WinTitleMatchMode', 4)
    Local $WinClass = 'classname=ExploreWClass'
    Local $FileInUse = ControlGetText($WinClass, '', 'Edit1')
    Opt('WinTitleMatchMode', $OptWindowMode)
    Return $FileInUse
EndFunc
But where do I put this code ?

Tuk

Edited by Tukata
Link to comment
Share on other sites

  • Moderators

But where do I put this code ?

Tuk

I can think of a few places :)

It returns a value, so you put the UDF anywhere and use it like:

If StringInStr(_GetFileInUse(), @HomeDrive & '\') Then MsgBox(64, 'Info:', 'Found')

Func _GetFileInUse()
    $OptWindowMode = Opt('WinTitleMatchMode', 4)
    Local $WinClass = 'classname=ExploreWClass'
    Local $FileInUse = ControlGetText($WinClass, '', 'Edit1')
    Opt('WinTitleMatchMode', $OptWindowMode)
    Return $FileInUse
EndFunc

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.

Link to comment
Share on other sites

  • 2 weeks later...

I can think of a few places :D

It returns a value, so you put the UDF anywhere and use it like:

If StringInStr(_GetFileInUse(), @HomeDrive & '\') Then MsgBox(64, 'Info:', 'Found')

Func _GetFileInUse()
    $OptWindowMode = Opt('WinTitleMatchMode', 4)
    Local $WinClass = 'classname=ExploreWClass'
    Local $FileInUse = ControlGetText($WinClass, '', 'Edit1')
    Opt('WinTitleMatchMode', $OptWindowMode)
    Return $FileInUse
EndFunc

This code to use classname doesn't work at all. Is this the whole code or just partial?

Link to comment
Share on other sites

works for me in the release and beta version

if you want to be a little more precise in what is open try something like

If StringUpper(_GetFileInUse()) = StringUpper(@HomeDrive & '\') Then MsgBox(64, 'Info:', 'Found')

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Try:

If IsEqual(_GetFileInUse(),@HomeDrive & '\') Then 
    MsgBox(64, 'Info:', 'Found')
Else
    MsgBox(64, 'Info:', 'Not Found')
EndIf

Func _GetFileInUse()
    $OptWindowMode = Opt('WinTitleMatchMode', 4)
    Local $WinClass = 'classname=ExploreWClass'
    Local $FileInUse = ControlGetText($WinClass, '', 'Edit1')
    Opt('WinTitleMatchMode', $OptWindowMode)
    Return $FileInUse
EndFunc
 
Func IsEqual($s_first, $s_second)
    If StringUpper($s_first) = StringUpper($s_second) Then Return 1
    Return 0
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I see why it exit. The folder wasn't found so it exited. But then it seems that it can't find my @HomeDrive or even c:\ which I changed it. It would just load and say not found.

Perhaps you had opened the drive in a window rather than an explorer.

Try this modified code...

$explore='ExploreWClass'
$window='CabinetWClass'
$lookfor=@HomeDrive & '\'

If IsEqual(_GetFileInUse($explore),$lookfor) Then 
    MsgBox(64, 'Info:', 'Found explorer '&$lookfor)
ElseIf  IsEqual(_GetFileInUse($window),$lookfor) Then 
    MsgBox(64, 'Info:', 'Found window'&$lookfor)
Else
    MsgBox(64, 'Info:', 'Not Found '&$lookfor)
EndIf


Func _GetFileInUse($class)
    $OptWindowMode = Opt('WinTitleMatchMode', 4)
    Local $WinClass = 'classname='&$class
    Local $FileInUse = ControlGetText($WinClass, '', 'Edit1')
    Opt('WinTitleMatchMode', $OptWindowMode)
    Return $FileInUse
EndFunc
 
Func IsEqual($s_first, $s_second)
    If StringUpper($s_first) = StringUpper($s_second) Then Return 1
    Return 0
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...