home *** CD-ROM | disk | FTP | other *** search
/ Windows Shareware GOLD / NuclearComputingVol3No1.cdr / _bbs3 / f1238.zip / FNDAPP.MCR < prev    next >
Text File  |  1991-04-20  |  3KB  |  65 lines

  1. ================================start of document==========================
  2.  
  3. Use WordBASIC macros to call external programs by snagging Windows
  4. library routines through the Declare statement.
  5.  
  6.  Enter the following macro, call it, say, "ExtPROGMAN":
  7.  
  8. ===========================================================================
  9.  
  10.  Declare Function FindWindow(foo As Long, name$) As Integer Lib "USER"
  11.  Declare Sub SetActiveWindow(hwnd As Integer) Lib "USER"
  12.  Declare Sub SendMessage(hwnd As Integer, msg As Integer, wp As Integer, \
  13.     lp As Long) Lib "user"
  14.  
  15.  Sub MAIN
  16.    hwnd = FindWindow(0, "Program Manager")
  17.    If hwnd <> 0 Then
  18.            SetActiveWindow(hwnd)
  19.              SendMessage(hwnd,  274, - 4048, 0)
  20.    Else
  21.           Shell "PROGMAN"
  22.    End If
  23.  End Sub
  24.  
  25. ===========================================================================
  26.  
  27. Now use File-Save All to save your macro.
  28. Now enter the following macro to run one-time only without saving 
  29. (unless you want to keep it for future reference. Running it again will
  30. result in an error).
  31.  
  32. ---------------------------------------------------------------------------
  33.  
  34.  Sub MAIN
  35.    'Assigns the named macro to Shift+F2
  36.    MacroAssignToKey "ExtPROGMAN", .Keycode=625, .Assign
  37.  End Sub
  38.  
  39. ---------------------------------------------------------------------------
  40.  
  41.  What you will have is a macro that will search all open apps for the 
  42.  app title bar you have in the 'hwnd =' line, and if it doesn't find it,
  43.  it *starts* it! Then to top it off, you can assign it to a Shift+F2 (a
  44.  key assignment you can't get to from the Macro Assign to Key dialog; but
  45.  you can bypass the dialog with a WordBASIC macro).
  46.  
  47.  It's handy to name this series of macros "Ext" plus the prefix name of 
  48. your application (sans .EXE). You could have ExtWINFILE, ExtMSDOS,
  49. ExtEXCEL, ExtPOWERPNT, all sorts of programs could be called directly by
  50. a single keystroke from inside of Winword.
  51.  
  52. The codes for Shift+F2 through Shift+F16 are 625-639 for .Keycode. These
  53. assignments will appear on the menu item if you assign ExtPROGMAN to, say,
  54. the Utilities menu.
  55.  
  56. Note that you can't override either the F1 key or the Shift+F1 combination;
  57. they are reserved for Help and Context-Sensitive Help respectively. They are 
  58. specifically hard wired out of reach of WordBASIC and can't be overridden
  59. because they are so fundamental to the interface of Microsoft Windows
  60. applications.
  61.  
  62. If you have any questions, you can easyplex me at 75140,427.
  63.  
  64. ===============================end of document===============================
  65.