Jump to content



Photo

GetFocus, SetFocus not working


  • Please log in to reply
3 replies to this topic

#1 UmeshS

UmeshS

    Seeker

  • Active Members
  • 7 posts

Posted 04 June 2009 - 11:03 PM

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





#2 UmeshS

UmeshS

    Seeker

  • Active Members
  • 7 posts

Posted 04 June 2009 - 11:57 PM

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

#3 Authenticity

Authenticity

    Universalist

  • MVPs
  • 2,619 posts

Posted 05 June 2009 - 12:40 AM

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

#4 UmeshS

UmeshS

    Seeker

  • Active Members
  • 7 posts

Posted 05 June 2009 - 07:25 AM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users