UmeshS Posted June 4, 2009 Posted June 4, 2009 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
UmeshS Posted June 4, 2009 Author Posted June 4, 2009 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
Authenticity Posted June 5, 2009 Posted June 5, 2009 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
UmeshS Posted June 5, 2009 Author Posted June 5, 2009 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 Thanks!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now