Results 1 to 13 of 13

Thread: SetFocus API

Threaded View

  1. #12

    Re: SetFocus API

    If you use win 10, you must use keyword PtrSafe before Function or Sub to run macro

    Private Declare PtrSafe Function GetForegroundWindow Lib "user32" () As Long

    Private Declare PtrSafe Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long

    HwndExcel = GetForegroundWindow ()
    Sendkeys Alt+Tab or you can use any API Function
    HwndOtherProgram = GetForegroundWindow ()

    SetForegroundWindow(HwndExcel) or SetForegroundWindow(HwndOtherProgram) Very good replacement for auto press Alt + Tab in win10 when Alt + Tab does not offer a fixed window like win 7 and earlier

    ---
    Best Regards!
    Hannah J. Parrish
    Last edited by Shaggy Hiker; Jun 10th, 2020 at 10:30 AM. Reason: Removed email to protect against bots.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width