AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Write the current active window name to text file

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Dannymet



Joined: 18 Jul 2008
Posts: 28

PostPosted: Sun Mar 01, 2009 4:40 pm    Post subject: Write the current active window name to text file Reply with quote

The following script writes the current active window name to Windows.txt

Code:
#NoEnv
SendMode Input
DetectHiddenWindows, On

Goto, Title
;------------------------------------------------------------------------------------------------------
 GetTitle:
  Loop
    {
     WinGetActiveTitle, Title1
      If (Title = Title1)
      Goto, GetTitle
       else
      Goto, Title
    }
;------------------------------------------------------------------------------------------------------
 Title:
   WinGetActiveTitle, Title
   FormatTime, FormatDate,, MM-dd-yyyy  HH:mm:ss
    FileAppend, `n-------- %Title% - %FormatDate% --------`n, Windows.txt
     Goto, GetTitle
;------------------------------------------------------------------------------------------------------



But theres a bug that I cant seem to fix.
It will log the current window, then when it sees another window it will log it blank then log it agian with the window name:
Code:
-------- New Folder (3) - 03-01-2009  16:37:47 --------

--------  - 03-01-2009  16:37:49 --------

-------- New Folder (2) - 03-01-2009  16:37:49 --------

--------  - 03-01-2009  16:37:50 --------

-------- New Folder (3) - 03-01-2009  16:37:50 --------

--------  - 03-01-2009  16:37:51 --------


Is there any way around this? so it just looks like this:
Code:
-------- New Folder (3) - 03-01-2009  16:37:47 --------

-------- New Folder (2) - 03-01-2009  16:37:49 --------

-------- New Folder (3) - 03-01-2009  16:37:50 --------







edit:
Fixed it with a simple if command:
Code:
#NoEnv
SendMode Input
DetectHiddenWindows, On

Goto, Title
;------------------------------------------------------------------------------------------------------
 GetTitle:
  Loop
    {
     WinGetActiveTitle, Title1
      If (Title = Title1)
      Goto, GetTitle
       else
      Goto, Title
    }
;------------------------------------------------------------------------------------------------------
 Title:
   WinGetActiveTitle, Title
   FormatTime, FormatDate,, MM-dd-yyyy  HH:mm:ss
    if (Title = "")
     Goto, GetTitle
    Else
    {
     FileAppend, `n-------- %Title% - %FormatDate% --------`n, Windows.txt
      Goto, GetTitle
    }
;------------------------------------------------------------------------------------------------------


[Title edited. Please write descriptive titles for your topics. ~jaco0646]
Back to top
View user's profile Send private message
evan



Joined: 19 Feb 2009
Posts: 125

PostPosted: Sun Mar 01, 2009 5:15 pm    Post subject: Reply with quote

u are just killing ur computer with constant checking
u should try using WinWaitNotActive
Back to top
View user's profile Send private message
Dannymet



Joined: 18 Jul 2008
Posts: 28

PostPosted: Sun Mar 01, 2009 5:26 pm    Post subject: Reply with quote

Ive just realised its using all my CPU

where would i put winwaitnotactivate in my script?
Back to top
View user's profile Send private message
Wouther



Joined: 01 May 2007
Posts: 83
Location: The Netherlands

PostPosted: Mon Mar 02, 2009 9:49 am    Post subject: Reply with quote

I can't test it right now, but my guess is something like:
Code:
WinWaitNotActive, A

...followed by FormatTime, FileAppend, etc.
In a loop, of course! Smile
_________________
Printing css/html-formatted text
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group