Sign in to follow this  
Followers 0
Somniis

Get Window without Title

8 posts in this topic

I have looked through the forum and haven't found anything on this. Please excuse me if there is something on this.. I may have not looked deep enough. :D

I am writing a bot for a game. The game, to protect against bots such as mine, has the name of the window change every few seconds. It changes to 7 random lower-case letters. Anyhow, is there a way to get this window without using the title of it?

I've been using WinWaitActive.. but this of course requires the title, which I cannot obtain. Any suggestions/references are greatly appreciated. :D

Share this post


Link to post
Share on other sites



I have looked through the forum and haven't found anything on this. Please excuse me if there is something on this.. I may have not looked deep enough. :D

I am writing a bot for a game. The game, to protect against bots such as mine, has the name of the window change every few seconds. It changes to 7 random lower-case letters. Anyhow, is there a way to get this window without using the title of it?

I've been using WinWaitActive.. but this of course requires the title, which I cannot obtain. Any suggestions/references are greatly appreciated. :D

WinGetHandle()

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I have looked through the forum and haven't found anything on this. Please excuse me if there is something on this.. I may have not looked deep enough. :D

I am writing a bot for a game. The game, to protect against bots such as mine, has the name of the window change every few seconds. It changes to 7 random lower-case letters. Anyhow, is there a way to get this window without using the title of it?

I've been using WinWaitActive.. but this of course requires the title, which I cannot obtain. Any suggestions/references are greatly appreciated. :P

WinGetHandle(), as Smoke already suggested will give you the handle of the window so the title does not matter.

Another solution I have used is WinGetTitle(""), this will return the title of the currently active window. So if you change the title, you can instantly get the new title this way.

Even yet, another solution, you could also track the random creation of the new title and implement it as needed.

The sky is the limit, use some imagination, ;)

Nomad :D


Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you both for the help! I guess I should look at the doc more closely, eh? :D

Edited by Somniis

Share this post


Link to post
Share on other sites

Thank you both for the help! :D

Anytime :P

Just a side note, I believe there are a few functions which will only accept a window title and not the handle of the window, which is why I had to get the title of the window instead of just using the handle. I can't remember which functions those were off the top of my head. They may not have been included functions, but UDF's, this was a while back. The help file should inform you of any of these instances if they are included functions.

Nomad :D


Share this post


Link to post
Share on other sites

:D

I have been playing with WinGetHandle() for the past couple of days, and to be frank, I don't think this will help me. Perhaps I don't understand it enough to use it properly.

I have used AutoIT Window Info on the window in question, and from what I can see, the title AND classname changes everytime the window is started up. So to use either of those in WinGetHandle() would not be very helpful.

This is what the Info window gives me:

Posted Image

(sorry for the bad quality)

It seems the class also is random everytime the window is started up. I have been looking through the forums for examples as how to exactly use WinGetHandle(), and I haven't found any. All that do use them use the title, which I cannot get, and have no idea how to use it in this scenario.

Do any of you more experienced coders have any ideas as to how to get this window? If I am just misunderstanding the use of WinGetHandle(), please do let me know. I'm at a loss!

:D

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

If you know the .exe name, try this ($WinHandle = _GetWindowHandle($ExeName) should be $WinHandle = _WinGetHandle(_GetWindowHandle($ExeName)), I didn't seperate it so you could compare):

Global $WinHandle = '', $ExeName = 'notepad.exe'
Local $condtion = True

While 1
    If $condtion = True Then
        $condtion = False
        $WinHandle = _GetWindowHandle($ExeName)
        MsgBox(0,'1', $WinHandle & @CR & WinGetHandle($WinHandle))
    EndIf
    Sleep(10)
WEnd

Func _GetWindowHandle($iPIDExe)
    $iPIDExe = ProcessExists($iPIDExe)
    Local $aWinlist = WinList(), $aProcList = ProcessList($iPIDExe)
    For $iCount = 1 To $aWinlist[0][0]
        If WinGetProcess($aWinlist[$iCount][0]) = $iPIDExe _
            And BitAND(WinGetState($aWinlist[$iCount][1]), 2) _
            And $aWinlist[$iCount][0] <> '' Then
            Return $aWinlist[$iCount][0]
        EndIf
    Next
EndFunc

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

If you know the .exe name, try this ($WinHandle = _GetWindowHandle($ExeName) should be $WinHandle = _WinGetHandle(_GetWindowHandle($ExeName)), I didn't seperate it so you could compare):

Global $WinHandle = '', $ExeName = 'notepad.exe'
Local $condtion = True

While 1
    If $condtion = True Then
        $condtion = False
        $WinHandle = _GetWindowHandle($ExeName)
        MsgBox(0,'1', $WinHandle & @CR & WinGetHandle($WinHandle))
    EndIf
    Sleep(10)
WEnd

Func _GetWindowHandle($iPIDExe)
    $iPIDExe = ProcessExists($iPIDExe)
    Local $aWinlist = WinList(), $aProcList = ProcessList($iPIDExe)
    For $iCount = 1 To $aWinlist[0][0]
        If WinGetProcess($aWinlist[$iCount][0]) = $iPIDExe _
            And BitAND(WinGetState($aWinlist[$iCount][1]), 2) _
            And $aWinlist[$iCount][0] <> '' Then
            Return $aWinlist[$iCount][0]
        EndIf
    Next
EndFunc
I do know the .exe name. :D Thank you for the help Smoke! Will give this a try.

Share this post


Link to post
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
Sign in to follow this  
Followers 0