LHSP‡  :example by by n1to10n1to10n1to10dimensionsymbol!second example of 3D measurements scripting9ýøÿÿ†Sub Main SendKeys ListVar1 ' Step 1 – display the first number ' Step 2 - Display unit of measure SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar2 ' Step 4 – display the second number ' Step 5 - Display unit of measure SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar3 ' Step 7 – display the third number ' Step 8 - Display unit of measure SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) SendKeys " " ' Step 9 - Display a trailing space ' SendKeys "{(}" ' The following is different from in the book! ' ' Direct Multiplication of the variables, which are strings, is not allowed. ' ' instead, they can be be converted to integers using the VB CInt function, ' then multiplied, then converted back to a string using the CStr function. ' SendKeys CStr(CInt(ListVar1) * CInt(ListVar2) * CInt(ListVar3)) SendKeys " cubic " If "'\feet" = ListVar4 Then SendKeys "feet" Else SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) End If SendKeys "{)} End Sub example save for signaturereplacing invalid characters scripting9ýðÿESub Main SendKeys "^{Home}" ' 1. ctrl+home move to top of document SendKeys "%e" ' 2. alt+e select Edit menu MenuPick "Find" ' 3. select the “find” ' Advanced users – the Steps 2 & 3 can be done via a SendKeys "^f" Wait .5 ' 4. Wait a while ' 5. try to find "RE:" then destroy the "Find" window SendKeys "RE:{Enter}{Esc}" Wait .5 ' 6. Wait a while ' 7. move right two then copy the rest of the line SendKeys "{Right 2}+{End}^c" Wait .5 ' 8. alt+f for File, then a for Save As SendKeys "%fa" ' 8. alt+f for File, then a for Save As Wait .5 SendKeys "C:\My Documents\ReadyForSignature\" ' Alternate of SendKeys "C:\Temp\" Wait .5 '----------- Show Replace function ----------- Fname$ = Clipboard ' put clipboard contents into ' the string Fname$ ' replace periods with underline Fname$ = Replace (Fname$, ".", "_") ' replace slashes with underline Fname$ = Replace (Fname$, "/", "_") ' modify step 10 SendKeys Fname$ ' 10. updated file name ' -------- end of String Operations Changes ----- Wait .5 HeardWord "click", "Save" ' 11. save the file End Sub 3sample by by n1to10n1to10n1to10 dimension(first example of 3-D measurement command scripting9ýøÿÿ}Sub Main SendKeys ListVar1 ' Step 1 – display the first number ' Step 2 - Display unit of measure If ListVar4 = "inches" Then SendKeys "in." If ListVar4 = "feet" Then SendKeys "'" If ListVar4 = "millimeters" Then SendKeys "mm" If ListVar4 = "centimeters" Then SendKeys "cm" If ListVar4 = "meters" Then SendKeys "m" SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar2 ' Step 4 – display the second number ' Step 5 - Display unit of measure If ListVar4 = "inches" Then SendKeys "in." If ListVar4 = "feet" Then SendKeys "'" If ListVar4 = "millimeters" Then SendKeys "mm" If ListVar4 = "centimeters" Then SendKeys "cm" If ListVar4 = "meters" Then SendKeys "m" SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar3 ' Step 7 – display the third number ' Step 8 - Display unit of measure If ListVar4 = "inches" Then SendKeys "in." If ListVar4 = "feet" Then SendKeys "'" If ListVar4 = "millimeters" Then SendKeys "mm" If ListVar4 = "centimeters" Then SendKeys "cm" If ListVar4 = "meters" Then SendKeys "m" SendKeys " " ' Step 9 - Display a trailing space End Sub sample acnestage scripting9ýøÿSThe patient presents today with a <> case of acne on both sides of the face.sample active window titledisplay title of current window scripting9ýøÿÿ ' declare three Windows functions Declare Function GetForegroundWindow& Lib "user32" () Declare Function GetWindowTextLengthA& Lib "user32" _ (ByVal hwnd&) Declare Sub GetWindowTextA Lib "user32" _ (ByVal hwnd&, ByVal lpsz$, ByVal cbMax&) ' ' use Windows functions to obtain a string with the ' title of the current window. The string is returned ' as the value of the ActiveWindowTitle function. Function ActiveWindowTitle$() ActiveWindow = GetForegroundWindow() TitleLen = GetWindowTextLengthA(ActiveWindow) Title$ = Space$(TitleLen) GetWindowTextA ActiveWindow,Title$,TitleLen+1 ActiveWindowTitle$ = Title$ End Function ' Use the window title – in this case, display it. ' More commonly it would be compared. Sub Main MsgBox ActiveWindowTitle$ End Sub sample choose formatdialog command for formatting scripting9ýøÿÿ‘Sub Main Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1 TextBox 30,14,330,63,.TextBox1,1 OptionGroup .Group1 OptionButton 40,91,90,14,"bold",.OptionButton1 OptionButton 40,119,90,14,"underline",.OptionButton2 OptionButton 40,147,90,14,"italics",.OptionButton3 OKButton 80,175,90,21 CancelButton 230,175,90,21 End Dialog Dim dlg As UserDialog If Dialog(dlg) = -1 Then Select Case dlg.Group1 Case 0 ' bold s="^b" Case 1 ' underline s="^u" Case 2 ' italics s="^i" End Select ' Wait .5 ' let focus return SendKeys s SendKeys dlg.TextBox1 SendKeys s Else End If End Sub sample control panel appletshell commands using list scripting9ýøÿÿ¨Sub Main ' There are many of these applets. ' Some have different values in different versions of Windows. ' This sample is based on Windows-XP Professional ' The second argument to the Shell command, "vbMaximizedFocus", causes ' windows to open. If not present, then some of these Control ' Panel applets open minimized. Shell("control " & Mid(ListVar1,1,InStr(ListVar1,"\")-1),vbMaximizedFocus) End Sub sample control panel audioopen the audio applet scripting9ýøÿ1Sub Main Shell "control mmsys.cpl,,2" End Sub !sample control panel screen saveropen the screen saver applet scripting9ýøÿ0Sub Main Shell "control desk.cpl,,1" End Sub sample current mouse position+get the current mouse position in clipboard scripting9ýøÿÿ!Option Explicit Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Type POINTAPI x As Long y As Long End Type ' declare Win32 API functions Declare Function GetCursorPos Lib "user32" _ Alias "GetCursorPos" (lpPoint As POINTAPI) As Long Declare Function GetWindowRect Lib "user32" _ Alias "GetWindowRect" (ByVal hwnd As Long, _ lpRect As RECT) As Long Declare Function GetForegroundWindow& Lib "user32" () Function GetWinCurPos(hwnd As Long) As POINTAPI Dim pt As POINTAPI Dim wRect As RECT Dim result As POINTAPI GetCursorPos pt GetWindowRect hwnd, wRect result.x = pt.x - wRect.Left result.y = pt.y - wRect.Top GetWinCurPos = result End Function Sub Main Dim hwnd As Long Dim result As POINTAPI Dim clip As String hwnd = GetForegroundWindow result = GetWinCurPos(hwnd) clip = "SetMousePosition 1," & result.x & _ "," & result.y clip = clip & Chr(13) & Chr(10) & _ "ButtonClick" & Chr(13) & Chr(10) ' Clipboard clip ' MsgBox clip, 64, "Mouse Test" End Sub sample email subjects scripting9ýøÿÿ/Sub Main Dim myOlApp As Object Dim intMsgCount As Integer, intMyFoldersCount As Integer Dim myFolder As Variant Dim x As Integer Set myOlApp = CreateObject("Outlook.Application") Set myNameSpace = myOlApp.GetNamespace("MAPI") Set myFolder= myNameSpace.GetDefaultFolder(6) ' intMsgCount = myFolder.Items.Count ' Loop through each message and display the ' unread messages with MsgBox For x = 1 To intMsgCount myUnread = myFolder.Items(x).Unread If myUnread = True Then MsgBox myFolder.Items(x) End If Next x End Sub #sample Hearing