Jump to content

Why?


Recommended Posts

Global $win
Global $text
While 1
    Sleep(1)
    if Not WinActive($win) then
    $winlist = WinList()
    for $wind in $winlist
        if WinActive($wind) Then            
            $win = $wind            
            $text = $text & "" & $win & " ^ " & @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & ""
        endif
    next
    EndIf
WEnd

this program should record what windows do i use and when... it doesn't work... why.

Link to comment
Share on other sites

I hope you are looking something like this. Study the code line by line and you will understand how things are handled.

Opt("WinTitleMatchMode", 4) ; Match the windows by their handles, not their titles; it gives more accurate results if we have double windows with the same title.
#include <File.au3> ; We need this for the _FileWriteLog function used below.

Dim $active ; Dim the variable outside the loop.

While 1
    $winlist = WinList() ; Return all windows, active or not, to an array
    For $i = 1 To $winlist[0][0] ; Scan all reported window handles ([0][0])
        $state = WinGetState($winlist[$i][1]) ; Check each window state.
        If BitAnd($state, 8) And $winlist[$i][1] <> $active And $winlist[$i][0] <> "" Then ; If the state is found to be active (8) and we have not previously recorded the same action and the window title is not null, write it to the log
            $active = $winlist[$i][1] ; We change this variable here so as to update our check above for the next time.
            _FileWriteLog(@ScriptDir & "\my.log", $winlist[$i][0] & " found active @ " & @HOUR & ":" & @MIN & ":" & @SEC) ; Write down the window found active.
        EndIf
    Next
WEnd
Link to comment
Share on other sites

Try this:

$winlist=WinList()
Global $win =$winlist[1][0]
Global $text
While 1
    Sleep(1)
    If Not WinActive($win) Then
        $winlist = WinList()
        For $k = 1 To $winlist[0][0]
            If $winlist[$k][0] <> "" And IsVisible($winlist[$k][1]) Then
                $win=$winlist[$k][0]
                $text = $text & "" & $winlist[$k][0] & " ^ " & @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & ""&@CRLF
            EndIf
        Next
    EndIf
WEnd
Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc   ;==>IsVisible
A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]
Link to comment
Share on other sites

  • Developers

$title=WinGetTitle('[ACTIVE]')

if I'm correct :)

It's al in the help-file...

my version of the HelpFile states:

Remarks

WinGetTitle("") returns the active window's title. WinGetTitle works on both minimized and hidden windows. If multiple windows match the criteria, the most recently active window is used.

:P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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