Code Generator

This will generate all the code you need to find the window you drag the magnifying glass over. Just select the window you want to generate the code for by dragging the magnifying glass over it. Then just click 'Insert' to insert the code at the end of your current project. Check 'I'm using a Find Window function' if you are using a Find Window function to find the window's parent. The following window finds the 'Sign On' button on AOL's Sign On screen.

Example (without Find Window function):

Your code would be:

AOLFrame& = FindWindow("AOL Frame25", vbNullString)
MDIClient& = FindWindowEx(AOLFrame&, 0&, "MDIClient", vbNullString)
AOLChild& = FindWindowEx(MDIClient&, 0&, "AOL Child", "Sign On")
AOLIcon& = FindWindowEx(AOLChild&, 0&, "_AOL_Icon", vbNullString)
For i = 1 To 3
AOLIcon& = FindWindowEx(AOLChild&, AOLIcon&, "_AOL_Icon", vbNullString)
Next i

Example (using a Find Window function):

The FindWindow function finds the AOLChild& window. CodeGenie will prompt you for the name of your Find Window function. In this case, I used the name 'Find_SignOn' for the Find Window function. Your code would be:

AOLIcon& = FindWindowEx(Find_SignOn(), 0&, "_AOL_Icon", vbNullString)
For i = 1 To 3
AOLIcon& = FindWindowEx(Find_SignOn(), AOLIcon&, "_AOL_Icon", vbNullString)
Next i

It's a good idea to use a Find Window function, because the function will find the exact window your looking for, even if its not on top. For example, the following code will find the window with the handle "AOL Child"...

AOLFrame& = FindWindow("AOL Frame25", vbNullString)
MDIClient& = FindWindowEx(AOLFrame&, 0&, "MDIClient", vbNullString)
AOLChild& = FindWindowEx(MDIClient&, 0&, "AOL Child", vbNullString)

AOLChild& could be any of the AOL Child's in AOL's MDI form... So if the window's caption never changes, use the windows caption instead of using vbNullString like this:

AOLFrame& = FindWindow("AOL Frame25", vbNullString)
MDIClient& = FindWindowEx(AOLFrame&, 0&, "MDIClient", vbNullString)
AOLChild& = FindWindowEx(MDIClient&, 0&, "AOL Child", "Write Mail")

AOL's Write Mail window never changes it's caption so we can use "Write Mail" instead of "vbNullString"... But if the window's caption changes, use a Find Window function... It's always safest to just use a Find Window function in any case...

You can make your own Find Window functions using the Find Window Function Generator!

Go Back