Post your favorite (or coolest) script snippet here

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Post your favorite (or coolest) script snippet here

Post by Dorian (MJT support) » Tue Mar 26, 2013 12:39 am

I'm wondering, what is your favorite script snippet? It can be a whole script or just part of one.

Is there something that you fall back on regularly? If so, what is it, and what does it do?

Or is there some code you found on the forum which really helped you?

I'll go through some of my scripts and post some here, but I'd love to see some of yours. It can be as simple or complex as you like. Remember, a lot of new users look at this forum, and code snippets really help them.

Who knows, your snippets may even find their way into the help file. :)
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Tue Mar 26, 2013 4:25 am

I Have A Few Simple Ones.

Speaking Script

Code: Select all

VBSTART
Sub Speak(text)
 Dim Talk
 Set Talk = CreateObject("SAPI.SpVoice")
 Talk.Speak text
End Sub
VBEND

VBRun>Speak,Hello Keith
AppTitle & Message Size

Code: Select all

Let>APP_TITLE=
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
Expiry Based On User Account

Code: Select all

Label>AccountChk
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
RunProgram>cmd /c net user /domain allem5 | Find "Account active" > %TEMP_DIR%AcctChk.csc
Wait>0.05
IfFileExists>%TEMP_DIR%AcctChk.csc
  ReadLn>%TEMP_DIR%AcctChk.csc,1,AcctStatus
  StringReplace>%AcctStatus%, ,,AcctStatus
  StringReplace>%AcctStatus%,Accountactive,,AcctStatus
  DeleteFile>%TEMP_DIR%AcctChk.csc
Else
  Goto>AccountChk
Endif

If>{(%AcctStatus%="No") OR (%AcctStatus%="##EOF##")}
  MDL>Program Has Expired!%CRLF%%CRLF%Please Contact Michael Allen To Purchase A License.%CRLF%  Email: Blah Blah Blah%CRLF%  Mobile: 0413 392 XXX%CRLF%%CRLF%Purchase Information%CRLF%  Single User Licence = $75%CRLF%  Domain Licence = $250
  GoTo>Exit
EndIf
Expiry Based On Date

Code: Select all

//Checks Expiry
Month>the_month
Year>the_year
If>%the_year%%the_month%>201206
  MDL>Program Has Expired!%CRLF%%CRLF%Please Contact Michael Allen To Purchase A License.%CRLF%  Email: [email protected]%CRLF%  Mobile: 0413 392 169%CRLF%%CRLF%Purchase Information%CRLF%  Single User Licence = $75%CRLF%  Site Licence = $250%CRLF%  Domain Licence = $750
  GoTo>Exit
EndIf
The expiry based on user account is for when I am doing contract work for a company, I might write them something to help their task and its freeware while I am employed, once employment ceases they are expected to pay, some times its just nagware, other times it will expired.
FIREFIGHTER

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Post by Dorian (MJT support) » Tue Mar 26, 2013 11:50 pm

Discovering Macro Scheduler can create talking scripts really blew my socks off!

I like that simple little date expiry script. Sometimes the tiniest, simplest scripts can make all the difference.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Post by Dorian (MJT support) » Wed Mar 27, 2013 12:24 am

Here's a nice easy script for beginners. It shows how to retrieve details of the active window.

Code: Select all

// Window details 101

/*
This example shows how to quickly and easily retrieve the position and dimensions of the active Window.
Save this script, and assign it a hotkey.
Select the window you wish to examine, and activate the macro with the hotkey
*/

// Set the size of the results popup (optional). 
Let>MSG_HEIGHT=300
Let>MSG_WIDTH=400
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1

// Get the window name, position, and dimensions.
getactivewindow>windowname,WinX,WinY,WinW,WinH

// make a note of these numbers :
messagemodal>Window details : %CRLF%Name : %windowname%%CRLF%Coordinates : X:%WinX%  Y:%WinY%. %CRLF%Dimensions : %CRLF%Height : %WinH% %CRLF%Width : %WinW%



Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts