Window Checker help needed Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Murkov01

Window Checker help needed

22 Feb 2018, 21:05

I'm tryna make a window checker that detects whenever a new window is opened and then puts it in a text file, but I'm really having trouble, can someone help me out, cheers

Code: Select all

loop
{
start:
if new_window = window_title
{	
	new_window = diff
	goto, start
}
else
{
	WinGetActiveTitle, window_title
	fileappend, %window_title% `n, C:\mypaths.txt
	new_window = window_title
	goto, start
}
}
thanks I really appreciate your time :)
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: Window Checker help needed

23 Feb 2018, 00:03

No reason to have a loop if you're simulating a loop with gotos. Just get rid of the gotos. It's a horrible practice.

You have problems with your syntax. Here it is corrected using legacy syntax, which it looks like you tried to use:

Code: Select all

loop
{
	if new_window = %window_title%
		new_window = diff
	else
	{
		WinGetActiveTitle, window_title
		fileappend, %window_title%`n, C:\mypaths.txt
		new_window = %window_title%
	}
}
Here's expression syntax, which is better:

Code: Select all

loop
{
	if (new_window = window_title)
		new_window := "diff"
	else
	{
		WinGetActiveTitle, window_title
		fileappend, % window_title . "`n", C:\mypaths.txt
		new_window := window_title
	}
}
Murkov01

Re: Window Checker help needed

23 Feb 2018, 01:21

this is good, except what I am trying to do is make it post a single appendage of the window title, the script you provided me with continuously loops :/
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: Window Checker help needed  Topic is solved

23 Feb 2018, 07:54

I was just fixing the syntax so you could work on the logic. Here's the logic fixed:

Code: Select all

loop
{
	WinGetActiveTitle, window_title
	if (new_window != window_title)
	{
		fileappend, % window_title . "`n", C:\mypaths.txt
		new_window := window_title
	}
	Sleep, 100
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: fiendhunter and 218 guests