AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ControlGet fails to work with ahk_id %control_ID%

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Freighter



Joined: 07 Sep 2006
Posts: 64

PostPosted: Sat Apr 07, 2007 2:00 am    Post subject: ControlGet fails to work with ahk_id %control_ID% Reply with quote

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
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Apr 07, 2007 9:33 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
win98guest
Guest





PostPosted: Sat Apr 07, 2007 10:30 am    Post subject: Reply with quote

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. Laughing
Back to top
Freighter



Joined: 07 Sep 2006
Posts: 64

PostPosted: Sun Apr 08, 2007 10:46 am    Post subject: Reply with quote

Rolling Eyes thats a first

A similar problem was fixed in the post http://www.autohotkey.com/forum/viewtopic.php?t=12619
thats why I tried the ControlGetPos to see if it wasnt fixed yet, but it worked flawlessly.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sun Apr 08, 2007 6:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
b.IT
Guest





PostPosted: Fri Jun 06, 2008 12:20 am    Post subject: Reply with quote

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

PostPosted: Sun Aug 31, 2008 12:55 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group