home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d009_2 / 1.ddi / FTESTKEY.MS$ / FTESTKEY.bin
Encoding:
Text File  |  1992-02-05  |  30.9 KB  |  1,358 lines

  1. 'FTestKey.inc - definitions for Fast Test Key, Menu and Window routines
  2. '
  3. '  Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
  4. '
  5. 'Purpose:
  6. ' This file defines the Key, Menu and Window functions of the Fast Test
  7. ' functionality
  8. '
  9.  
  10.  
  11. '**********************************************************
  12. '***************** Keystroke Subroutines ******************
  13. '**********************************************************
  14.  
  15. ' support routine for other subroutines, not meant to be called
  16. ' except by fasttest routines
  17. '
  18. FUNCTION SKeyString$(s$) STATIC
  19.     DIM sTemp$
  20.  
  21.     IF LEN(s$) = 0 THEN
  22.         XLogFailure "zero length string passed to SKeyString$"
  23.     END IF
  24.  
  25.     IF LEN(s$) = 1 THEN
  26.         SELECT CASE ASC(s$)
  27.  
  28.             ' alphanumerics, pass along as given
  29.             CASE ASC("a") to ASC("z"), ASC("A") to ASC("Z"), ASC("0") to ASC("9")
  30.                 sTemp$ = s$
  31.  
  32.             ' special characters to Dokeys, surround with braces
  33.             CASE ASC("~"),ASC("+"),ASC("^"),ASC("%")
  34.                 sTemp$ = "{" + s$ + "}"
  35.  
  36.             CASE ASC("{"),ASC("}"),ASC("("),ASC(")"),ASC("["),ASC("]")
  37.                 sTemp$ = "{" + s$ + "}"
  38.  
  39.             ' normal printable non-alphanumerics, pass along
  40.             CASE ASC("!"),ASC("@"),ASC("#"),ASC("$"),ASC("&")
  41.                 sTemp$ = s$
  42.  
  43.             CASE ASC("*"),ASC("_"),ASC("|"),ASC(""""),ASC("<"),ASC(">")
  44.                 sTemp$ = s$
  45.  
  46.             CASE ASC("-"),ASC("="),ASC("\"),ASC(";"),ASC("'"),ASC(":")
  47.                 sTemp$ =s$
  48.  
  49.             CASE ASC(","),ASC("."),ASC("/"),ASC(" "),ASC("?"),ASC("`")
  50.                 sTemp$ =s$
  51.  
  52.             ' non-printable other character
  53.             CASE ELSE
  54.                 XLogFailure "Bad character passed to SKeyString$"
  55.  
  56.         END SELECT
  57.  
  58.     ELSE
  59.         ' the string is greater than 1 character in length, put braces
  60.         ' around it and send it to Dokeys and let it parse it
  61.         sTemp$ = "{" + s$ + "}"
  62.     END IF
  63.     SKeyString$ = "(" + sTemp$ + ")"
  64. END FUNCTION
  65.  
  66. ' support routine for other subroutines, not meant to be called
  67. ' except by fasttest routines
  68. '
  69. FUNCTION SHideKeys$(s$) STATIC
  70.     DIM check$
  71.     DIM i%
  72.     DIM stRet$
  73.     ' this code must hide each character that is special to DoKeys
  74.  
  75.     stRet$ = ""     ' start empty
  76.     FOR i% = 1 to LEN(s$)
  77.         ' special characters to DoKeys, surround with braces
  78.         check$ = mid$(s$,i%,1)
  79.         IF check$ = "~" OR check$ = "+" OR check$ = "^" OR check$ = "%" THEN
  80.             stRet$ = stRet$ + "{" + check$ + "}"
  81.         ELSEIF check$ = "{" OR check$ = "}" OR check$ = "(" OR check$ = ")" OR check$ = "[" OR check$ = "]" THEN
  82.             stRet$ = stRet$ + "{" + check$ + "}"
  83.         ELSE
  84.             stRet$ = stRet$ + check$
  85.         END IF
  86.     NEXT i%
  87.     SHideKeys$ = stRet$
  88. END FUNCTION
  89.  
  90. '
  91. '   XKey(s$)
  92. '
  93. ' Description:
  94. '       Send Keystroke to active application
  95. '       This uses DoKeys, so DoKeys syntax is allowed
  96. '
  97. ' Parameters:
  98. '       s$ - single char to send
  99. '       NOTE: any string longer that 1 character in length is assumed
  100. '             to be a special name for a key and is handled as such
  101. '
  102. ' Returns:
  103. '       nothing
  104. '
  105. ' Example:
  106. '       XKey "f"
  107. '       XKey "escape"
  108.  
  109. SUB XKey (s$) STATIC
  110.     DoKeys SKeyString$(s$)
  111.  
  112. END SUB
  113.  
  114.  
  115. '
  116. ' XAlt(s$)
  117. '
  118. ' Description:
  119. '       Send a key as if the alt key is pressed at the same time
  120. '
  121. ' Parameters:
  122. '       s$ - single char to send
  123. '       see XKey note
  124. '
  125. ' Returns:
  126. '       nothing
  127. '
  128. ' Example:
  129. '       XAlt "f"
  130. '       XAlt "escape"
  131. '
  132. '
  133.  
  134. SUB XAlt (s$) STATIC
  135.     DoKeys "%" + SKeyString$(s$)
  136.  
  137. END SUB
  138.  
  139. '
  140. ' XCtrl(s$)
  141. '
  142. ' Description:
  143. '       Send a key as if the control key is pressed at the same time
  144. '
  145. ' Parameters:
  146. '       s$ - single char to send
  147. '       see XKey note
  148. '
  149. ' Returns:
  150. '       nothing
  151. '
  152. ' Example:
  153. '       XCtrl "f"
  154. '       XCtrl "escape"
  155. '
  156. '
  157.  
  158. SUB XCtrl (s$) STATIC
  159.     DoKeys "^" + SKeyString$(s$)
  160. END SUB
  161.  
  162. '
  163. ' XShift(s$)
  164. '
  165. ' Description:
  166. '       Send a key as if the alt key is pressed at the same time
  167. '
  168. ' Parameters:
  169. '       s$ - single char to send
  170. '       see XKey note
  171. '
  172. ' Returns:
  173. '       nothing
  174. '
  175. ' Example:
  176. '       XShift "f"
  177. '       XShift "escape"
  178. '
  179. '
  180.  
  181. SUB XShift (s$) STATIC
  182.     DoKeys "+" + SKeyString$(s$)
  183.  
  184. END SUB
  185.  
  186. '
  187. ' XCtrlAlt(s$)
  188. '
  189. ' Description:
  190. '       Send a key as if the alt key is pressed at the same time
  191. '
  192. ' Parameters:
  193. '       s$ - single char to send
  194. '       see XKey note
  195. '
  196. ' Returns:
  197. '       nothing
  198. '
  199. ' Example:
  200. '       XCtrlAlt "f"
  201. '       XCtrlAlt "escape"
  202. '
  203. '
  204.  
  205.  
  206. SUB XCtrlAlt (s$) STATIC
  207.     DoKeys "^%" + SKeyString$(s$)
  208. END SUB
  209.  
  210. '
  211. ' XAltShift(s$)
  212. '
  213. ' Description:
  214. '       Send a key as if the alt key is pressed at the same time
  215. '
  216. ' Parameters:
  217. '       s$ - single char to send
  218. '       see XKey note
  219. '
  220. ' Returns:
  221. '       nothing
  222. '
  223. ' Example:
  224. '       XAltShift "f"
  225. '       XAltShift "escape"
  226. '
  227. '
  228.  
  229. SUB XAltShift (s$) STATIC
  230.     DoKeys "%+" + SKeyString$(s$)
  231. END SUB
  232.  
  233. '
  234. ' XCtrlShift(s$)
  235. '
  236. ' Description:
  237. '       Send a key as if the alt key is pressed at the same time
  238. '
  239. ' Parameters:
  240. '       s$ - single char to send
  241. '       see XKey note
  242. '
  243. ' Returns:
  244. '       nothing
  245. '
  246. ' Example:
  247. '       XCtrlShift "f"
  248. '       XCtrlShift "escape"
  249. '
  250. '
  251.  
  252. SUB XCtrlShift (s$) STATIC
  253.     DoKeys "^+" + SKeyString$(s$)
  254. END SUB
  255.  
  256. '
  257. ' XCtrlAltShift(s$)
  258. '
  259. ' Description:
  260. '       Send a key as if the alt key is pressed at the same time
  261. '
  262. ' Parameters:
  263. '       s$ - single char to send
  264. '       see XKey note
  265. '
  266. ' Returns:
  267. '       nothing
  268. '
  269. ' Example:
  270. '       XCtrlAltShift "f"
  271. '       XCtrlAltShift "escape"
  272. '
  273. '
  274.  
  275. SUB XCtrlAltShift (s$) STATIC
  276.     DoKeys "^%+" + SKeyString$(s$)
  277.  
  278. END SUB
  279.  
  280. '
  281. ' XText(s$)
  282. '
  283. ' Description:
  284. '       Send any key as without having to specially specify any
  285. '       keys that are special to DoKeys
  286. '
  287. ' Parameters:
  288. '       s$ - string of characters to send
  289. '
  290. ' Returns:
  291. '       nothing
  292. '
  293. ' Example:
  294. '       XText "Hello World"
  295. '       XText "The DoKeys string to send is {escape}"
  296. '
  297. '
  298.  
  299. SUB XText(s$) STATIC
  300.     DoKeys SHideKeys$(s$)
  301. END SUB
  302.  
  303. '
  304. ' XEnter(s$)
  305. '
  306. ' Description:
  307. '       Send any key as without having to specially specify any
  308. '       keys that are special to DoKeys followed by an enter key
  309. '
  310. ' Parameters:
  311. '       s$ - string of characters to send
  312. '
  313. ' Returns:
  314. '       nothing
  315. '
  316. ' Example:
  317. '       XEnter "Hello World"
  318. '       XEnter "The DoKeys string to send is {escape}"
  319. '
  320. '
  321.  
  322. SUB XEnter(s$) STATIC
  323.     DoKeys SHideKeys$(s$) + "{enter}"
  324. END SUB
  325.  
  326.  
  327.  
  328.  
  329.  
  330. '**********************************************************
  331. '***************** Menu Subroutines ***********************
  332. '**********************************************************
  333.  
  334.  
  335.  
  336.  
  337. '
  338. ' XSelectMenuItem(stMenu, stMenuItem, stHMenuItem)
  339. '
  340. ' Description:
  341. '       This procedure selects the specified menu item name.
  342. '
  343. ' Parameters:
  344. '       stMenu      = menu where stMenuItem is found.
  345. '       stMenuItem  = menu item to select or secondary menu, IF
  346. '                     Hierarchial menu exists.
  347. '       stHMenuItem = hierarchial(popup) menu item.
  348. '
  349. ' Returns:
  350. '       nothing
  351. '
  352. ' Example:
  353. '       XSelectMenuItem "Edit", "Copy",""
  354. '
  355. '
  356. SUB XSelectMenuItem(stMenu$,stMenuItem$,stHMenuItem$) STATIC
  357.     XMenuItemExists stMenu$,stMenuItem$,stHMenuItem$
  358.  
  359.     WMenu(stMenu$)
  360.     IF stMenuItem$ <> "" THEN
  361.         WMenu(stMenuItem$)
  362.     END IF
  363.     IF stHMenuItem$ <> "" THEN              'If popup menu is to be selected
  364.         WMenu(stHMenuItem$)                  'Select menu item under popup menu.
  365.     END IF
  366.  
  367. END SUB
  368.  
  369.  
  370.  
  371. '
  372. ' BMenuItemExists(stMenu, stMenuItem, stHMenuItem)
  373. '
  374. ' Description:
  375. '       This procedure checks for the specified menu item
  376. '       and returns true IF found, false IF not found.
  377. '
  378. ' Parameters:
  379. '       stMenu      = menu where stMenuItem is found.
  380. '       stMenuItem  = menu item to check or secondary menu, IF
  381. '                     Hierarchial menu exists.
  382. '       stHMenuItem = hierarchial(popup) menu item.
  383. '
  384. ' Returns:
  385. '       TRUE if it exists, FALSE if not
  386. '
  387. ' Example:
  388. '       fSuccess% = BMenuItemExists("File", "", "")
  389. '       fSuccess% = BMenuItemExists("FIle","Edit", "")
  390. '
  391. '
  392. FUNCTION BMenuItemExists%(stMenu$,stMenuItem$,stHMenuItem$) STATIC
  393.  
  394.     IF stHMenuItem$ = "" THEN
  395.         IF stMenuItem$ = "" THEN
  396.             BMenuItemExists = WMenuExists(stMenu$) <> 0
  397.         ELSE
  398.             WMenu(stMenu$)
  399.             BMenuItemExists = WMenuExists(stMenuItem$) <> 0
  400.         END IF
  401.     ELSE
  402.         WMenu(stMenu$)
  403.         WMenu(stMenuItem$)
  404.         BMenuItemExists = WMenuExists(stHMenuItem$) <> 0
  405.     END IF
  406.     DoKeys "{esc 3}"                     'Make sure you close menu.
  407.  
  408. END FUNCTION
  409.  
  410.  
  411. '
  412. ' XMenuItemExists (stMenu$,stMenuItem$, stHMenuItem$)
  413. '
  414. ' Description:
  415. '       Reports error IF menu item does not exist.
  416. '
  417. ' Parameters:
  418. '       stMenu      = menu where stMenuItem is found.
  419. '       stMenuItem  = menu item to select or secondary menu, IF
  420. '                     Hierarchial menu exists.
  421. '       stHMenuItem = hierarchial(popup) menu item.
  422. '
  423. ' Returns:
  424. '       nothing
  425. '
  426. ' Example:
  427. '       XMenuItemExists "File", "Close", ""
  428. '
  429. '
  430. '
  431. SUB XMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  432.     IF BMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN
  433.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " does not Exist"
  434.     END IF
  435. END SUB
  436.  
  437.  
  438. '
  439. ' XMenuItemNotExists (stMenu$,stMenuItem$, stHMenuItem$)
  440. '
  441. ' Description:
  442. '       Reports error IF menu item exist.
  443. '
  444. ' Parameters:
  445. '       stMenu      = menu where stMenuItem is found.
  446. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  447. '                        exists.
  448. '       stHMenuItem = hierarchial(popup) menu item.
  449. '
  450. ' Returns:
  451. '       nothing
  452. '
  453. ' Example:
  454. '       XMenuItemNotExists "File", "Close", ""
  455. '
  456. '
  457. '
  458.  
  459. SUB XMenuItemNotExists(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  460.     IF BMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$) THEN
  461.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " Exists"
  462.     END IF
  463. END SUB
  464.  
  465.  
  466.  
  467. '
  468. ' IGetMenuCount(stMenu, stMenuItem)
  469. '
  470. ' Description:
  471. '       This procedure returns the number of menu items
  472. '       in the specified menu.
  473. '
  474. ' Parameters:
  475. '       stMenu       = top level menu to count menu items in.
  476. '                      IF stMenu = "", THEN counts items in the menu bar(counts the
  477. '                      number of top level menus).
  478. '       stMenuItem   = secondary menu to count menu items in; counts hierarchial
  479. '                      menu items.
  480. '
  481. ' Returns:
  482. '       An integer; the number of menu items found.
  483. '
  484. ' Example:
  485. '       iHowMany% = IGetMenuCount("","") returns how many top level menus.
  486. '       iHowMany% = IGetMenuCount("Utilities", "") returns the number of menu items
  487. '                                                     in the "Utilities" menu.
  488. '       iHowMany% = IGetMenuCount("Utilities", "Info") returns how many menu items
  489. '                                                                 in the popup menu "Info".
  490. '
  491. '
  492. FUNCTION IGetMenuCount%(stMenu$, stMenuItem$) STATIC
  493.  
  494.     IF stMenuItem$ <> "" THEN                   'Count in menu items in hierarchial menu.
  495.         WMenu(stMenu$)
  496.         WMenu(stMenuItem$)
  497.         IGetMenuCount = WMenuCount()          'Count the number of menus items in the popup
  498.                                                 'menu.
  499.     ELSE
  500.         IF stMenu$ <> "" THEN                   'Count menus in stMenu$.
  501.             WMenu(stMenu$)
  502.             IGetMenuCount = WMenuCount()      'Count the number of menus items in the menu.
  503.         ELSE
  504.             IGetMenuCount = WMenuCount()      'Count the number of menus in the menu bar if.
  505.                                                 'the above "IF" statements are skipped.
  506.         END IF
  507.     END IF
  508.     DoKeys "{esc 3}"                             'Make sure you close menu.
  509.  
  510. END FUNCTION
  511.  
  512.  
  513.  
  514. '
  515. ' SGetMenuItemText(stMenu, stMenuItem, iIndex)
  516. '
  517. ' Description:
  518. '       This procedure returns the text of menu item, iIndex
  519. '       (base 1) in stMenu.  Length of the buffer to store
  520. '       the menu item text is passed in.
  521. '
  522. ' Parameters:
  523. '       stMenu      = menu where stMenuItem is found.
  524. '       stMenuItem  = menu item to check or secondary menu, IF Hierarchial menu
  525. '                     exists.
  526. '       iIndex      = index of menu item in stMenu.
  527. '       iLength     = length of buffer to store text
  528. '
  529. ' Returns:
  530. '       a string, the menu item text(name).
  531. '
  532. ' Example:
  533. '       Print SGetMenuItemText("","","", 3)  gets name of 3rd menu.
  534. '       Print SGetMenuItemText("Utilities","","",3) gets name of 3rd menu item
  535. '                                                          in the "Utilities" menu.
  536. '       Print SGetMenuItemText("Utilities","Info",3) gets name of 3rd menu item
  537. '                                                           in the popup menu "Info".
  538. '
  539. '
  540. FUNCTION SGetMenuItemText$(stMenu$,stMenuItem$, iIndex%) STATIC
  541.     DIM buffer$
  542.  
  543.     buffer$ = String$(128,32)        'initialize with spaces.
  544.     IF stMenuItem$ <> "" THEN        'get menu text from hierarchial menu.
  545.         WMenu(stMenu$)
  546.         WMenu(stMenuItem$)
  547.     ELSE
  548.         IF stMenu$ <> "" THEN        'get menu text from stMenu$.
  549.             WMenu(stMenu$)
  550.         END IF
  551.     END IF
  552.     WMenuText iIndex%, buffer$       'get menu text. If above "IF" condition
  553.                                      'is skipped, this gets text in menu bar.
  554.     SGetMenuItemText = buffer$       'return buffer$
  555.  
  556.     DoKeys "{esc 3}"                 'Make sure you close menu.
  557.  
  558. END FUNCTION
  559.  
  560.  
  561.  
  562. '
  563. ' BMenuItemGrayed(stMenu$, stMenuItem$,stHMenuItem$)
  564. '
  565. ' Description:
  566. '       This procedure checks to see IF the specified menu or
  567. '       menu item is grayed out or not.
  568. '
  569. ' Parameters:
  570. '       stMenu      = menu where stMenuItem is found.
  571. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  572. '                     exists.
  573. '       stHMenuItem = hierarchial(popup) menu item.
  574. '
  575. ' Returns:
  576. '       TRUE if grayed.
  577. '       FALSE if not grayed.
  578. '
  579. ' Example:
  580. '       fIsGrayed% = BMenuItemGrayed("Edit", "Copy", "")
  581. '       fIsGrayed% = BMenuItemGrayed("Edit", "", "")
  582. '
  583. '
  584. FUNCTION BMenuItemGrayed%(stMenu$, stMenuItem$, stHMenuItem$) STATIC
  585.  
  586.     IF stHMenuItem$ = "" THEN
  587.         IF stMenuItem$ = "" THEN
  588.             BMenuItemGrayed = WMenuGrayed(stMenu$) <> 0  'Check main menu bar menu items.
  589.         ELSE
  590.             WMenu(stMenu$)                         'Check menu item within stMenuItem$.
  591.             BMenuItemGrayed = WMenuGrayed(stMenuItem$) <> 0
  592.         END IF
  593.     ELSE
  594.         WMenu(stMenu$)                             'Check popup menu items.
  595.         WMenu(stMenuItem$)
  596.         BMenuItemGrayed = WMenuGrayed(stHMenuItem$) <> 0
  597.     END IF
  598.     DoKeys "{esc 3}"                                         'Make sure you close menu.
  599.  
  600. END FUNCTION
  601.  
  602.  
  603. '
  604. ' XMenuItemGrayed (stMenu$,stMenuItem$, stHMenuItem$)
  605. '
  606. ' Description:
  607. '       Reports error IF menu item is not Grayed.
  608. '
  609. ' Parameters:
  610. '       stMenu      = menu where stMenuItem is found.
  611. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  612. '                     exists.
  613. '       stHMenuItem = hierarchial(popup) menu item.
  614. '
  615. ' Returns:
  616. '       nothing
  617. '
  618. ' Example:
  619. '       XMenuItemGrayed "File", "Close", ""
  620. '
  621. '
  622. '
  623.  
  624. SUB XMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  625.   IF BMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN
  626.      XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Grayed"
  627.   END IF
  628. END SUB
  629.  
  630. '
  631. ' XMenuItemNotGrayed (stMenu$,stMenuItem$, stHMenuItem$)
  632. '
  633. ' Description:
  634. '       Reports error IF menu item is Grayed.
  635. '
  636. ' Parameters:
  637. '       stMenu      = menu where stMenuItem is found.
  638. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  639. '                     exists.
  640. '       stHMenuItem = hierarchial(popup) menu item.
  641. '
  642. ' Returns:
  643. '       nothing
  644. '
  645. ' Example:
  646. '       XMenuItemNotGrayed "File", "Close", ""
  647. '
  648. '
  649. '
  650.  
  651. SUB XMenuItemNotGrayed(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  652.     IF BMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) THEN
  653.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Grayed"
  654.     END IF
  655. END SUB
  656.  
  657.  
  658.  
  659. '
  660. ' BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$)
  661. '
  662. ' Description:
  663. '       This procedure checks to see IF the specified menu
  664. '       item is checked or not.
  665. '
  666. ' Parameters:
  667. '       stMenu      = menu where stMenuItem is found.
  668. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  669. '                     exists.
  670. '       stHMenuItem = hierarchial(popup) menu item.
  671. '
  672. ' Returns:
  673. '       TRUE if checked.
  674. '       FALSE if not checked.
  675. '
  676. ' Example:
  677. '       fIsChecked% = BMenuItemChecked("Format","Style","Bold")
  678. '       fIsChecked% = BMenuItemchecked("Edit", "Copy", "")
  679. '
  680. '
  681. FUNCTION BMenuItemChecked%(stMenu$, stMenuItem$, stHMenuItem$) STATIC
  682.  
  683.     IF stHMenuItem$ = "" THEN
  684.         WMenu(stMenu$)                             'Check menu item within stMenu$.
  685.         BMenuItemChecked = WMenuChecked(stMenuItem$) <> 0
  686.     ELSE
  687.         WMenu(stMenu$)                             'Check menu item under popup menu.
  688.         WMenu(stMenuItem$)
  689.         BMenuItemChecked = WMenuChecked(stHMenuItem$) <> 0
  690.     END IF
  691.     DoKeys "{esc 3}"                                           'Make sure you close menu.
  692.  
  693. END FUNCTION
  694.  
  695.  
  696.  
  697. '
  698. ' XMenuItemChecked (stMenu$,stMenuItem$, stHMenuItem$)
  699. '
  700. ' Description:
  701. '       Reports error IF menu item is not Checked.
  702. '
  703. ' Parameters:
  704. '       stMenu      = menu where stMenuItem is found.
  705. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  706. '                     exists.
  707. '       stHMenuItem = hierarchial(popup) menu item.
  708. '
  709. ' Returns:
  710. '       nothing
  711. '
  712. ' Example:
  713. '       XMenuItemChecked "Options", "Read Only", ""
  714. '
  715. '
  716. '
  717. SUB XMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  718.     IF BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN
  719.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Checked"
  720.     END IF
  721. END SUB
  722.  
  723. '
  724. ' XMenuItemNotChecked (stMenu$,stMenuItem$, stHMenuItem$)
  725. '
  726. ' Description:
  727. '       Reports error IF menu item is Checked.
  728. '
  729. ' Parameters:
  730. '       stMenu      = menu where stMenuItem is found.
  731. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  732. '                     exists.
  733. '       stHMenuItem = hierarchial(popup) menu item.
  734. '
  735. ' Returns:
  736. '       nothing
  737. '
  738. ' Example:
  739. '       XMenuItemNotChecked "Options", "Read Only", ""
  740. '
  741. '
  742. '
  743. SUB XMenuItemNotChecked(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  744.     IF BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) THEN
  745.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Checked"
  746.     END IF
  747. END SUB
  748.  
  749.  
  750.  
  751. '
  752. ' BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$)
  753. '
  754. ' Description:
  755. '       This procedure checks to see IF the specified menu or
  756. '       menu item is enabled or not.
  757. '
  758. ' Parameters:
  759. '       stMenu      = menu where stMenuItem is found.
  760. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  761. '                     exists.
  762. '       stHMenuItem = hierarchial(popup) menu item.
  763. '
  764. ' Returns:
  765. '       TRUE if enabled.
  766. '       FALSE if not enabled.
  767. '
  768. ' Example:
  769. '       fIsEnabled% = BMenuItemEnabled("File", "", "")
  770. '       fIsEnabled% = BMenuItemEnabled("File", "Close", "")
  771. '
  772. '
  773. FUNCTION BMenuItemEnabled%(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  774.  
  775.     IF stHMenuItem$ = "" THEN
  776.         IF stMenuItem$ = "" THEN
  777.             BMenuItemEnabled = WMenuEnabled(stMenu$) <> 0 'Check main menu bar menu items.
  778.         ELSE
  779.             WMenu(stMenu$)                         'Check menu item within stMenu$.
  780.             BMenuItemEnabled = WMenuEnabled(stMenuItem$) <> 0
  781.         END IF
  782.     ELSE
  783.         WMenu(stMenu$)                             'Check menu item under popup menu.
  784.         WMenu(stMenuItem$)
  785.         BMenuItemEnabled = WMenuEnabled(stHMenuItem$) <> 0
  786.     END IF
  787.     DoKeys "{esc 3}"                                         'Make sure you close menu.
  788.  
  789. END FUNCTION
  790.  
  791.  
  792. '
  793. ' XMenuItemEnabled (stMenu$,stMenuItem$, stHMenuItem$)
  794. '
  795. ' Description:
  796. '       Reports error IF menu item is not Enabled.
  797. '
  798. ' Parameters:
  799. '       stMenu      = menu where stMenuItem is found.
  800. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  801. '                     exists.
  802. '       stHMenuItem = hierarchial(popup) menu item.
  803. '
  804. ' Returns:
  805. '       nothing
  806. '
  807. ' Example:
  808. '       XMenuItemEnabled "Options", "Read Only", ""
  809. '
  810. '
  811. '
  812. SUB XMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  813.     IF BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN
  814.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Enabled"
  815.     END IF
  816. END SUB
  817.  
  818.  
  819. '
  820. ' XMenuItemNotEnabled (stMenu$,stMenuItem$, stHMenuItem$)
  821. '
  822. ' Description:
  823. '       Reports error IF menu item is Enabled.
  824. '
  825. ' Parameters:
  826. '       stMenu      = menu where stMenuItem is found.
  827. '       stMenuItem  = menu item to select or secondary menu, IF Hierarchial menu
  828. '                     exists.
  829. '       stHMenuItem = hierarchial(popup) menu item.
  830. '
  831. ' Returns:
  832. '       nothing
  833. '
  834. ' Example:
  835. '       XMenuItemNotEnabled "Options", "Read Only", ""
  836. '
  837. '
  838. '
  839. SUB XMenuItemNotEnabled(stMenu$,stMenuItem$, stHMenuItem$) STATIC
  840.     IF BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) THEN
  841.         XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Enabled"
  842.     END IF
  843. END SUB
  844.  
  845.  
  846.  
  847. '**********************************************************
  848. '***************** Window Subroutines *********************
  849. '**********************************************************
  850.  
  851.  
  852.  
  853.  
  854. '
  855. ' XCaptionExists(stCaption$)
  856. '
  857. ' Description:
  858. '       Will report error IF caption does not Exist.
  859. '
  860. ' Parameters:
  861. '       stCaption$  - expected caption of current window
  862. '
  863. ' Returns:
  864. '       nothing
  865. '
  866. ' Example:
  867. '       XCaptionExists "Winword"
  868. '
  869. '
  870. '
  871. SUB XCaptionExists(stCaption$) STATIC
  872.     IF Instr(SGetCaption(), stCaption$) = 0 THEN
  873.         XLogFailure stCaption$ + " caption does not exist in active window."
  874.     END IF
  875. END SUB
  876.  
  877.  
  878. '
  879. ' XCaptionNotExists(stCaption$)
  880. '
  881. ' Description:
  882. '       Will report error IF caption Exist.
  883. '
  884. ' Parameters:
  885. '       stCaption$  - NOT expected caption of current window
  886. '
  887. ' Returns:
  888. '       nothing
  889. '
  890. ' Example:
  891. '       XCaptionNotExists "Winword"
  892. '
  893. '
  894. SUB XCaptionNotExists(stCaption$) STATIC
  895.     IF Instr(SGetCaption(), stCaption$) <> 0 THEN
  896.         XLogFailure stCaption$ + " caption Exists in active window."
  897.     END IF
  898. END SUB
  899.  
  900.  
  901.  
  902. '
  903. ' SGetCaption()
  904. '
  905. ' Description:
  906. '       Returns the caption of the Active window
  907. '
  908. ' Parameters:
  909. '       none
  910. '
  911. ' Return:
  912. '       Caption of the Active window
  913. '
  914. ' Example:
  915. '       stCaption$ = SGetCaption()
  916. '
  917. '
  918. FUNCTION SGetCaption$() STATIC
  919.     DIM x%
  920.     DIM stCaption$
  921.  
  922.     stCaption$ = String$(100, 32)
  923.     x% = GetWindowText (GetActiveWindow(), stCaption$, LEN(stCaption$))
  924.     SGetCaption = mid$(stCaption$,1,x%)
  925.     stCaption$ = ""
  926. END FUNCTION
  927.  
  928.  
  929.  
  930. '
  931. ' XZoomWindow
  932. '
  933. ' Description:
  934. '       Toggles the state of the window between normalized
  935. '       and maximized.
  936. '
  937. ' Parameters:
  938. '       None
  939. '
  940. ' Returns:
  941. '       nothing
  942. '
  943. ' Example:
  944. '       XZoomWindow
  945. '
  946. '
  947. '
  948. SUB XZoomWindow STATIC
  949.     DIM bogus%
  950.     DIM lhwndTemp%
  951.  
  952.     lhwndTemp% = GetActiveWindow()
  953.  
  954.     ' IF the window is maximized, normalize.
  955.  
  956.     IF (IsZoomed(lhwndTemp%)) THEN
  957.         ' window is maximized, we must normalize it
  958.         bogus% = ShowWindow(lhwndTemp%, SW_SHOWNORMAL)
  959.     ELSE
  960.         bogus% = ShowWindow(lhwndTemp%, SW_MAXIMIZE)
  961.     END IF
  962.  
  963. END SUB
  964.  
  965.  
  966. '
  967. ' XMaxWindow
  968. '
  969. ' Description:
  970. '       Maximize the current active window
  971. '
  972. ' Parameters:
  973. '       None
  974. '
  975. ' Returns:
  976. '       nothing
  977. '
  978. ' Example:
  979. '       XMaxWinow
  980. '
  981. '
  982. '
  983.  
  984.  
  985. SUB XMaxWindow STATIC
  986.     DIM bogus%
  987.     DIM lhwndTemp%
  988.     DIM lWndStyle&
  989.  
  990.     lhwndTemp% = GetActiveWindow ()
  991.  
  992.     ' Get the window's style attributes
  993.     lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE)
  994.  
  995.     IF ((lWndStyle& And WS_MAXIMIZE) <> 0) THEN
  996.         XLogFailure "Could not maximize active window, already maximized"
  997.     ELSE
  998.         bogus% = ShowWindow(lhwndTemp%, SW_SHOWMAXIMIZED)
  999.     END IF
  1000.  
  1001. END SUB
  1002.  
  1003. '
  1004. ' XWindowMaximized
  1005. '
  1006. ' Description:
  1007. '       check IF the current active window is Maximized
  1008. '
  1009. ' Parameters:
  1010. '       none
  1011. '
  1012. ' Returns:
  1013. '       nothing
  1014. '
  1015. ' Example:
  1016. '       XWindowMaximized
  1017. '
  1018. '
  1019. '
  1020.  
  1021.  
  1022. SUB XWindowMaximized STATIC
  1023.     IF BWindowMaximized = 0 THEN
  1024.         XLogFailure "Active Window not maximized"
  1025.     END IF
  1026.  
  1027. END SUB
  1028.  
  1029. '
  1030. ' XWindowNotMaximized
  1031. '
  1032. ' Description:
  1033. '       Check that the current window is not maximized
  1034. '
  1035. ' Parameters:
  1036. '       none
  1037. '
  1038. ' Returns:
  1039. '       nothing
  1040. '
  1041. ' Example:
  1042. '       XWindowNotMaximized
  1043. '
  1044. '
  1045. '
  1046.  
  1047.  
  1048. SUB XWindowNotMaximized STATIC
  1049.  
  1050.     IF BWindowMaximized THEN
  1051.         XLogFailure "Active Window is maximized"
  1052.     END IF
  1053.  
  1054. END SUB
  1055.  
  1056. '
  1057. ' BWindowMaximized
  1058. '
  1059. ' Description:
  1060. '       detect IF current window is maximized
  1061. '
  1062. ' Parameters:
  1063. '       none
  1064. '
  1065. ' Returns:
  1066. '       TRUE if maximized, FALSE if not
  1067. '
  1068. ' Example:
  1069. '       BWindowMaximized
  1070. '
  1071. '
  1072. '
  1073.  
  1074.  
  1075. FUNCTION BWindowMaximized% STATIC
  1076.     DIM bogus%
  1077.     DIM lhwndTemp%
  1078.     DIM lWndStyle&
  1079.  
  1080.     lhwndTemp% = GetActiveWindow ()
  1081.  
  1082.     ' Get the window's style attributes
  1083.     lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE)
  1084.  
  1085.     BWindowMaximized = (lWndStyle& AND WS_MAXIMIZE) <> 0
  1086.  
  1087. END FUNCTION
  1088.  
  1089.  
  1090. '
  1091. ' XMinWindow
  1092. '
  1093. ' Description:
  1094. '       Minimize the current active window
  1095. '
  1096. ' Parameters:
  1097. '       none
  1098. '
  1099. ' Returns:
  1100. '       nothing
  1101. '
  1102. ' Example:
  1103. '       XMinWindow
  1104. '
  1105. '
  1106. '
  1107.  
  1108.  
  1109. SUB XMinWindow STATIC
  1110.     DIM bogus%
  1111.     DIM lhwndTemp%
  1112.     DIM lWndStyle&
  1113.  
  1114.     lhwndTemp% = GetActiveWindow ()
  1115.  
  1116.     ' Get the window's style attributes
  1117.     lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE)
  1118.  
  1119.     ' IF maximized, XLog the descrepancy
  1120.     IF ((lWndStyle& And WS_MINIMIZE) <> 0) THEN
  1121.         XLogFailure "Could not minimize active window, already minimized"
  1122.     ELSE
  1123.         bogus% = ShowWindow(lhwndTemp%, SW_SHOWMINIMIZED)
  1124.     END IF
  1125.  
  1126. END SUB
  1127.  
  1128. ' XWindowMinimized
  1129. '
  1130. ' Description:
  1131. '       Check that current window is minimized
  1132. '
  1133. ' Parameters:
  1134. '       none
  1135. '
  1136. ' Returns:
  1137. '       nothing
  1138. '
  1139. ' Example:
  1140. '       XWindowMinized
  1141. '
  1142. '
  1143. '
  1144.  
  1145.  
  1146. SUB XWindowMinimized STATIC
  1147.  
  1148.     IF BWindowMinimized = 0 THEN
  1149.         XLogFailure "Active Window not Minimized"
  1150.     END IF
  1151.  
  1152. END SUB
  1153.  
  1154. '
  1155. ' XWindowNotMinimized
  1156. '
  1157. ' Description:
  1158. '       Check that current window is not minimized
  1159. '
  1160. ' Parameters:
  1161. '       none
  1162. '
  1163. ' Returns:
  1164. '       nothing
  1165. '
  1166. ' Example:
  1167. '       XWindowNotMinimized
  1168. '
  1169. '
  1170. '
  1171.  
  1172.  
  1173. SUB XWindowNotMinimized STATIC
  1174.     IF BWindowMinimized THEN
  1175.         XLogFailure "Active Window is Minimized"
  1176.     END IF
  1177.  
  1178. END SUB
  1179.  
  1180. '
  1181. ' BWindowMinimized
  1182. '
  1183. ' Description:
  1184. '       Detect IF active window minimized
  1185. '
  1186. ' Parameters:
  1187. '       none
  1188. '
  1189. ' Returns:
  1190. '       TRUE if minimized, FALSE if not
  1191. '
  1192. ' Example:
  1193. '       BWindowMinimized
  1194. '
  1195. '
  1196. '
  1197.  
  1198.  
  1199. FUNCTION BWindowMinimized% STATIC
  1200.     DIM bogus%
  1201.     DIM lhwndTemp%
  1202.     DIM lWndStyle&
  1203.  
  1204.     lhwndTemp% = GetActiveWindow ()
  1205.  
  1206.     ' Get the window's style attributes
  1207.     lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE)
  1208.  
  1209.     BWindowMinimized = (lWndStyle& AND WS_MINIMIZE) <> 0
  1210.  
  1211. END FUNCTION
  1212.  
  1213. '
  1214. ' XRestoreWindow
  1215. '
  1216. ' Description:
  1217. '       Restore the current active window.  NOTE: You must make
  1218. '       the icon the active window before calling XRestoreWin!
  1219. '
  1220. ' Parameters:
  1221. '       none
  1222. '
  1223. ' Returns:
  1224. '       nothing
  1225. '
  1226. ' Example:
  1227. '       XRestoreWindow
  1228. '
  1229. '
  1230. '
  1231.  
  1232.  
  1233. SUB XRestoreWindow STATIC
  1234.     DIM bogus%
  1235.     DIM lhwndTemp%
  1236.     DIM lWndStyle&
  1237.  
  1238.     lhwndTemp% = GetActiveWindow ()
  1239.  
  1240.     ' Get the window's style attributes
  1241.     lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE)
  1242.  
  1243.     ' IF maximized, XLog the descrepancy
  1244.     IF ((lWndStyle& And WS_MINIMIZE) = 0) AND ((lWndStyle& And WS_MAXIMIZE) = 0) THEN
  1245.         XLogFailure "Active window is not minimized or maximized."
  1246.     ELSE
  1247.         bogus% = ShowWindow(lhwndTemp%, SW_RESTORE)
  1248.     END IF
  1249.  
  1250. END SUB
  1251.  
  1252.  
  1253.  
  1254. '
  1255. ' XSizeActiveWindow(iXPixels, iYPixels, fAbsOrRel)
  1256. '
  1257. ' Description:
  1258. '       Moves the bottom-right corner of the active window
  1259. '       to new coordiates iXPixels, iYPixels.  IF fAbsOrRel
  1260. '       is TRUE, the coordiates are absolute.  IF fAbsOrRel
  1261. '       is FALSE, the coordiates are relative to the current
  1262. '       position.
  1263. '
  1264. ' Parameters:
  1265. '       iXPixels - X coordinate
  1266. '       iYPixels - Y coordinate
  1267. '       IF !fAbsOrRel FALSE, the X,Y coordinates are relative to the
  1268. '       current mouse coordianates.
  1269. '
  1270. ' Returns:
  1271. '       nothing
  1272. '
  1273. ' Example:
  1274. '       XSizeActiveWindow iXPixels, iYPixels, fAbsOrRel
  1275. '
  1276. '
  1277. '
  1278.  
  1279. SUB XSizeActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%) STATIC
  1280.  
  1281.     DIM xyTempRect As rect
  1282.     DIM iTempX%
  1283.     DIM iTempY%
  1284.     DIM temphWnd%
  1285.  
  1286.     IF fAbsOrRel% THEN
  1287.         WSetWndSiz GetActiveWindow(), iXPixels%, iYPixels%
  1288.     ELSE
  1289.         ' Find the active window
  1290.         temphWnd% = GetActiveWindow
  1291.  
  1292.         ' Get the Rect of the active window
  1293.         GetWindowRect temphWnd%, xyTempRect
  1294.         ' Determine new X coordinate
  1295.         iTempX% = ((xyTempRect.wright - 1) - (xyTempRect.wleft)) + iXPixels%
  1296.  
  1297.         ' Determine new Y coordinate
  1298.         iTempY% = ((xyTempRect.bottom - 1) - (xyTempRect.top)) + iYPixels%
  1299.  
  1300.         ' size the window
  1301.         WSetWndSiz GetActiveWindow(), iTempX%, iTempY%
  1302.  
  1303.     END IF
  1304. END SUB
  1305.  
  1306.  
  1307. '
  1308. ' XMoveActiveWindow(iXPixels, iYPixels, fAbsOrRel)
  1309. '
  1310. ' Description:
  1311. '       Moves the top-left corner of the active window
  1312. '       to new coordiates iXPixels, iYPixels.  IF fAbsOrRel
  1313. '       is TRUE, the coordiates are absolute.  IF fAbsOrRel
  1314. '       is FALSE, the coordiates are relative to the current
  1315. '       position.
  1316. '
  1317. ' Parameters:
  1318. '       iXPixels - X coordinate
  1319. '       iYPixels - Y coordinate
  1320. '       IF !fAbsOrRel FALSE, the X,Y coordinates are relative to the
  1321. '       current mouse coordianates.
  1322. '
  1323. ' Returns:
  1324. '       nothing
  1325. '
  1326. ' Example:
  1327. '       XMoveActiveWindow iXPixels, iYPixels, fAbsOrRel
  1328. '
  1329. '
  1330.  
  1331. SUB XMoveActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%) STATIC
  1332.  
  1333.     DIM xyTempRect As Rect
  1334.     DIM iTempX%
  1335.     DIM iTempY%
  1336.     DIM temphWnd%
  1337.  
  1338.  
  1339.     IF fAbsOrRel% THEN
  1340.         WSetWndPos GetActiveWindow(), iXPixels%, iYPixels%
  1341.     ELSE
  1342.         ' Find the active window
  1343.         temphWnd% = GetActiveWindow
  1344.  
  1345.         ' Get the Rect of the active window
  1346.         GetWindowRect temphWnd%, xyTempRect
  1347.  
  1348.         ' Determine new X coordinate
  1349.         iTempX% = xyTempRect.wleft + iXPixels%
  1350.  
  1351.         ' Determine new Y coordinate
  1352.         iTempY% = xyTempRect.top + iYPixels%
  1353.  
  1354.         ' move the window
  1355.         WSetWndPos GetActiveWindow(), iTempX%, iTempY%
  1356.     END IF
  1357. END SUB
  1358.