Sign in to follow this  
Followers 0
UmeshS

GetFocus, SetFocus not working

4 posts in this topic

Both GetFocus and SetFocus are returning 0x00000000 and subsequent @error is also 0 and hence I don't know what's going on? Why are ___Focus() calls returning 0?

$wndFocus = _WinAPI_GetFocus()

MsgBox(0, "Debug", "WinGetHandle(Picasa 3) returned " & WinGetHandle("Picasa 3") & @CRLF & _

"_WinAPI_GetForegroundWindow() returned " & _WinAPI_GetForegroundWindow() & @CRLF & _

"_WinAPI_SetFocus(WinGetHandle(Picasa 3)) returned " & _WinAPI_SetFocus(WinGetHandle("Picasa 3")) & @CRLF & _

"_WinAPI_SetFocus(_WinAPI_GetForegroundWindow()) returned " & _WinAPI_SetFocus(0) & @CRLF & _

"First _WinAPI_GetFocus() returned " & $wndFocus & " and Second _WinAPI_GetFocus() returned " & _WinAPI_GetFocus() )

Thanks.

Umesh

Share this post


Link to post
Share on other sites



Both GetFocus and SetFocus are returning 0x00000000 and subsequent @error is also 0 and hence I don't know what's going on? Why are ___Focus() calls returning 0?

$wndFocus = _WinAPI_GetFocus()

MsgBox(0, "Debug", "WinGetHandle(Picasa 3) returned " & WinGetHandle("Picasa 3") & @CRLF & _

"_WinAPI_GetForegroundWindow() returned " & _WinAPI_GetForegroundWindow() & @CRLF & _

"_WinAPI_SetFocus(WinGetHandle(Picasa 3)) returned " & _WinAPI_SetFocus(WinGetHandle("Picasa 3")) & @CRLF & _

"_WinAPI_SetFocus(_WinAPI_GetForegroundWindow()) returned " & _WinAPI_SetFocus(0) & @CRLF & _

"First _WinAPI_GetFocus() returned " & $wndFocus & " and Second _WinAPI_GetFocus() returned " & _WinAPI_GetFocus() )

Thanks.

Umesh

------------

Here's another sample test that is failing...

#Include <WinAPI.au3>

Run("C:\Program Files\Google\Picasa3\Picasa3.exe")

WinWaitActive ("Picasa 3")

WinActivate("Picasa 3")

ControlSend("Picasa 3", "", "[CLASS:Edit; INSTANCE:1]", "{SHIFTDOWN}{HOME}{SHIFTUP}{SHIFTDOWN}H{SHIFTUP}appy!")

MsgBox(0, "Debug - WinAPI_GetFocus()", _WinAPI_GetFocus())

MsgBox(0, "Debug - WinAPI_SetFocus()", _WinAPI_SetFocus(WinGetHandle("Picasa 3")))

MsgBox(0, "Debug - WinAPI_GetFocus()", _WinAPI_GetFocus())

WinClose("Picasa 3")

Exit

Share this post


Link to post
Share on other sites
Link. Read the remarks. In short, this function works on the thread level, means if the keyboard focus belongs to another thread, other than yours, it'll return 0. Use GetForegroundwindow. ... and read the remarks :D

Share this post


Link to post
Share on other sites

Link. Read the remarks. In short, this function works on the thread level, means if the keyboard focus belongs to another thread, other than yours, it'll return 0. Use GetForegroundwindow. ... and read the remarks :D

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0