Code:
'Function PBMain 'Mutex check Dim WinName As Asciiz * %MAX_PATH Dim hMutex As Dword, hForWnd As Dword, hWin As Dword WinName = $AppTitle hMutex = CreateMutex(ByVal %NULL, 0, WinName) If hMutex = %NULL Then Exit Function If GetLastError = %ERROR_ALREADY_EXISTS Then 'already running! hWin = FindWindow (ByVal %Null, WinName) 'find handle of target window hForWnd = GetForegroundWindow 'handle of current foreground window 'Set own window to the top in Z-order with %HWND_TOP SetWindowpos hWin, %HWND_TOP, 0, 0, 0, 0, %SWP_NOMOVE Or %SWP_NOSIZE Or %SWP_SHOWWINDOW 'Disable current foreground window. EnableWindow hForWnd, 0 'Redirect focus to next window in Z-order / move to foreground and activate SetForegroundWindow hWin 'Re-enable previous foreground window EnableWindow hForWnd, 1 Exit Function End If
Leave a comment: