Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetWindowTextW - can you get it to work?
#1
I'm trying to get the name of the current window that has focus. I've already successfully figured out how to get the window handle of any window in focus but I'm having trouble getting the window's title. According to Microsoft's docs here:

https://learn.microsoft.com/en-us/window...indowtextw

GetWindowTextW should be able to do this. ( There is also a GetWindowTextA function for ASCII return but that's not working for me either. )

It's pretty straight forward:

DECLARE DYNAMIC LIBRARY "user32"
    FUNCTION GetWindowTextW (BYVAL hWnd AS _INTEGER64, lpString AS STRING, BYVAL nMaxCount AS INTEGER)
END DECLARE

DIM Dummy AS INTEGER
DIM n AS STRING

_TITLE "This is a test"
Dummy = GetWindowTextW(_WINDOWHANDLE, n, 255)
PRINT n

Does anyone have any insights on why this is not working? The string seems to be null and Dummy returns the value of 0.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
GetWindowTextW - can you get it to work? - by TerryRitchie - 06-07-2024, 07:01 PM



Users browsing this thread: 7 Guest(s)