View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Aug 12, 2015 7:31 pm Post subject: Window Title API call |
|
|
I am not sure if it is windows 10 or what, but when I use @winactive(N) in a loop, my app stops responding and crashes after a few min. I really need to get the title of windows. Is there an API call that I can use to get the title bar text of a window? _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Aug 12, 2015 8:44 pm Post subject: |
|
|
ok I think I can use the WM_GETTEXT with @sendmsg() but it only returns the length of the text, not the text itself. It copies the text to a buffer.... I can figure out how to get it from the buffer... _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 10:50 pm Post subject: |
|
|
Are you checking @winactive(n) for null state? |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Aug 12, 2015 10:52 pm Post subject: |
|
|
Yeah. I don't get an error or anything, the app just hangs. If I remove the check for the title name @winactive(n) it works fine. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 10:55 pm Post subject: |
|
|
Code: |
DIALOG CREATE,New Dialog,-1,0,240,160,,ontop
REM *** Modified by Dialog Designer on 8/12/2015 - 17:54 ***
DIALOG SHOW
:loop
if @event()
stop
end
%x = @winactive(n)
if @null(%x)
%x = not available
end
dialog title,%x
goto loop
|
Compiling and testing the above for the evening. VDS5. I'll let you know if it hangs |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 10:58 pm Post subject: |
|
|
No need to test for an evening. Already have an app hang. I'll let you know what I find.
I'm thinking that if we place a delay, a wait in there maybe the hang won't occur. It likely has to do with window switching though, the moment where the active window handle changes. In that case you can't really fully prevent the problem, you would only be able to mitigate it by delay looping. |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Aug 12, 2015 11:05 pm Post subject: |
|
|
I already have a delay. I have tested 0.1 to 1 second. I can't have it longer than that. 1 second is pushing it. I am going to try doing a winlist and then see if I can match the class name in that list to get the title. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 11:46 pm Post subject: |
|
|
This gets it.
Code: |
DIALOG CREATE,New Dialog,-1,0,240,160,,ontop
REM *** Modified by Dialog Designer on 8/12/2015 - 17:54 ***
DIALOG SHOW
:loop
if @event()
stop
end
%x = @winactive(c)
# info %x
if @null(%x)
%x = TVDSDialog
end
wait .1
if @wintext(#%x)
dialog title,@wintext(#%x)
end
goto loop
|
|
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 11:47 pm Post subject: |
|
|
I think the wait .1 is unneeded. |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 11:48 pm Post subject: |
|
|
Code: | DIALOG CREATE,New Dialog,-1,0,240,160,,ontop
REM *** Modified by Dialog Designer on 8/12/2015 - 17:54 ***
DIALOG SHOW
:loop
if @event()
stop
end
%x = @winactive(c)
# info %x
if @null(%x)
%x = TVDSDialog
end
if @wintext(#%x)
dialog title,@wintext(#%x)
end
goto loop |
This seems to work. Testing more thoroughly. |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 11:50 pm Post subject: |
|
|
*crash* didn't work |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Aug 12, 2015 11:53 pm Post subject: |
|
|
So it didn't work at all or needs the 0.1?
So far, mine is working ok.
I made the following function and it is working to get the title
Code: |
:WinTitle
%%exit =
%t = @new(list)
list winlist,%t,CN
%x = 0
repeat
parse "%a;%b",@item(%t,%x)
if @equal(%a,%1)
if %b
%%exit = @trim(%b)
%x = @pred(@count(%t))
end
end
%x = @succ(%x)
until @equal(%x,@count(%t))
list close,%t
exit %%exit
|
_________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Wed Aug 12, 2015 11:56 pm Post subject: |
|
|
Nope, mine wasn't working at all. I was getting ready to go back to your original API suggestion, with loading and unloading the DLL after each call after sorting out how to make the call at all.
I'll test your function over here as well. |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Thu Aug 13, 2015 12:09 am Post subject: |
|
|
Seems to work! Good job! |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Thu Aug 13, 2015 12:10 am Post subject: |
|
|
Yep! I'm happy with it! It was kicking my ass all day I have had my app running for about 15 min now, no crash.
Thanks _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
|