Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 70

Thread: clicking a button

  1. #21
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    FindWindowEx, finds it within the parent if I remember right?

    you need to find window the parent..as in the class and name of the actual window.


    also the 2nd picture seems to show, no checkboxes, but maybe the actual window? look at the text. send a SETEXT event and see what changes..probably the window title if anything...

    Then once you know you have the actual window title...use that with findwindowEx on the class checkbox and you will probably get each one in tab order...


    did you check what is found?

    print out the Hwnds. may be null?

  2. #22
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    I'm sorry, but I feel stupid right now elg, I'm almost certain I've done everything you mentions.

    I get the initial window handle of the parent
    Once I have that I use FindWindowEx() to get all the objects under it (which is what you are saying above)

    The second screenshot (windowse.png) shows the parents under the button object. The strange thing is that both parents are the same window\class, but they have a different handle, which is why I'm doing this:

    Code:
    HWND DialogHandle = FindWindowEx(0, 0, "#32770", "AD Pictures by Exclaimer");
    HWND DialogHandle2 = FindWindowEx(DialogHandle, 0, "#32770", "AD Pictures by Exclaimer");
    You can use findwindow or findwindowex to get the parent. If you use findWindowEx like I did for the parent, just don't specify the first value. Anywho I tried both funcs and it's the same thing.
    Anywho, here is another img of spy++
    Click image for larger version. 

Name:	spy++.jpg 
Views:	8 
Size:	91.4 KB 
ID:	588

  3. #23
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    what? no, find the second from the first window. its probably a container like RR said.

    then get each button, click on them in the lsit and find their proper class. Search using that class only.

    You should get each button.

    HWND DialogHandle = FindWindowEx(0, 0, "#32770", "AD Pictures by Exclaimer");
    HWND DialogHandle2 = FindWindowEx(DialogHandle, 0, "#32770", "AD Pictures by Exclaimer");

    might get the container yea...did you check what the handle1 and handle2 are? print the handles and then find which is it using spy++..as theyw ill have the same handle.

    Then find your buttons

    HWND btnOne= FindWindowEx(DialogHandle2, 0, CL_BUTTON, null);

    print(btnOne);

  4. #24
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Well I took a shortcut approach since it isn't worth the hassle or trouble.
    Basically I used this
    Code:
    	//Select "Import Multiple Images" radio button
    	keybd_event(VK_UP, NULL, NULL, NULL);
    	keybd_event(VK_UP, NULL, KEYEVENTF_KEYUP, NULL);
    to select the item and this works perfectly.

    Moving forward. Now I am on the 3rd screen with the browse treeview, this is yet another pain in the ass getting a handle on it. What function can I use to get a handle if I have the offset of the parent handle? I think if I just hard code it, it'll make life easier.

  5. #25
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    the handle cant be hard coded.

    why don't you just make an app which uploads?

  6. #26
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    I think it would be tougher because it has to integrate with Active Directory. If I uploaded the app, could you take a look elg? I seriously don't know why the handle is giving me so much trouble.

    Here is the app:
    http://www.softpedia.com/get/Interne...Pictures.shtml

  7. #27
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    oki but I'm at gf's house with no compiler and on a MAC (ew) at the moment

  8. #28
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    So I have an update.

    I'm able to get the parent handle to the application, BUT for the life of me I can't get any of the child objects (aside from the buttons).
    FindWindowEx doesn't seem to do anything for me. I'm printing out the offsets of each window handle to see if it compares to the output in spy++ or Windowse. Only 1 of the offsets match and that's the parent.
    I can't get the child windows though, so I think I have to use EnumChildWindows() instead.

    My next question is if I do something like the code below, will this work?

    Code:
    HWND myTree;
    
    
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) 
    {
    
    
    	if(hwnd == FindWindow("SysTreeView32", NULL))
    	{	
    		myTree = hwnd	
         		return TRUE;
    	}
    }
    
    
    HWND DialogHandle = FindWindow("#32770", "AD Pictures by Exclaimer");
    EnumChildWindows(DialogHandle , EnumChildProc, 0);
    if(myTree)
    {
    	//Now I should have a handle
    }

  9. #29
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Current code I'm testing with, still no go. Only the parent window handle is valid.

    Code:
    // Automater.cpp : Defines the entry point for the console application.
    //
    
    
    #include "stdafx.h"
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
    {
    	LPTSTR szBuff;
    
    
    	if (GetWindowText(hwnd, szBuff, sizeof(szBuff)))
    	{
    		if (!strcmp("SysTreeView32", szBuff))
    		{
    			//We found the button!
    			TCHAR szBuff2[512];
    			_stprintf_s(szBuff2, _T("%p\n"), szBuff);
    
    
    			MessageBox(NULL, szBuff2, _T("Found Windows"), MB_OK);
    			return true;
    		}
    	}
    	//No button was found
    	return false;
    
    
    }
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	//Hide Console Window
    	FreeConsole();
    
    
    	//Start our Application
    	ShellExecute(NULL, "open", "c:\\Program Files\\AD Pictures\\AD Pictures.exe", NULL, NULL, SW_SHOWNORMAL);
    
    
    	Sleep(3000);
    
    
    	//Get Parent Handle of Application
    	HWND mainApp = FindWindow("#32770", "AD Pictures by Exclaimer");
    
    
    	//EnumChildWindows(mainApp , FindWindow("SysTreeView32", NULL), 0);
    	EnumChildWindows(mainApp, (WNDENUMPROC)&EnumChildProc, 0);
    
    
    	HWND child1 = FindWindowEx(mainApp, NULL, "#32770", "AD Pictures by Exclaimer");
    	HWND child2 = FindWindowEx(child1, NULL, "#32770", "Browse For Folder");
    	HWND child3 = FindWindowEx(child2, NULL, "SHBrowseForFolder ShellNameSpace Control", NULL);
    	HWND child4 = FindWindowEx(child3, NULL, "SysTreeView32", NULL);
    	HWND child5 = GetWindow(child4, NULL);
    
    
    /*
    	HWND child1 = GetWindow(mainApp, GW_CHILD);
    	HWND child2 = GetWindow(child1, GW_CHILD);
    	HWND child3 = GetWindow(child2, GW_CHILD);
    	HWND child4 = GetWindow(child3, GW_CHILD);
    	HWND child5 = GetWindow(child4, GW_CHILD);
    */
    	//Get handle for next button
    	HWND DialogButtonHandle = FindWindowEx(mainApp, 0, "Button", "&Next >");
    
    
    	//First next button
    	SendMessage(DialogButtonHandle, BM_CLICK, 1, 0);
    	Sleep(500);
    
    
    	//Select "Import Multiple Images" radio button
    	keybd_event(VK_UP, NULL, NULL, NULL);
    	keybd_event(VK_UP, NULL, KEYEVENTF_KEYUP, NULL);
    	Sleep(500);
    
    
    	//Second next button
    	SendMessage(DialogButtonHandle, BM_CLICK, 1, 0);
    	Sleep(500);
    
    
    	//Make sure our app is running, if it's not wait 5 seconds
    	TCHAR szBuff[512];
    	_stprintf_s(szBuff, _T("%p\n%p\n%p\n%p\n%p\n%p\n"), mainApp, child1, child2, child3, child4, child5);
    
    
    	MessageBox(NULL, szBuff, _T("Found Windows"), MB_OK);
    
    
    	system("Pause");
    
    
    	return 0;
    }

  10. #30
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Update, I got the handles with this code:

    Code:
    // Automater.cpp : Defines the entry point for the console application.
    //
    
    
    #include "stdafx.h"
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <commctrl.h>
    
    
    HWND sysTree;
     
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) 
    {
        sysTree = FindWindowEx(hwnd, NULL, "SysTreeView32", NULL);
     
        if(!sysTree)
            return TRUE;
    
    
        return FALSE;
    }
    
    
    void keyDown()
    {
    	keybd_event(VK_DOWN, NULL, NULL, NULL);
    	keybd_event(VK_DOWN, NULL, KEYEVENTF_KEYUP, NULL);
    	Sleep(500);
    }
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	LRESULT treeItem = 0;
    	HWND hChild;
    	int list = 0;
    	
    	TCHAR szBuff1[512];
    	TCHAR szBuff2[512];
    	TCHAR szBuff3[512];
    	TCHAR szBuff4[512];
    	TCHAR szBuff5[512];
    	TCHAR Offsets[512];
    	
    	//Hide Console Window
    	FreeConsole();
    
    
    	//Start our Application
    	ShellExecute(NULL, "open", "c:\\Program Files\\AD Pictures\\AD Pictures.exe", NULL, NULL, SW_SHOWNORMAL);
    
    
    	//Wait 3 seconds to make sure the application is launched
    	Sleep(3000);
    
    
    	//Get Parent Handle of Application
    	HWND mainApp = FindWindow("#32770", "AD Pictures by Exclaimer");
    
    
    	if (!mainApp) 
    	{
    		MessageBox(NULL, "Program Window not found", "error", MB_OK);
            return 0;
        }
    
    
    	//Get handle for next button
    	HWND DialogButtonHandle = FindWindowEx(mainApp, 0, "Button", "&Next >");
    
    
    	//First next button
    	SendMessage(DialogButtonHandle, BM_CLICK, 1, 0);
    	Sleep(500);
    
    
    	//Select "Import Multiple Images" radio button
    	keybd_event(VK_UP, NULL, NULL, NULL);
    	keybd_event(VK_UP, NULL, KEYEVENTF_KEYUP, NULL);
    	Sleep(500);
    
    
    	//Second next button
    	SendMessage(DialogButtonHandle, BM_CLICK, 1, 0);
    	Sleep(1000);
    
    
    	hChild = FindWindowEx(mainApp, NULL, "#32770", "AD Pictures by Exclaimer");
        hChild = FindWindowEx(hChild, NULL, "#32770", "Browse For Folder");
    
    
    	EnumChildWindows(hChild, &EnumChildProc, NULL);
    	
    	_stprintf_s(szBuff4, _T("%p\n"), sysTree);
    	MessageBox(NULL, szBuff4, _T("Found Windows"), MB_OK);
    
    
    	treeItem = SendMessage(sysTree, TVM_GETNEXTITEM, TVGN_ROOT, 0);
    	treeItem = SendMessage(sysTree, TVM_GETNEXTITEM, TVGN_NEXT, treeItem);
    	treeItem = SendMessage(sysTree, TVM_GETNEXTITEM, TVGN_CHILD, treeItem);
    	SendMessage(sysTree, TVM_SELECTITEM, TVGN_CARET, treeItem);
    
    
    	system("Pause");
    
    
    	return 0;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •