 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Freighter
Joined: 07 Sep 2006 Posts: 64
|
Posted: Sat Apr 07, 2007 2:00 am Post subject: ControlGet fails to work with ahk_id %control_ID% |
|
|
| Code: |
Process, Exist, WolfRat.exe
if !errorlevel
exitapp
else
{
WRPID := errorlevel
errorlevel = 0
}
ControlGet, ChatBox, Hwnd,,SysListView321, ahk_pid%WRPID%, ahk_pid%WRPID%
ControlGet, ChatBoxText, List,,, ahk_id %ChatBox%
msgbox %ChatBoxText%
Return | ChatBoxText has nothing
I also tried
ControlGetPos, X, Y,,,, ahk_id %ChatBox%
and it works just fine |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sat Apr 07, 2007 9:33 am Post subject: |
|
|
I was tempted to react because some parts of the code were fishy: the double ahk_pid without space, the test on a specific program.
But after clean up I tested it on a well known application: the HTML help of AutoHotkey, after the search of a keyword:
| Code: | Process Exist, HH.exe
If (errorlevel = 0)
ExitApp
Else
{
WRPID := errorlevel
errorlevel = 0
}
; Get the ID
ControlGet searchResultID, Hwnd, , SysListView321, ahk_pid %WRPID%
; The problematic command
ControlGet count, List, Count, , ahk_id %searchResultID%
ControlGet results, List, Count, , ahk_id %searchResultID%
; Verify the ID is correct
ControlGetPos x, y, w, h, , ahk_id %searchResultID%
MsgBox PID: %WRPID%`nID: %searchResultID%`n# %count%`n%x% %y% %w% %h%`n%results%
; Compare with classical Get
ControlGet count, List, Count, SysListView321, AutoHotkey Help
ControlGet results, List, , SysListView321, AutoHotkey Help
MsgBox # %count%`n%results%
Return
| Indeed, I have no results with the ID, so either I miss something myself, or something is broken.
It is documented that "The syntax for ListView retrieval is:
ControlGet, OutputVar, List, Options, SysListView321, WinTitle, WinText",
so if it is a limitation, I suggest to explicitly state that the ID way doesn't work.
[EDIT] Corrected typos. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Last edited by PhiLho on Mon Apr 09, 2007 10:10 am; edited 1 time in total |
|
| Back to top |
|
 |
win98guest Guest
|
Posted: Sat Apr 07, 2007 10:30 am Post subject: |
|
|
| PhiLho wrote: | I was tempted to react because some parts of the code was fishy: the double ahk_pid without space, the test on a specific program.
But after clean up I tested it on a well known application: the HTML help of AutoHotkey, after the search of the keyword:
|
Guess what, I finally found something that works on win98 and win98se
that does not work on XP!
PhilLho's example code works flawlessly on win98's.
I had the seach results showing in autohotkey help, and PhilLho's example code captured and displayed all the results in the list.  |
|
| Back to top |
|
 |
Freighter
Joined: 07 Sep 2006 Posts: 64
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Apr 08, 2007 6:39 pm Post subject: |
|
|
This will be fixed in the next update. The problem affects other commands too, namely ControlGet's FindString/Choice/List, and Control's Add/Delete/Choose.
Thanks for making it easy to reproduce this. |
|
| Back to top |
|
 |
b.IT Guest
|
Posted: Fri Jun 06, 2008 12:20 am Post subject: |
|
|
Hi,
I've been trying this code:
| Code: | ; This script retrieves the ahk_id (HWND) of the active window's focused control.
; This script requires Windows 98+ or NT 4.0 SP3+.
GuiThreadInfoSize = 48
VarSetCapacity(GuiThreadInfo, GuiThreadInfoSize)
NumPut(GuiThreadInfoSize, GuiThreadInfo, 0)
if not DllCall("GetGUIThreadInfo", uint, 0, str, GuiThreadInfo)
{
MsgBox GetGUIThreadInfo() indicated a failure.
return
}
FocusedHWND := NumGet(GuiThreadInfo, 12) ; Retrieve the hwndFocus field from the struct.
; MsgBox % "The focused control's ahk_id (HWND) is " . FocusedHWND
; This ID can be used all control commands. For example:
; ControlGetText, OutputVar,, ahk_id %FocusedHWND%
ControlGet string, Selected,,ahk_id %FocusedHWND% |
Seems to be affected under Vista 32Bit. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Sun Aug 31, 2008 12:55 am Post subject: |
|
|
You are missing a comma.
| Quote: | | To operate upon a control's HWND (window handle), leave the Control parameter blank and specify ahk_id %ControlHwnd% for the WinTitle parameter |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|