'FTestKey.inc - definitions for Fast Test Key, Menu and Window routines ' ' Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved. ' 'Purpose: ' This file defines the Key, Menu and Window functions of the Fast Test ' functionality ' '********************************************************** '***************** Keystroke Subroutines ****************** '********************************************************** ' support routine for other subroutines, not meant to be called ' except by fasttest routines ' FUNCTION SKeyString$(s$) STATIC DIM sTemp$ IF LEN(s$) = 0 THEN XLogFailure "zero length string passed to SKeyString$" END IF IF LEN(s$) = 1 THEN SELECT CASE ASC(s$) ' alphanumerics, pass along as given CASE ASC("a") to ASC("z"), ASC("A") to ASC("Z"), ASC("0") to ASC("9") sTemp$ = s$ ' special characters to Dokeys, surround with braces CASE ASC("~"),ASC("+"),ASC("^"),ASC("%") sTemp$ = "{" + s$ + "}" CASE ASC("{"),ASC("}"),ASC("("),ASC(")"),ASC("["),ASC("]") sTemp$ = "{" + s$ + "}" ' normal printable non-alphanumerics, pass along CASE ASC("!"),ASC("@"),ASC("#"),ASC("$"),ASC("&") sTemp$ = s$ CASE ASC("*"),ASC("_"),ASC("|"),ASC(""""),ASC("<"),ASC(">") sTemp$ = s$ CASE ASC("-"),ASC("="),ASC("\"),ASC(";"),ASC("'"),ASC(":") sTemp$ =s$ CASE ASC(","),ASC("."),ASC("/"),ASC(" "),ASC("?"),ASC("`") sTemp$ =s$ ' non-printable other character CASE ELSE XLogFailure "Bad character passed to SKeyString$" END SELECT ELSE ' the string is greater than 1 character in length, put braces ' around it and send it to Dokeys and let it parse it sTemp$ = "{" + s$ + "}" END IF SKeyString$ = "(" + sTemp$ + ")" END FUNCTION ' support routine for other subroutines, not meant to be called ' except by fasttest routines ' FUNCTION SHideKeys$(s$) STATIC DIM check$ DIM i% DIM stRet$ ' this code must hide each character that is special to DoKeys stRet$ = "" ' start empty FOR i% = 1 to LEN(s$) ' special characters to DoKeys, surround with braces check$ = mid$(s$,i%,1) IF check$ = "~" OR check$ = "+" OR check$ = "^" OR check$ = "%" THEN stRet$ = stRet$ + "{" + check$ + "}" ELSEIF check$ = "{" OR check$ = "}" OR check$ = "(" OR check$ = ")" OR check$ = "[" OR check$ = "]" THEN stRet$ = stRet$ + "{" + check$ + "}" ELSE stRet$ = stRet$ + check$ END IF NEXT i% SHideKeys$ = stRet$ END FUNCTION ' ' XKey(s$) ' ' Description: ' Send Keystroke to active application ' This uses DoKeys, so DoKeys syntax is allowed ' ' Parameters: ' s$ - single char to send ' NOTE: any string longer that 1 character in length is assumed ' to be a special name for a key and is handled as such ' ' Returns: ' nothing ' ' Example: ' XKey "f" ' XKey "escape" SUB XKey (s$) STATIC DoKeys SKeyString$(s$) END SUB ' ' XAlt(s$) ' ' Description: ' Send a key as if the alt key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XAlt "f" ' XAlt "escape" ' ' SUB XAlt (s$) STATIC DoKeys "%" + SKeyString$(s$) END SUB ' ' XCtrl(s$) ' ' Description: ' Send a key as if the control key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XCtrl "f" ' XCtrl "escape" ' ' SUB XCtrl (s$) STATIC DoKeys "^" + SKeyString$(s$) END SUB ' ' XShift(s$) ' ' Description: ' Send a key as if the alt key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XShift "f" ' XShift "escape" ' ' SUB XShift (s$) STATIC DoKeys "+" + SKeyString$(s$) END SUB ' ' XCtrlAlt(s$) ' ' Description: ' Send a key as if the alt key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XCtrlAlt "f" ' XCtrlAlt "escape" ' ' SUB XCtrlAlt (s$) STATIC DoKeys "^%" + SKeyString$(s$) END SUB ' ' XAltShift(s$) ' ' Description: ' Send a key as if the alt key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XAltShift "f" ' XAltShift "escape" ' ' SUB XAltShift (s$) STATIC DoKeys "%+" + SKeyString$(s$) END SUB ' ' XCtrlShift(s$) ' ' Description: ' Send a key as if the alt key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XCtrlShift "f" ' XCtrlShift "escape" ' ' SUB XCtrlShift (s$) STATIC DoKeys "^+" + SKeyString$(s$) END SUB ' ' XCtrlAltShift(s$) ' ' Description: ' Send a key as if the alt key is pressed at the same time ' ' Parameters: ' s$ - single char to send ' see XKey note ' ' Returns: ' nothing ' ' Example: ' XCtrlAltShift "f" ' XCtrlAltShift "escape" ' ' SUB XCtrlAltShift (s$) STATIC DoKeys "^%+" + SKeyString$(s$) END SUB ' ' XText(s$) ' ' Description: ' Send any key as without having to specially specify any ' keys that are special to DoKeys ' ' Parameters: ' s$ - string of characters to send ' ' Returns: ' nothing ' ' Example: ' XText "Hello World" ' XText "The DoKeys string to send is {escape}" ' ' SUB XText(s$) STATIC DoKeys SHideKeys$(s$) END SUB ' ' XEnter(s$) ' ' Description: ' Send any key as without having to specially specify any ' keys that are special to DoKeys followed by an enter key ' ' Parameters: ' s$ - string of characters to send ' ' Returns: ' nothing ' ' Example: ' XEnter "Hello World" ' XEnter "The DoKeys string to send is {escape}" ' ' SUB XEnter(s$) STATIC DoKeys SHideKeys$(s$) + "{enter}" END SUB '********************************************************** '***************** Menu Subroutines *********************** '********************************************************** ' ' XSelectMenuItem(stMenu, stMenuItem, stHMenuItem) ' ' Description: ' This procedure selects the specified menu item name. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF ' Hierarchial menu exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XSelectMenuItem "Edit", "Copy","" ' ' SUB XSelectMenuItem(stMenu$,stMenuItem$,stHMenuItem$) STATIC XMenuItemExists stMenu$,stMenuItem$,stHMenuItem$ WMenu(stMenu$) IF stMenuItem$ <> "" THEN WMenu(stMenuItem$) END IF IF stHMenuItem$ <> "" THEN 'If popup menu is to be selected WMenu(stHMenuItem$) 'Select menu item under popup menu. END IF END SUB ' ' BMenuItemExists(stMenu, stMenuItem, stHMenuItem) ' ' Description: ' This procedure checks for the specified menu item ' and returns true IF found, false IF not found. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to check or secondary menu, IF ' Hierarchial menu exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' TRUE if it exists, FALSE if not ' ' Example: ' fSuccess% = BMenuItemExists("File", "", "") ' fSuccess% = BMenuItemExists("FIle","Edit", "") ' ' FUNCTION BMenuItemExists%(stMenu$,stMenuItem$,stHMenuItem$) STATIC IF stHMenuItem$ = "" THEN IF stMenuItem$ = "" THEN BMenuItemExists = WMenuExists(stMenu$) <> 0 ELSE WMenu(stMenu$) BMenuItemExists = WMenuExists(stMenuItem$) <> 0 END IF ELSE WMenu(stMenu$) WMenu(stMenuItem$) BMenuItemExists = WMenuExists(stHMenuItem$) <> 0 END IF DoKeys "{esc 3}" 'Make sure you close menu. END FUNCTION ' ' XMenuItemExists (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item does not exist. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF ' Hierarchial menu exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemExists "File", "Close", "" ' ' ' SUB XMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " does not Exist" END IF END SUB ' ' XMenuItemNotExists (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item exist. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemNotExists "File", "Close", "" ' ' ' SUB XMenuItemNotExists(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$) THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " Exists" END IF END SUB ' ' IGetMenuCount(stMenu, stMenuItem) ' ' Description: ' This procedure returns the number of menu items ' in the specified menu. ' ' Parameters: ' stMenu = top level menu to count menu items in. ' IF stMenu = "", THEN counts items in the menu bar(counts the ' number of top level menus). ' stMenuItem = secondary menu to count menu items in; counts hierarchial ' menu items. ' ' Returns: ' An integer; the number of menu items found. ' ' Example: ' iHowMany% = IGetMenuCount("","") returns how many top level menus. ' iHowMany% = IGetMenuCount("Utilities", "") returns the number of menu items ' in the "Utilities" menu. ' iHowMany% = IGetMenuCount("Utilities", "Info") returns how many menu items ' in the popup menu "Info". ' ' FUNCTION IGetMenuCount%(stMenu$, stMenuItem$) STATIC IF stMenuItem$ <> "" THEN 'Count in menu items in hierarchial menu. WMenu(stMenu$) WMenu(stMenuItem$) IGetMenuCount = WMenuCount() 'Count the number of menus items in the popup 'menu. ELSE IF stMenu$ <> "" THEN 'Count menus in stMenu$. WMenu(stMenu$) IGetMenuCount = WMenuCount() 'Count the number of menus items in the menu. ELSE IGetMenuCount = WMenuCount() 'Count the number of menus in the menu bar if. 'the above "IF" statements are skipped. END IF END IF DoKeys "{esc 3}" 'Make sure you close menu. END FUNCTION ' ' SGetMenuItemText(stMenu, stMenuItem, iIndex) ' ' Description: ' This procedure returns the text of menu item, iIndex ' (base 1) in stMenu. Length of the buffer to store ' the menu item text is passed in. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to check or secondary menu, IF Hierarchial menu ' exists. ' iIndex = index of menu item in stMenu. ' iLength = length of buffer to store text ' ' Returns: ' a string, the menu item text(name). ' ' Example: ' Print SGetMenuItemText("","","", 3) gets name of 3rd menu. ' Print SGetMenuItemText("Utilities","","",3) gets name of 3rd menu item ' in the "Utilities" menu. ' Print SGetMenuItemText("Utilities","Info",3) gets name of 3rd menu item ' in the popup menu "Info". ' ' FUNCTION SGetMenuItemText$(stMenu$,stMenuItem$, iIndex%) STATIC DIM buffer$ buffer$ = String$(128,32) 'initialize with spaces. IF stMenuItem$ <> "" THEN 'get menu text from hierarchial menu. WMenu(stMenu$) WMenu(stMenuItem$) ELSE IF stMenu$ <> "" THEN 'get menu text from stMenu$. WMenu(stMenu$) END IF END IF '$IFNDEF NT WMenuText iIndex%, buffer$ 'get menu text. If above "IF" condition 'is skipped, this gets text in menu bar. '$ELSE WMenuText "@"+STR$(iIndex%), buffer$ '$ENDIF SGetMenuItemText = buffer$ 'return buffer$ DoKeys "{esc 3}" 'Make sure you close menu. END FUNCTION ' ' BMenuItemGrayed(stMenu$, stMenuItem$,stHMenuItem$) ' ' Description: ' This procedure checks to see IF the specified menu or ' menu item is grayed out or not. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' TRUE if grayed. ' FALSE if not grayed. ' ' Example: ' fIsGrayed% = BMenuItemGrayed("Edit", "Copy", "") ' fIsGrayed% = BMenuItemGrayed("Edit", "", "") ' ' FUNCTION BMenuItemGrayed%(stMenu$, stMenuItem$, stHMenuItem$) STATIC IF stHMenuItem$ = "" THEN IF stMenuItem$ = "" THEN BMenuItemGrayed = WMenuGrayed(stMenu$) <> 0 'Check main menu bar menu items. ELSE WMenu(stMenu$) 'Check menu item within stMenuItem$. BMenuItemGrayed = WMenuGrayed(stMenuItem$) <> 0 END IF ELSE WMenu(stMenu$) 'Check popup menu items. WMenu(stMenuItem$) BMenuItemGrayed = WMenuGrayed(stHMenuItem$) <> 0 END IF DoKeys "{esc 3}" 'Make sure you close menu. END FUNCTION ' ' XMenuItemGrayed (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item is not Grayed. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemGrayed "File", "Close", "" ' ' ' SUB XMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Grayed" END IF END SUB ' ' XMenuItemNotGrayed (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item is Grayed. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemNotGrayed "File", "Close", "" ' ' ' SUB XMenuItemNotGrayed(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$) THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Grayed" END IF END SUB ' ' BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' This procedure checks to see IF the specified menu ' item is checked or not. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' TRUE if checked. ' FALSE if not checked. ' ' Example: ' fIsChecked% = BMenuItemChecked("Format","Style","Bold") ' fIsChecked% = BMenuItemchecked("Edit", "Copy", "") ' ' FUNCTION BMenuItemChecked%(stMenu$, stMenuItem$, stHMenuItem$) STATIC IF stHMenuItem$ = "" THEN WMenu(stMenu$) 'Check menu item within stMenu$. BMenuItemChecked = WMenuChecked(stMenuItem$) <> 0 ELSE WMenu(stMenu$) 'Check menu item under popup menu. WMenu(stMenuItem$) BMenuItemChecked = WMenuChecked(stHMenuItem$) <> 0 END IF DoKeys "{esc 3}" 'Make sure you close menu. END FUNCTION ' ' XMenuItemChecked (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item is not Checked. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemChecked "Options", "Read Only", "" ' ' ' SUB XMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Checked" END IF END SUB ' ' XMenuItemNotChecked (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item is Checked. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemNotChecked "Options", "Read Only", "" ' ' ' SUB XMenuItemNotChecked(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$) THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Checked" END IF END SUB ' ' BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' This procedure checks to see IF the specified menu or ' menu item is enabled or not. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' TRUE if enabled. ' FALSE if not enabled. ' ' Example: ' fIsEnabled% = BMenuItemEnabled("File", "", "") ' fIsEnabled% = BMenuItemEnabled("File", "Close", "") ' ' FUNCTION BMenuItemEnabled%(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF stHMenuItem$ = "" THEN IF stMenuItem$ = "" THEN BMenuItemEnabled = WMenuEnabled(stMenu$) <> 0 'Check main menu bar menu items. ELSE WMenu(stMenu$) 'Check menu item within stMenu$. BMenuItemEnabled = WMenuEnabled(stMenuItem$) <> 0 END IF ELSE WMenu(stMenu$) 'Check menu item under popup menu. WMenu(stMenuItem$) BMenuItemEnabled = WMenuEnabled(stHMenuItem$) <> 0 END IF DoKeys "{esc 3}" 'Make sure you close menu. END FUNCTION ' ' XMenuItemEnabled (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item is not Enabled. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemEnabled "Options", "Read Only", "" ' ' ' SUB XMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) = 0 THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is not Enabled" END IF END SUB ' ' XMenuItemNotEnabled (stMenu$,stMenuItem$, stHMenuItem$) ' ' Description: ' Reports error IF menu item is Enabled. ' ' Parameters: ' stMenu = menu where stMenuItem is found. ' stMenuItem = menu item to select or secondary menu, IF Hierarchial menu ' exists. ' stHMenuItem = hierarchial(popup) menu item. ' ' Returns: ' nothing ' ' Example: ' XMenuItemNotEnabled "Options", "Read Only", "" ' ' ' SUB XMenuItemNotEnabled(stMenu$,stMenuItem$, stHMenuItem$) STATIC IF BMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$) THEN XLogFailure stMenu$ + " " + stMenuItem$ + " " + stHMenuItem$ + " is Enabled" END IF END SUB '********************************************************** '***************** Window Subroutines ********************* '********************************************************** ' ' XCaptionExists(stCaption$) ' ' Description: ' Will report error IF caption does not Exist. ' ' Parameters: ' stCaption$ - expected caption of current window ' ' Returns: ' nothing ' ' Example: ' XCaptionExists "Winword" ' ' ' SUB XCaptionExists(stCaption$) STATIC IF Instr(SGetCaption(), stCaption$) = 0 THEN XLogFailure stCaption$ + " caption does not exist in active window." END IF END SUB ' ' XCaptionNotExists(stCaption$) ' ' Description: ' Will report error IF caption Exist. ' ' Parameters: ' stCaption$ - NOT expected caption of current window ' ' Returns: ' nothing ' ' Example: ' XCaptionNotExists "Winword" ' ' SUB XCaptionNotExists(stCaption$) STATIC IF Instr(SGetCaption(), stCaption$) <> 0 THEN XLogFailure stCaption$ + " caption Exists in active window." END IF END SUB ' ' SGetCaption() ' ' Description: ' Returns the caption of the Active window ' ' Parameters: ' none ' ' Return: ' Caption of the Active window ' ' Example: ' stCaption$ = SGetCaption() ' ' FUNCTION SGetCaption$() STATIC DIM x% DIM stCaption$ stCaption$ = String$(100, 32) x% = GetWindowText (GetForegroundWindow(), stCaption$, LEN(stCaption$)) SGetCaption = mid$(stCaption$,1,x%) stCaption$ = "" END FUNCTION ' ' XZoomWindow ' ' Description: ' Toggles the state of the window between normalized ' and maximized. ' ' Parameters: ' None ' ' Returns: ' nothing ' ' Example: ' XZoomWindow ' ' ' SUB XZoomWindow STATIC DIM bogus% DIM lhwndTemp% lhwndTemp% = GetForegroundWindow() ' IF the window is maximized, normalize. IF (IsZoomed(lhwndTemp%)) THEN ' window is maximized, we must normalize it bogus% = ShowWindow(lhwndTemp%, SW_SHOWNORMAL) ELSE bogus% = ShowWindow(lhwndTemp%, SW_MAXIMIZE) END IF END SUB ' ' XMaxWindow ' ' Description: ' Maximize the current active window ' ' Parameters: ' None ' ' Returns: ' nothing ' ' Example: ' XMaxWinow ' ' ' SUB XMaxWindow STATIC DIM bogus% DIM lhwndTemp% DIM lWndStyle& lhwndTemp% = GetForegroundWindow () ' Get the window's style attributes lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) IF ((lWndStyle& And WS_MAXIMIZE) <> 0) THEN XLogFailure "Could not maximize active window, already maximized" ELSE bogus% = ShowWindow(lhwndTemp%, SW_SHOWMAXIMIZED) END IF END SUB ' ' XWindowMaximized ' ' Description: ' check IF the current active window is Maximized ' ' Parameters: ' none ' ' Returns: ' nothing ' ' Example: ' XWindowMaximized ' ' ' SUB XWindowMaximized STATIC IF BWindowMaximized = 0 THEN XLogFailure "Active Window not maximized" END IF END SUB ' ' XWindowNotMaximized ' ' Description: ' Check that the current window is not maximized ' ' Parameters: ' none ' ' Returns: ' nothing ' ' Example: ' XWindowNotMaximized ' ' ' SUB XWindowNotMaximized STATIC IF BWindowMaximized THEN XLogFailure "Active Window is maximized" END IF END SUB ' ' BWindowMaximized ' ' Description: ' detect IF current window is maximized ' ' Parameters: ' none ' ' Returns: ' TRUE if maximized, FALSE if not ' ' Example: ' BWindowMaximized ' ' ' FUNCTION BWindowMaximized% STATIC DIM bogus% DIM lhwndTemp% DIM lWndStyle& lhwndTemp% = GetForegroundWindow () ' Get the window's style attributes lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) BWindowMaximized = (lWndStyle& AND WS_MAXIMIZE) <> 0 END FUNCTION ' ' XMinWindow ' ' Description: ' Minimize the current active window ' ' Parameters: ' none ' ' Returns: ' nothing ' ' Example: ' XMinWindow ' ' ' SUB XMinWindow STATIC DIM bogus% DIM lhwndTemp% DIM lWndStyle& lhwndTemp% = GetForegroundWindow () ' Get the window's style attributes lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ' IF maximized, XLog the descrepancy IF ((lWndStyle& And WS_MINIMIZE) <> 0) THEN XLogFailure "Could not minimize active window, already minimized" ELSE bogus% = ShowWindow(lhwndTemp%, SW_SHOWMINIMIZED) END IF END SUB ' XWindowMinimized ' ' Description: ' Check that current window is minimized ' ' Parameters: ' none ' ' Returns: ' nothing ' ' Example: ' XWindowMinized ' ' ' SUB XWindowMinimized STATIC IF BWindowMinimized = 0 THEN XLogFailure "Active Window not Minimized" END IF END SUB ' ' XWindowNotMinimized ' ' Description: ' Check that current window is not minimized ' ' Parameters: ' none ' ' Returns: ' nothing ' ' Example: ' XWindowNotMinimized ' ' ' SUB XWindowNotMinimized STATIC IF BWindowMinimized THEN XLogFailure "Active Window is Minimized" END IF END SUB ' ' BWindowMinimized ' ' Description: ' Detect IF active window minimized ' ' Parameters: ' none ' ' Returns: ' TRUE if minimized, FALSE if not ' ' Example: ' BWindowMinimized ' ' ' FUNCTION BWindowMinimized% STATIC DIM bogus% DIM lhwndTemp% DIM lWndStyle& lhwndTemp% = GetForegroundWindow () ' Get the window's style attributes lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) BWindowMinimized = (lWndStyle& AND WS_MINIMIZE) <> 0 END FUNCTION ' ' XRestoreWindow ' ' Description: ' Restore the current active window. NOTE: You must make ' the icon the active window before calling XRestoreWin! ' ' Parameters: ' none ' ' Returns: ' nothing ' ' Example: ' XRestoreWindow ' ' ' SUB XRestoreWindow STATIC DIM bogus% DIM lhwndTemp% DIM lWndStyle& lhwndTemp% = GetForegroundWindow () ' Get the window's style attributes lWndStyle& = GetWindowLong(lhwndTemp%, GWL_STYLE) ' IF maximized, XLog the descrepancy IF ((lWndStyle& And WS_MINIMIZE) = 0) AND ((lWndStyle& And WS_MAXIMIZE) = 0) THEN XLogFailure "Active window is not minimized or maximized." ELSE bogus% = ShowWindow(lhwndTemp%, SW_RESTORE) END IF END SUB ' ' XSizeActiveWindow(iXPixels, iYPixels, fAbsOrRel) ' ' Description: ' Moves the bottom-right corner of the active window ' to new coordiates iXPixels, iYPixels. IF fAbsOrRel ' is TRUE, the coordiates are absolute. IF fAbsOrRel ' is FALSE, the coordiates are relative to the current ' position. ' ' Parameters: ' iXPixels - X coordinate ' iYPixels - Y coordinate ' IF !fAbsOrRel FALSE, the X,Y coordinates are relative to the ' current mouse coordianates. ' ' Returns: ' nothing ' ' Example: ' XSizeActiveWindow iXPixels, iYPixels, fAbsOrRel ' ' ' SUB XSizeActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%) STATIC DIM xyTempRect As rect DIM iTempX% DIM iTempY% DIM temphWnd% IF fAbsOrRel% THEN WSetWndSiz GetForegroundWindow(), iXPixels%, iYPixels% ELSE ' Find the active window temphWnd% = GetForegroundWindow ' Get the Rect of the active window GetWindowRect temphWnd%, xyTempRect ' Determine new X coordinate iTempX% = ((xyTempRect.wright - 1) - (xyTempRect.wleft)) + iXPixels% ' Determine new Y coordinate iTempY% = ((xyTempRect.bottom - 1) - (xyTempRect.top)) + iYPixels% ' size the window WSetWndSiz GetForegroundWindow(), iTempX%, iTempY% END IF END SUB ' ' XMoveActiveWindow(iXPixels, iYPixels, fAbsOrRel) ' ' Description: ' Moves the top-left corner of the active window ' to new coordiates iXPixels, iYPixels. IF fAbsOrRel ' is TRUE, the coordiates are absolute. IF fAbsOrRel ' is FALSE, the coordiates are relative to the current ' position. ' ' Parameters: ' iXPixels - X coordinate ' iYPixels - Y coordinate ' IF !fAbsOrRel FALSE, the X,Y coordinates are relative to the ' current mouse coordianates. ' ' Returns: ' nothing ' ' Example: ' XMoveActiveWindow iXPixels, iYPixels, fAbsOrRel ' ' SUB XMoveActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%) STATIC DIM xyTempRect As Rect DIM iTempX% DIM iTempY% DIM temphWnd% IF fAbsOrRel% THEN WSetWndPos GetForegroundWindow(), iXPixels%, iYPixels% ELSE ' Find the active window temphWnd% = GetForegroundWindow ' Get the Rect of the active window GetWindowRect temphWnd%, xyTempRect ' Determine new X coordinate iTempX% = xyTempRect.wleft + iXPixels% ' Determine new Y coordinate iTempY% = xyTempRect.top + iYPixels% ' move the window WSetWndPos GetForegroundWindow(), iTempX%, iTempY% END IF END SUB