Hi,
When I use RunProgram on OSX, the program that is launched always has background focus.
On Windows Launched applications seem to always get foreground / active focus.
So on OSX, Is there a way to give an application foreground / active focus when I use RunProgram. or is there a way to give an application focus from purebasic once the application is started with RunProgram.
thanks in advance
Martin
RunProgram - How to give focus to a launched app?
Re: RunProgram - How to give focus to a launched app?
I need little time... I'm not Cocoa Profi
Code: Select all
#NSApplicationActivateAllWindows = 1 << 0
#NSApplicationActivateIgnoringOtherApps = 1 << 1
Procedure ShowNamedWindow(Name.s, IsThread = #False) ; ; Result = Count of Windows
Protected RunningApps.i, RunningAppsCount.i, RunningApp.i, AppName.s, i, cnt, Pool
If IsThread
Pool = CocoaMessage(0, 0, "NSAutoreleasePool new")
EndIf
RunningApps = CocoaMessage(0, CocoaMessage(0, 0, "NSWorkspace sharedWorkspace"), "runningApplications")
RunningAppsCount = CocoaMessage(0, RunningApps, "count")
i = 0
While i < RunningAppsCount
RunningApp = CocoaMessage(0, RunningApps, "objectAtIndex:", i)
AppName.s = PeekS(CocoaMessage(0, CocoaMessage(0, RunningApp, "localizedName"), "UTF8String"), -1, #PB_UTF8)
If Name = AppName
CocoaMessage(0, RunningApp, "activateWithOptions:", #NSApplicationActivateIgnoringOtherApps)
cnt + 1
EndIf
i + 1
Wend
If IsThread
CocoaMessage(0, Pool, "release")
EndIf
ProcedureReturn cnt
EndProcedure
ShowNamedWindow("Safari")
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive