AutoHotkey Community

It is currently May 24th, 2012, 1:41 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: GetControlFilename
PostPosted: April 23rd, 2008, 9:15 pm 
Offline

Joined: November 6th, 2005, 6:43 pm
Posts: 72
One of the apps I'm trying to control has randomized classnames, making it very difficult to find the control I want to target. Sometimes the control I'm looking for is implemented via a separate ocx (eg. "vsflex7n.ocx"). This function fetches the OCX filename, which sometimes allows you to locate the desired control.

This is the same information that the WinSpy-like WinID displays.

(note: this is different from other examples of GetModuleFileNameExA() here, since you give an hWnd rather than a pid to the funtion)

Code:
#SingleInstance force
#Persistent

SetTimer,repeat,100      ; ten times a second

repeat:
   MouseGetPos,,,,mouseover_class
   MouseGetPos,,,,mouseover_hwnd,2
   filename := GetControlFilename(mouseover_hwnd)
   ToolTip,class: %mouseover_class%`nfilename:%filename%
   return
   


; Get the .ocx/.dll that implements a particular control.
GetControlFilename(hwnd)
{
   hInstance := DllCall("GetWindowLong", "uint", hwnd, "uint", GWW_HINSTANCE:=-6)

   WinGet, pPID, PID, ahk_id %hwnd%

   ; you must have permission to open the process...  this may require admin on WinXP or later
   hProcess := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", pPID )

   VarSetCapacity( filename, name_size:=255 )
   DllCall( "psapi.dll\GetModuleFileNameExA", "uint", hProcess, "uint", hInstance, "str", filename, "uint", name_size )

   DllCall( "CloseHandle", hProcess )

   return filename
}
[/b]


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cerberus, cmulcahy, Google Feedfetcher, hoppfrosch, MSN [Bot], RaptorX and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group