home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Corel / Ventura8 / Ventura / Scripts / FindWindow.csc < prev    next >
Encoding:
Text File  |  1998-02-04  |  2.2 KB  |  45 lines

  1. REM TEACHING SCRIPT - FindWindow() API example [CorelSCRIPT 8]
  2. REM FindWindow.csc  February 5, 1998
  3. REM ⌐ 1998 Corel Corporation. All rights reserved.
  4.  
  5. REM **********************************************************************
  6. REM  GENERAL INFORMATION 
  7. REM  This script demonstrates how to declare and call a function in a 
  8. REM  Dynamic Link Library (DLL). 
  9. REM 
  10. REM  To use an API, you must know the API name, and how it is declared.
  11. REM  You can find this information by using an API text viewer such as that 
  12. REM  provided with Visual Basic (Apilod32.exe)
  13. REM ***********************************************************************
  14.  
  15. REM ***********************************************************************
  16. REM  This example uses the function FindWindow() from the windows library: 
  17. REM  User32.dll. The FindWindow() function returns the handle of a window
  18. REM  specified by lpClassName. If more than one window has the same 
  19. REM  "lpClassName", it returns the topmost window.  If the specified 
  20. REM  application is not running, the function returns zero.
  21. REM ***********************************************************************
  22.  
  23. ' Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  24. ' The above line shows the function as declared from the Visual Basic API text viewer. 
  25. ' This declaration has to be modified slightly in order to work with Corel SCRIPT.
  26. ' The SCRIPT declaration places the 'ALIAS' at the end of the declaration. 
  27.  
  28. ' The second parameter 'lpWindowName' is declared as a LONG in SCRIPT. In order for
  29. ' the function to determine if the app is running (without having to specify an open file name),
  30. ' this parameter must be set to NULL. Since SCRIPT doesn't support NULL, this parameter is 
  31. ' declared as a LONG, and is assigned the value zero.
  32.  
  33. DECLARE FUNCTION FindWindow LIB "user32"(\\
  34.     BYVAL lpClassName AS STRING,          \\
  35.     BYVAL lpWindowName AS LONG         \\
  36.     ) AS LONG ALIAS "FindWindowA"
  37.  
  38. ' Call function to determine whether Ventura is running and display appropriate message
  39. IF FindWindow("Ventura 8.0", 0) = 0 THEN        
  40.     MESSAGE "Corel VENTURA 8 is not running"
  41. ELSE
  42.     MESSAGE "Corel VENTURA 8 is running"
  43. ENDIF
  44.  
  45.