|
|
1.1 ! root 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: ! 553: '$IFNDEF NT ! 554: WMenuText iIndex%, buffer$ 'get menu text. If above "IF" condition ! 555: 'is skipped, this gets text in menu bar. ! 556: '$ELSE ! 557: WMenuText "@"+STR$(iIndex%), buffer$ ! 558: '$ENDIF ! 559: ! 560: SGetMenuItemText = buffer$ 'return buffer$ ! 561: ! 562: DoKeys "{esc 3}" 'Make sure you close menu. ! 563: ! 564: END FUNCTION ! 565: ! 566: ! 567: ! 568: ' ! 569: ' BMenuItemGrayed(stMenu$, stMenuItem$,stHMenuItem$) ! 570: ' ! 571: ' Description: ! 572: ' This procedure checks to see IF the specified menu or ! 573: ' menu item is grayed out or not. ! 574: ' ! 575: ' Parameters: ! 576: ' stMenu = menu where stMenuItem is found. ! 577: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 578: ' exists. ! 579: ' stHMenuItem = hierarchial(popup) menu item. ! 580: ' ! 581: ' Returns: ! 582: ' TRUE if grayed. ! 583: ' FALSE if not grayed. ! 584: ' ! 585: ' Example: ! 586: ' fIsGrayed% = BMenuItemGrayed("Edit", "Copy", "") ! 587: ' fIsGrayed% = BMenuItemGrayed("Edit", "", "") ! 588: ' ! 589: ' ! 590: FUNCTION BMenuItemGrayed%(stMenu$, stMenuItem$, stHMenuItem$) STATIC ! 591: ! 592: IF stHMenuItem$ = "" THEN ! 593: IF stMenuItem$ = "" THEN ! 594: BMenuItemGrayed = WMenuGrayed(stMenu$) <> 0 'Check main menu bar menu items. ! 595: ELSE ! 596: WMenu(stMenu$) 'Check menu item within stMenuItem$. ! 597: BMenuItemGrayed = WMenuGrayed(stMenuItem$) <> 0 ! 598: END IF ! 599: ELSE ! 600: WMenu(stMenu$) 'Check popup menu items. ! 601: WMenu(stMenuItem$) ! 602: BMenuItemGrayed = WMenuGrayed(stHMenuItem$) <> 0 ! 603: END IF ! 604: DoKeys "{esc 3}" 'Make sure you close menu. ! 605: ! 606: END FUNCTION ! 607: ! 608: ! 609: ' ! 610: ' XMenuItemGrayed (stMenu$,stMenuItem$, stHMenuItem$) ! 611: ' ! 612: ' Description: ! 613: ' Reports error IF menu item is not Grayed. ! 614: ' ! 615: ' Parameters: ! 616: ' stMenu = menu where stMenuItem is found. ! 617: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 618: ' exists. ! 619: ' stHMenuItem = hierarchial(popup) menu item. ! 620: ' ! 621: ' Returns: ! 622: ' nothing ! 623: ' ! 624: ' Example: ! 625: ' XMenuItemGrayed "File", "Close", "" ! 626: ' ! 627: ' ! 628: ' ! 629: ! 630: SUB XMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 631: IF BMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN ! 632: XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Grayed" ! 633: END IF ! 634: END SUB ! 635: ! 636: ' ! 637: ' XMenuItemNotGrayed (stMenu$,stMenuItem$, stHMenuItem$) ! 638: ' ! 639: ' Description: ! 640: ' Reports error IF menu item is Grayed. ! 641: ' ! 642: ' Parameters: ! 643: ' stMenu = menu where stMenuItem is found. ! 644: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 645: ' exists. ! 646: ' stHMenuItem = hierarchial(popup) menu item. ! 647: ' ! 648: ' Returns: ! 649: ' nothing ! 650: ' ! 651: ' Example: ! 652: ' XMenuItemNotGrayed "File", "Close", "" ! 653: ' ! 654: ' ! 655: ' ! 656: ! 657: SUB XMenuItemNotGrayed(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 658: IF BMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) THEN ! 659: XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Grayed" ! 660: END IF ! 661: END SUB ! 662: ! 663: ! 664: ! 665: ' ! 666: ' BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) ! 667: ' ! 668: ' Description: ! 669: ' This procedure checks to see IF the specified menu ! 670: ' item is checked or not. ! 671: ' ! 672: ' Parameters: ! 673: ' stMenu = menu where stMenuItem is found. ! 674: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 675: ' exists. ! 676: ' stHMenuItem = hierarchial(popup) menu item. ! 677: ' ! 678: ' Returns: ! 679: ' TRUE if checked. ! 680: ' FALSE if not checked. ! 681: ' ! 682: ' Example: ! 683: ' fIsChecked% = BMenuItemChecked("Format","Style","Bold") ! 684: ' fIsChecked% = BMenuItemchecked("Edit", "Copy", "") ! 685: ' ! 686: ' ! 687: FUNCTION BMenuItemChecked%(stMenu$, stMenuItem$, stHMenuItem$) STATIC ! 688: ! 689: IF stHMenuItem$ = "" THEN ! 690: WMenu(stMenu$) 'Check menu item within stMenu$. ! 691: BMenuItemChecked = WMenuChecked(stMenuItem$) <> 0 ! 692: ELSE ! 693: WMenu(stMenu$) 'Check menu item under popup menu. ! 694: WMenu(stMenuItem$) ! 695: BMenuItemChecked = WMenuChecked(stHMenuItem$) <> 0 ! 696: END IF ! 697: DoKeys "{esc 3}" 'Make sure you close menu. ! 698: ! 699: END FUNCTION ! 700: ! 701: ! 702: ! 703: ' ! 704: ' XMenuItemChecked (stMenu$,stMenuItem$, stHMenuItem$) ! 705: ' ! 706: ' Description: ! 707: ' Reports error IF menu item is not Checked. ! 708: ' ! 709: ' Parameters: ! 710: ' stMenu = menu where stMenuItem is found. ! 711: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 712: ' exists. ! 713: ' stHMenuItem = hierarchial(popup) menu item. ! 714: ' ! 715: ' Returns: ! 716: ' nothing ! 717: ' ! 718: ' Example: ! 719: ' XMenuItemChecked "Options", "Read Only", "" ! 720: ' ! 721: ' ! 722: ' ! 723: SUB XMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 724: IF BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN ! 725: XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Checked" ! 726: END IF ! 727: END SUB ! 728: ! 729: ' ! 730: ' XMenuItemNotChecked (stMenu$,stMenuItem$, stHMenuItem$) ! 731: ' ! 732: ' Description: ! 733: ' Reports error IF menu item is Checked. ! 734: ' ! 735: ' Parameters: ! 736: ' stMenu = menu where stMenuItem is found. ! 737: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 738: ' exists. ! 739: ' stHMenuItem = hierarchial(popup) menu item. ! 740: ' ! 741: ' Returns: ! 742: ' nothing ! 743: ' ! 744: ' Example: ! 745: ' XMenuItemNotChecked "Options", "Read Only", "" ! 746: ' ! 747: ' ! 748: ' ! 749: SUB XMenuItemNotChecked(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 750: IF BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) THEN ! 751: XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Checked" ! 752: END IF ! 753: END SUB ! 754: ! 755: ! 756: ! 757: ' ! 758: ' BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) ! 759: ' ! 760: ' Description: ! 761: ' This procedure checks to see IF the specified menu or ! 762: ' menu item is enabled or not. ! 763: ' ! 764: ' Parameters: ! 765: ' stMenu = menu where stMenuItem is found. ! 766: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 767: ' exists. ! 768: ' stHMenuItem = hierarchial(popup) menu item. ! 769: ' ! 770: ' Returns: ! 771: ' TRUE if enabled. ! 772: ' FALSE if not enabled. ! 773: ' ! 774: ' Example: ! 775: ' fIsEnabled% = BMenuItemEnabled("File", "", "") ! 776: ' fIsEnabled% = BMenuItemEnabled("File", "Close", "") ! 777: ' ! 778: ' ! 779: FUNCTION BMenuItemEnabled%(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 780: ! 781: IF stHMenuItem$ = "" THEN ! 782: IF stMenuItem$ = "" THEN ! 783: BMenuItemEnabled = WMenuEnabled(stMenu$) <> 0 'Check main menu bar menu items. ! 784: ELSE ! 785: WMenu(stMenu$) 'Check menu item within stMenu$. ! 786: BMenuItemEnabled = WMenuEnabled(stMenuItem$) <> 0 ! 787: END IF ! 788: ELSE ! 789: WMenu(stMenu$) 'Check menu item under popup menu. ! 790: WMenu(stMenuItem$) ! 791: BMenuItemEnabled = WMenuEnabled(stHMenuItem$) <> 0 ! 792: END IF ! 793: DoKeys "{esc 3}" 'Make sure you close menu. ! 794: ! 795: END FUNCTION ! 796: ! 797: ! 798: ' ! 799: ' XMenuItemEnabled (stMenu$,stMenuItem$, stHMenuItem$) ! 800: ' ! 801: ' Description: ! 802: ' Reports error IF menu item is not Enabled. ! 803: ' ! 804: ' Parameters: ! 805: ' stMenu = menu where stMenuItem is found. ! 806: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 807: ' exists. ! 808: ' stHMenuItem = hierarchial(popup) menu item. ! 809: ' ! 810: ' Returns: ! 811: ' nothing ! 812: ' ! 813: ' Example: ! 814: ' XMenuItemEnabled "Options", "Read Only", "" ! 815: ' ! 816: ' ! 817: ' ! 818: SUB XMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 819: IF BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN ! 820: XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Enabled" ! 821: END IF ! 822: END SUB ! 823: ! 824: ! 825: ' ! 826: ' XMenuItemNotEnabled (stMenu$,stMenuItem$, stHMenuItem$) ! 827: ' ! 828: ' Description: ! 829: ' Reports error IF menu item is Enabled. ! 830: ' ! 831: ' Parameters: ! 832: ' stMenu = menu where stMenuItem is found. ! 833: ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ! 834: ' exists. ! 835: ' stHMenuItem = hierarchial(popup) menu item. ! 836: ' ! 837: ' Returns: ! 838: ' nothing ! 839: ' ! 840: ' Example: ! 841: ' XMenuItemNotEnabled "Options", "Read Only", "" ! 842: ' ! 843: ' ! 844: ' ! 845: SUB XMenuItemNotEnabled(stMenu$,stMenuItem$, stHMenuItem$) STATIC ! 846: IF BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) THEN ! 847: XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Enabled" ! 848: END IF ! 849: END SUB ! 850: ! 851: ! 852: ! 853: '********************************************************** ! 854: '***************** Window Subroutines ********************* ! 855: '********************************************************** ! 856: ! 857: ! 858: ! 859: ! 860: ' ! 861: ' XCaptionExists(stCaption$) ! 862: ' ! 863: ' Description: ! 864: ' Will report error IF caption does not Exist. ! 865: ' ! 866: ' Parameters: ! 867: ' stCaption$ - expected caption of current window ! 868: ' ! 869: ' Returns: ! 870: ' nothing ! 871: ' ! 872: ' Example: ! 873: ' XCaptionExists "Winword" ! 874: ' ! 875: ' ! 876: ' ! 877: SUB XCaptionExists(stCaption$) STATIC ! 878: IF Instr(SGetCaption(), stCaption$) = 0 THEN ! 879: XLogFailure stCaption$ + " caption does not exist in active window." ! 880: END IF ! 881: END SUB ! 882: ! 883: ! 884: ' ! 885: ' XCaptionNotExists(stCaption$) ! 886: ' ! 887: ' Description: ! 888: ' Will report error IF caption Exist. ! 889: ' ! 890: ' Parameters: ! 891: ' stCaption$ - NOT expected caption of current window ! 892: ' ! 893: ' Returns: ! 894: ' nothing ! 895: ' ! 896: ' Example: ! 897: ' XCaptionNotExists "Winword" ! 898: ' ! 899: ' ! 900: SUB XCaptionNotExists(stCaption$) STATIC ! 901: IF Instr(SGetCaption(), stCaption$) <> 0 THEN ! 902: XLogFailure stCaption$ + " caption Exists in active window." ! 903: END IF ! 904: END SUB ! 905: ! 906: ! 907: ! 908: ' ! 909: ' SGetCaption() ! 910: ' ! 911: ' Description: ! 912: ' Returns the caption of the Active window ! 913: ' ! 914: ' Parameters: ! 915: ' none ! 916: ' ! 917: ' Return: ! 918: ' Caption of the Active window ! 919: ' ! 920: ' Example: ! 921: ' stCaption$ = SGetCaption() ! 922: ' ! 923: ' ! 924: FUNCTION SGetCaption$() STATIC ! 925: DIM x% ! 926: DIM stCaption$ ! 927: ! 928: stCaption$ = String$(100, 32) ! 929: x% = GetWindowText (GetForegroundWindow(), stCaption$, LEN(stCaption$)) ! 930: SGetCaption = mid$(stCaption$,1,x%) ! 931: stCaption$ = "" ! 932: END FUNCTION ! 933: ! 934: ! 935: ! 936: ' ! 937: ' XZoomWindow ! 938: ' ! 939: ' Description: ! 940: ' Toggles the state of the window between normalized ! 941: ' and maximized. ! 942: ' ! 943: ' Parameters: ! 944: ' None ! 945: ' ! 946: ' Returns: ! 947: ' nothing ! 948: ' ! 949: ' Example: ! 950: ' XZoomWindow ! 951: ' ! 952: ' ! 953: ' ! 954: SUB XZoomWindow STATIC ! 955: DIM bogus% ! 956: DIM lhwndTemp% ! 957: ! 958: lhwndTemp% = GetForegroundWindow() ! 959: ! 960: ' IF the window is maximized, normalize. ! 961: ! 962: IF (IsZoomed(lhwndTemp%)) THEN ! 963: ' window is maximized, we must normalize it ! 964: bogus% = ShowWindow(lhwndTemp%, SW_SHOWNORMAL) ! 965: ELSE ! 966: bogus% = ShowWindow(lhwndTemp%, SW_MAXIMIZE) ! 967: END IF ! 968: ! 969: END SUB ! 970: ! 971: ! 972: ' ! 973: ' XMaxWindow ! 974: ' ! 975: ' Description: ! 976: ' Maximize the current active window ! 977: ' ! 978: ' Parameters: ! 979: ' None ! 980: ' ! 981: ' Returns: ! 982: ' nothing ! 983: ' ! 984: ' Example: ! 985: ' XMaxWinow ! 986: ' ! 987: ' ! 988: ' ! 989: ! 990: ! 991: SUB XMaxWindow STATIC ! 992: DIM bogus% ! 993: DIM lhwndTemp% ! 994: DIM lWndStyle& ! 995: ! 996: lhwndTemp% = GetForegroundWindow () ! 997: ! 998: ' Get the window's style attributes ! 999: lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ! 1000: ! 1001: IF ((lWndStyle& And WS_MAXIMIZE) <> 0) THEN ! 1002: XLogFailure "Could not maximize active window, already maximized" ! 1003: ELSE ! 1004: bogus% = ShowWindow(lhwndTemp%, SW_SHOWMAXIMIZED) ! 1005: END IF ! 1006: ! 1007: END SUB ! 1008: ! 1009: ' ! 1010: ' XWindowMaximized ! 1011: ' ! 1012: ' Description: ! 1013: ' check IF the current active window is Maximized ! 1014: ' ! 1015: ' Parameters: ! 1016: ' none ! 1017: ' ! 1018: ' Returns: ! 1019: ' nothing ! 1020: ' ! 1021: ' Example: ! 1022: ' XWindowMaximized ! 1023: ' ! 1024: ' ! 1025: ' ! 1026: ! 1027: ! 1028: SUB XWindowMaximized STATIC ! 1029: IF BWindowMaximized = 0 THEN ! 1030: XLogFailure "Active Window not maximized" ! 1031: END IF ! 1032: ! 1033: END SUB ! 1034: ! 1035: ' ! 1036: ' XWindowNotMaximized ! 1037: ' ! 1038: ' Description: ! 1039: ' Check that the current window is not maximized ! 1040: ' ! 1041: ' Parameters: ! 1042: ' none ! 1043: ' ! 1044: ' Returns: ! 1045: ' nothing ! 1046: ' ! 1047: ' Example: ! 1048: ' XWindowNotMaximized ! 1049: ' ! 1050: ' ! 1051: ' ! 1052: ! 1053: ! 1054: SUB XWindowNotMaximized STATIC ! 1055: ! 1056: IF BWindowMaximized THEN ! 1057: XLogFailure "Active Window is maximized" ! 1058: END IF ! 1059: ! 1060: END SUB ! 1061: ! 1062: ' ! 1063: ' BWindowMaximized ! 1064: ' ! 1065: ' Description: ! 1066: ' detect IF current window is maximized ! 1067: ' ! 1068: ' Parameters: ! 1069: ' none ! 1070: ' ! 1071: ' Returns: ! 1072: ' TRUE if maximized, FALSE if not ! 1073: ' ! 1074: ' Example: ! 1075: ' BWindowMaximized ! 1076: ' ! 1077: ' ! 1078: ' ! 1079: ! 1080: ! 1081: FUNCTION BWindowMaximized% STATIC ! 1082: DIM bogus% ! 1083: DIM lhwndTemp% ! 1084: DIM lWndStyle& ! 1085: ! 1086: lhwndTemp% = GetForegroundWindow () ! 1087: ! 1088: ' Get the window's style attributes ! 1089: lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ! 1090: ! 1091: BWindowMaximized = (lWndStyle& AND WS_MAXIMIZE) <> 0 ! 1092: ! 1093: END FUNCTION ! 1094: ! 1095: ! 1096: ' ! 1097: ' XMinWindow ! 1098: ' ! 1099: ' Description: ! 1100: ' Minimize the current active window ! 1101: ' ! 1102: ' Parameters: ! 1103: ' none ! 1104: ' ! 1105: ' Returns: ! 1106: ' nothing ! 1107: ' ! 1108: ' Example: ! 1109: ' XMinWindow ! 1110: ' ! 1111: ' ! 1112: ' ! 1113: ! 1114: ! 1115: SUB XMinWindow STATIC ! 1116: DIM bogus% ! 1117: DIM lhwndTemp% ! 1118: DIM lWndStyle& ! 1119: ! 1120: lhwndTemp% = GetForegroundWindow () ! 1121: ! 1122: ' Get the window's style attributes ! 1123: lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ! 1124: ! 1125: ' IF maximized, XLog the descrepancy ! 1126: IF ((lWndStyle& And WS_MINIMIZE) <> 0) THEN ! 1127: XLogFailure "Could not minimize active window, already minimized" ! 1128: ELSE ! 1129: bogus% = ShowWindow(lhwndTemp%, SW_SHOWMINIMIZED) ! 1130: END IF ! 1131: ! 1132: END SUB ! 1133: ! 1134: ' XWindowMinimized ! 1135: ' ! 1136: ' Description: ! 1137: ' Check that current window is minimized ! 1138: ' ! 1139: ' Parameters: ! 1140: ' none ! 1141: ' ! 1142: ' Returns: ! 1143: ' nothing ! 1144: ' ! 1145: ' Example: ! 1146: ' XWindowMinized ! 1147: ' ! 1148: ' ! 1149: ' ! 1150: ! 1151: ! 1152: SUB XWindowMinimized STATIC ! 1153: ! 1154: IF BWindowMinimized = 0 THEN ! 1155: XLogFailure "Active Window not Minimized" ! 1156: END IF ! 1157: ! 1158: END SUB ! 1159: ! 1160: ' ! 1161: ' XWindowNotMinimized ! 1162: ' ! 1163: ' Description: ! 1164: ' Check that current window is not minimized ! 1165: ' ! 1166: ' Parameters: ! 1167: ' none ! 1168: ' ! 1169: ' Returns: ! 1170: ' nothing ! 1171: ' ! 1172: ' Example: ! 1173: ' XWindowNotMinimized ! 1174: ' ! 1175: ' ! 1176: ' ! 1177: ! 1178: ! 1179: SUB XWindowNotMinimized STATIC ! 1180: IF BWindowMinimized THEN ! 1181: XLogFailure "Active Window is Minimized" ! 1182: END IF ! 1183: ! 1184: END SUB ! 1185: ! 1186: ' ! 1187: ' BWindowMinimized ! 1188: ' ! 1189: ' Description: ! 1190: ' Detect IF active window minimized ! 1191: ' ! 1192: ' Parameters: ! 1193: ' none ! 1194: ' ! 1195: ' Returns: ! 1196: ' TRUE if minimized, FALSE if not ! 1197: ' ! 1198: ' Example: ! 1199: ' BWindowMinimized ! 1200: ' ! 1201: ' ! 1202: ' ! 1203: ! 1204: ! 1205: FUNCTION BWindowMinimized% STATIC ! 1206: DIM bogus% ! 1207: DIM lhwndTemp% ! 1208: DIM lWndStyle& ! 1209: ! 1210: lhwndTemp% = GetForegroundWindow () ! 1211: ! 1212: ' Get the window's style attributes ! 1213: lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ! 1214: ! 1215: BWindowMinimized = (lWndStyle& AND WS_MINIMIZE) <> 0 ! 1216: ! 1217: END FUNCTION ! 1218: ! 1219: ' ! 1220: ' XRestoreWindow ! 1221: ' ! 1222: ' Description: ! 1223: ' Restore the current active window. NOTE: You must make ! 1224: ' the icon the active window before calling XRestoreWin! ! 1225: ' ! 1226: ' Parameters: ! 1227: ' none ! 1228: ' ! 1229: ' Returns: ! 1230: ' nothing ! 1231: ' ! 1232: ' Example: ! 1233: ' XRestoreWindow ! 1234: ' ! 1235: ' ! 1236: ' ! 1237: ! 1238: ! 1239: SUB XRestoreWindow STATIC ! 1240: DIM bogus% ! 1241: DIM lhwndTemp% ! 1242: DIM lWndStyle& ! 1243: ! 1244: lhwndTemp% = GetForegroundWindow () ! 1245: ! 1246: ' Get the window's style attributes ! 1247: lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ! 1248: ! 1249: ' IF maximized, XLog the descrepancy ! 1250: IF ((lWndStyle& And WS_MINIMIZE) = 0) AND ((lWndStyle& And WS_MAXIMIZE) = 0) THEN ! 1251: XLogFailure "Active window is not minimized or maximized." ! 1252: ELSE ! 1253: bogus% = ShowWindow(lhwndTemp%, SW_RESTORE) ! 1254: END IF ! 1255: ! 1256: END SUB ! 1257: ! 1258: ! 1259: ! 1260: ' ! 1261: ' XSizeActiveWindow(iXPixels, iYPixels, fAbsOrRel) ! 1262: ' ! 1263: ' Description: ! 1264: ' Moves the bottom-right corner of the active window ! 1265: ' to new coordiates iXPixels, iYPixels. IF fAbsOrRel ! 1266: ' is TRUE, the coordiates are absolute. IF fAbsOrRel ! 1267: ' is FALSE, the coordiates are relative to the current ! 1268: ' position. ! 1269: ' ! 1270: ' Parameters: ! 1271: ' iXPixels - X coordinate ! 1272: ' iYPixels - Y coordinate ! 1273: ' IF !fAbsOrRel FALSE, the X,Y coordinates are relative to the ! 1274: ' current mouse coordianates. ! 1275: ' ! 1276: ' Returns: ! 1277: ' nothing ! 1278: ' ! 1279: ' Example: ! 1280: ' XSizeActiveWindow iXPixels, iYPixels, fAbsOrRel ! 1281: ' ! 1282: ' ! 1283: ' ! 1284: ! 1285: SUB XSizeActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%) STATIC ! 1286: ! 1287: DIM xyTempRect As rect ! 1288: DIM iTempX% ! 1289: DIM iTempY% ! 1290: DIM temphWnd% ! 1291: ! 1292: IF fAbsOrRel% THEN ! 1293: WSetWndSiz GetForegroundWindow(), iXPixels%, iYPixels% ! 1294: ELSE ! 1295: ' Find the active window ! 1296: temphWnd% = GetForegroundWindow ! 1297: ! 1298: ' Get the Rect of the active window ! 1299: GetWindowRect temphWnd%, xyTempRect ! 1300: ' Determine new X coordinate ! 1301: iTempX% = ((xyTempRect.wright - 1) - (xyTempRect.wleft)) + iXPixels% ! 1302: ! 1303: ' Determine new Y coordinate ! 1304: iTempY% = ((xyTempRect.bottom - 1) - (xyTempRect.top)) + iYPixels% ! 1305: ! 1306: ' size the window ! 1307: WSetWndSiz GetForegroundWindow(), iTempX%, iTempY% ! 1308: ! 1309: END IF ! 1310: END SUB ! 1311: ! 1312: ! 1313: ' ! 1314: ' XMoveActiveWindow(iXPixels, iYPixels, fAbsOrRel) ! 1315: ' ! 1316: ' Description: ! 1317: ' Moves the top-left corner of the active window ! 1318: ' to new coordiates iXPixels, iYPixels. IF fAbsOrRel ! 1319: ' is TRUE, the coordiates are absolute. IF fAbsOrRel ! 1320: ' is FALSE, the coordiates are relative to the current ! 1321: ' position. ! 1322: ' ! 1323: ' Parameters: ! 1324: ' iXPixels - X coordinate ! 1325: ' iYPixels - Y coordinate ! 1326: ' IF !fAbsOrRel FALSE, the X,Y coordinates are relative to the ! 1327: ' current mouse coordianates. ! 1328: ' ! 1329: ' Returns: ! 1330: ' nothing ! 1331: ' ! 1332: ' Example: ! 1333: ' XMoveActiveWindow iXPixels, iYPixels, fAbsOrRel ! 1334: ' ! 1335: ' ! 1336: ! 1337: SUB XMoveActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%) STATIC ! 1338: ! 1339: DIM xyTempRect As Rect ! 1340: DIM iTempX% ! 1341: DIM iTempY% ! 1342: DIM temphWnd% ! 1343: ! 1344: ! 1345: IF fAbsOrRel% THEN ! 1346: WSetWndPos GetForegroundWindow(), iXPixels%, iYPixels% ! 1347: ELSE ! 1348: ' Find the active window ! 1349: temphWnd% = GetForegroundWindow ! 1350: ! 1351: ' Get the Rect of the active window ! 1352: GetWindowRect temphWnd%, xyTempRect ! 1353: ! 1354: ' Determine new X coordinate ! 1355: iTempX% = xyTempRect.wleft + iXPixels% ! 1356: ! 1357: ' Determine new Y coordinate ! 1358: iTempY% = xyTempRect.top + iYPixels% ! 1359: ! 1360: ' move the window ! 1361: WSetWndPos GetForegroundWindow(), iTempX%, iTempY% ! 1362: END IF ! 1363: END SUB
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.