Jump to content

Window address?


Khryus
 Share

Recommended Posts

Hi, I am trying to retrieve a window's address with autoit (it looks like C:somefoldersomeotherfolder...).

I was thinking of using WinExists, but since I want to make it so that a function will be triggered when a certain folder is opened (for example C:testfolderprivate), I need to read the address of the active window.

I am not entirely sure on how to do this, but I noticed that by using the AutoIt 3 Window Info tool I can read the window address. The point is: how do I incorporate that into my code? How do I get what Window Info reads in my script? 

I'm sorry if this isn't clear, if you need further explanations I'll try my best :D

EDIT: I found a way to do this (using WinGetText and WinGetHandle for who is interested). Sorry mods ! This thread can be closed :)

EDIT 2 : here's the code if anyone is interested!

$auth=False ; don't edit this
$address="insert address here"
$timeout=7 ; time to input your password when requested
$poll=500 ; how long the script waits before another loop (longer = uses less cpu, but means less efficient script because it might trigger the pass request too late, so I'd say this is a good number)
;to set a password you need to make a file "pass.txt" - put your password in there

While 1
    $str=WinGetText("[active]")
    Switch StringInStr($str, $address)
        Case Not 0
            Switch $auth
                Case True
                    $handle=WinGetHandle("")
                    WinWaitClose($handle)
                    ConsoleWrite("auth lost"&@crlf)
                    $auth=False
                Case False
                    WinClose(WinGetHandle(""))
                    $input=InputBox("Authentication Requested", $timeout&"s Timeout"&@CRLF&"Password", "", "*", "", "", "", "", $timeout)
                    If $input == FileReadLine(FileOpen("pass.txt"), 1) Then
                        $auth=True
                        WinActivate(Run("explorer.exe " & $address))
                    EndIf
            EndSwitch
        EndSwitch
    Sleep($poll)
WEnd
Edited by megablox

"The story of a blade is linked in Blood." 

―Yasuo

 

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...