Page 1 of 1

Attaching to Window with Wierd Name

Posted: Tue Mar 17, 2009 2:57 pm
by eviltuna
I'm trying to make a bot in ESO http://eso.perfectworld.com/, but I'm having trouble getting getting micromacro to attach to the game window as it has a really wierd name in a chinese font. I've managed to make a list of all the windows but still haven't been able to attach to it. Is there a way to attach a window using an EXE?

Re: Attaching to Window with Wierd Name

Posted: Tue Mar 17, 2009 6:55 pm
by 3cmSailorfuku
eviltuna wrote:I'm trying to make a bot in ESO http://eso.perfectworld.com/, but I'm having trouble getting getting micromacro to attach to the game window as it has a really wierd name in a chinese font. I've managed to make a list of all the windows but still haven't been able to attach to it. Is there a way to attach a window using an EXE?
http://solarimpact.servegame.com/wiki/i ... ocessByExe

Re: Attaching to Window with Wierd Name

Posted: Tue Mar 17, 2009 7:10 pm
by Administrator
Attached input doesn't work with this game. I've already got a (very) basic bot set up, but most of the input doesn't work when attached. Tabbing, for example, works, but pressing skill hotkeys doesn't.

Re: Attaching to Window with Wierd Name

Posted: Tue Mar 17, 2009 7:54 pm
by eviltuna
3cmSailorfuku wrote:
eviltuna wrote:I'm trying to make a bot in ESO http://eso.perfectworld.com/, but I'm having trouble getting getting micromacro to attach to the game window as it has a really wierd name in a chinese font. I've managed to make a list of all the windows but still haven't been able to attach to it. Is there a way to attach a window using an EXE?
http://solarimpact.servegame.com/wiki/i ... ocessByExe
I am talking about the attach() fuction, not the openProcessbyExe, I know about that. Thanks though.

Re: Attaching to Window with Wierd Name

Posted: Wed Mar 18, 2009 8:20 am
by 3cmSailorfuku
eviltuna wrote:
3cmSailorfuku wrote:
eviltuna wrote:I'm trying to make a bot in ESO http://eso.perfectworld.com/, but I'm having trouble getting getting micromacro to attach to the game window as it has a really wierd name in a chinese font. I've managed to make a list of all the windows but still haven't been able to attach to it. Is there a way to attach a window using an EXE?
http://solarimpact.servegame.com/wiki/i ... ocessByExe
I am talking about the attach() fuction, not the openProcessbyExe, I know about that. Thanks though.
Actually I was talking about getting like that the Process ID, which can be used as far as I can remember.
Although it's important in what encoding you are saving your files if you use Strings that contain anything else than western standards.

Re: Attaching to Window with Wierd Name

Posted: Wed Mar 18, 2009 11:01 am
by Administrator
I'm guessing you're looking for a function like findProcessByWindow() but in reverse (findWindowByProcess()). In that case, no. There is no such function at this time. You could still write a set of functions to find what you need.

First, just get a list of all windows (findWindowList("*") should work), then iterate through each element in the returned list and check it's paired process using findProcessByWindow(). Here's an example script using exactly this method:

Code: Select all

function findWindowByProcess(proc)
	local windowList = findWindowList("*");

	for i,v in pairs(windowList) do
		local thisProc = findProcessByWindow(v);
		if( thisProc == proc ) then
			return v;
		end
	end

	return nil; -- In case the process isn't found, return nil
end


function main()
	local notepadWin = findWindow("Untitled - Notepad");
	local notepadProc = findProcessByWindow(notepadWin);

	printf("win: 0x%X, proc: 0x%X\n", notepadWin, notepadProc);

	local foundWin = findWindowByProcess(notepadProc);
	printf("Found win: 0x%X\n", foundWin);
end
startMacro(main);
foundWin was exactly the same as notepadWin, which means it worked. Just copy/paste the findWindowByProcess() function into your script for now, as the function may be added to the core later. Since you should only be calling this once per execution, it shouldn't cause any slowdowns. Not that the code is overly heavy or anything.

Re: Attaching to Window with Wierd Name

Posted: Wed Mar 18, 2009 2:18 pm
by eviltuna
Thats exactly what I was thinking of doing, but since you did it already, thanks =D
Administrator wrote:I'm guessing you're looking for a function like findProcessByWindow() but in reverse (findWindowByProcess()). In that case, no. There is no such function at this time. You could still write a set of functions to find what you need.

First, just get a list of all windows (findWindowList("*") should work), then iterate through each element in the returned list and check it's paired process using findProcessByWindow(). Here's an example script using exactly this method:

Code: Select all

function findWindowByProcess(proc)
	local windowList = findWindowList("*");

	for i,v in pairs(windowList) do
		local thisProc = findProcessByWindow(v);
		if( thisProc == proc ) then
			return v;
		end
	end

	return nil; -- In case the process isn't found, return nil
end


function main()
	local notepadWin = findWindow("Untitled - Notepad");
	local notepadProc = findProcessByWindow(notepadWin);

	printf("win: 0x%X, proc: 0x%X\n", notepadWin, notepadProc);

	local foundWin = findWindowByProcess(notepadProc);
	printf("Found win: 0x%X\n", foundWin);
end
startMacro(main);
foundWin was exactly the same as notepadWin, which means it worked. Just copy/paste the findWindowByProcess() function into your script for now, as the function may be added to the core later. Since you should only be calling this once per execution, it shouldn't cause any slowdowns. Not that the code is overly heavy or anything.

Re: Attaching to Window with Wierd Name

Posted: Wed Mar 18, 2009 2:19 pm
by eviltuna
I've managed to attach to the window, but you are right, can't send any keys to it, except tab. I did try using AutoIt and was able to get keys sent using the Send() function, but ControlSend didn't work very well.