AI bliver først for alvor en del af arbejdet, når teknologien integreres i den måde, vi arbejder på. At have adgang til AI betyder ikke nødvendigvis, at medarbejderne er klar til at bruge den.
Du kunne jo lade programmet, ved start, skrive en oplysning i en fil, som så bliver slettet når programmet afsluttes. Det andet program checker så indholdet i denne fil og kan derved se om det andet program er aktiv. Ulempen er at hvis Win går ned imens er filen der stadig. -SCB
Private Declare Function apiFindWindow Lib \"user32\" Alias _ \"FindWindowA\" (ByVal strClass As String, _ ByVal lpWindow As String) As Long
Private Declare Function apiSendMessage Lib \"user32\" Alias _ \"SendMessageA\" (ByVal hWnd As Long, ByVal Msg As Long, ByVal _ wParam As Long, lParam As Long) As Long
Private Declare Function apiSetForegroundWindow Lib \"user32\" Alias _ \"SetForegroundWindow\" (ByVal hWnd As Long) As Long
Private Declare Function apiShowWindow Lib \"user32\" Alias _ \"ShowWindow\" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function apiIsIconic Lib \"user32\" Alias _ \"IsIconic\" (ByVal hWnd As Long) As Long
Function IsAppRunning(ByVal strAppName As String, _ Optional fActivate As Boolean) As Boolean Dim lngH As Long, strClassName As String Dim lngX As Long, lngTmp As Long Const WM_USER = 1024 On Local Error GoTo IsAppRunning_Err IsAppRunning = False Select Case LCase$(strAppName) Case \"excel\": strClassName = \"XLMain\" Case \"word\": strClassName = \"OpusApp\" Case \"access\": strClassName = \"OMain\" Case \"powerpoint95\": strClassName = \"PP7FrameClass\" Case \"powerpoint97\": strClassName = \"PP97FrameClass\" Case \"notepad\": strClassName = \"NOTEPAD\" Case \"paintbrush\": strClassName = \"pbParent\" Case \"wordpad\": strClassName = \"WordPadClass\" Case Else: strClassName = \"\" End Select
If strClassName = \"\" Then lngH = apiFindWindow(vbNullString, strAppName) Else lngH = apiFindWindow(strClassName, vbNullString) End If If lngH <> 0 Then apiSendMessage lngH, WM_USER + 18, 0, 0 lngX = apiIsIconic(lngH) If lngX <> 0 Then lngTmp = apiShowWindow(lngH, SW_SHOWNORMAL) End If If fActivate Then lngTmp = apiSetForegroundWindow(lngH) End If IsAppRunning = True End If IsAppRunning_Exit: Exit Function IsAppRunning_Err: IsAppRunning = False Resume IsAppRunning_Exit End Function
\'******************** Code End ************************
Syntaxen er som følger: If IsAppRunning(\"Excel\") = true then ...
/Thomas
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.