Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1363 lines
31 KiB

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