MTM2.com

A forum for mtm2 discussion
FAQ :: Search :: Members :: Groups :: Register
Login
It is currently Fri Nov 22, 2024 11:20 am



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Automation/Macro Utilities
PostPosted: Thu Nov 10, 2005 2:30 pm 
Member
User avatar

Joined: Sat Feb 26, 2000 2:01 pm
Posts: 0
There are a lot of macro/automation tools out there that record key presses and mouse movements in order to quickly or automatically perform routine tasks. I've discovered an easy to use one that performs better than most -- Script It, published by Microsoft years ago (1998) as freeware.

You use it by creating a step by step text script for it to follow, which is easy enough for anyone to do. It can run programs or command lines and send keystrokes to various windows. Some benefits are that it enters keystrokes based on a window's title rather than just running a timed sequence as other programs do -- which can foul up if something on the screen is not as expected or the timing is off. It's also executes commands blazingly fast.

It's an EXE that runs a text file containing a script, you launch it with a shortcut or batch file with a command line like the following.

C:\Utilities\ScriptIt\SCRIPTIT.EXE actfast.ini

You can name your script file anything you like, with any extension, as long as you instruct scriptit.exe to run it as demonstrated.


Simple script examples:

The following script would launch Notepad and then type a phrase in the Notepad window:

[SCRIPT]
run=C:\WINDOWS\Notepad.exe
Untitled - Notepad=Hello there.


The run command points to the program or command to run. The second line names the window by title, which by default is "Untitled - Notepad" (case sensitive), and tells what keystrokes to send to that window, which in this case is "Hello there." The end result is a notepad window on your screen containing the words "hello there".


Taking the concept a bit further:

[SCRIPT]
run=C:\WINDOWS\Notepad.exe
Untitled - Notepad=Hello there.##
Untitled - Notepad={ALT}f
Untitled - Notepad=a
Save As=c:\desktop\hello.txt
Save As={ENTER}
hello.txt - Notepad=!{F4}


Line 1) Notepad is launched.
Line 2) The phrase is typed then "##" inserts a five second delay before the next command is executed.
Line 3) The ALT key is pressed followed by F, to bring up the file menu.
Line 4) The A key is pressed (in the File menu), prompting the "Save As" dialog box.
Line 5) A directory path and filename is typed into the "Save As" window.
Line 6) The enter key is pressed in the "Save As" window, saving the file.
Line 7) The Notepad window title has changed, an Alt-F4 key combo closes the window (!=alt).

The end result is a saved text file, created by a simple step by step script. Easy, eh?


The reason I sought out such a program was to automatically switch video modes without requiring a program always running in the background. Some "recording" type of macros I tried failed at times or were too slow, while ScriptIt gave me what I needed faster than I could follow it on screen.

A little known way to launch the "Display Properties" dialog with the "Settings" tab already selected (to change screen resolution, color depth, etc.) is to use the following command line in a shortcut (in Win98 at least):

C:\WINDOWS\RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3

By running that command with ScriptIt and then supplying the proper sequence of keystrokes that follow you can change the screen resolution or even manipulate the advanced video card properties.

I wrote the following script to change my screen resolution then switch my video card into TV out mode (to play games on a TV screen). A commandline is launched to bring up the the first window then keystrokes are sent to the various windows by name. The TAB key is used to cycle through the menus and the SPACE key is used to activate selected buttons.

[SCRIPT]
run=C:\WINDOWS\RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3
Display Properties={TAB 2}
Display Properties={SP}
Rage 128 Properties={TAB 5}
Rage 128 Properties={UP}
Rage 128 Properties={TAB 5}
Rage 128 Properties={SP}
Rage 128 Properties={TAB 3}
Rage 128 Properties={SP}
ATI Property Page={TAB}
ATI Property Page={SP}
Rage 128 Properties={ESC}
Display Properties={TAB 5}
Display Properties={LEFT 5}
Display Properties={RIGHT 3}
Display Properties={TAB 2}
Display Properties={SP}
Display Properties={SP}
Monitor Settings={TAB}
Monitor Settings={SP}



Each key was given it's own line in the script and when you see a number following the key it indicates the key is pressed that many times. That script is not written as efficiently as it could be but it's easy to follow and is probably the best way to first write one. It can be shortened to the following, where the "#" sign separates keystrokes sent to the same window.

[SCRIPT]
run=C:\WINDOWS\RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3
Display Properties={TAB 2}#{SP}
Rage 128 Properties={TAB 5}#{UP}#{TAB 5}#{SP}#{TAB 3}#{SP}
ATI Property Page={TAB}#{SP}
Rage 128 Properties={ESC}
Display Properties={TAB 5}#{LEFT 5}#{RIGHT 3}#{TAB 2}#{SP}#{SP}
Monitor Settings={TAB}#{SP}


That script is only useful to me but I think it serves as a good visual example. In actual fact that script is what turns off my TV mode and resets the screen to my preferred resolution.


Downloads and info:

From Microsoft, you can download ScriptIt HERE and read about it HERE.

I recommend you read more about ScriptIt (and find another download link) HERE.

Funnily enough ScriptIt is actually a compiled WinBatch script (a commercial third-party tool).


Also, if you like the idea of ScriptIt and you wish to go much further with it you should probably use the similar and up to date freeware program called Auto It. It does much more but it can also be more difficult to use. Advanced users would do well to use it instead.


Macros discussed previously:
http://mtm2.com/~mtmg/special/macros/
http://mtm2.com/~mtmg/special/macros/examples.html
http://forum.mtm2.com/viewtopic.php?t=2803


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 2:43 pm 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
When I was doing truckshots, I needed something to trigger and work from inside the game. Launching a batch file was not an option. However, the points about targeting windows is a good one.

Win xp display properties...

C:\WINDOWS\system32\rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 4:41 pm 
Member
User avatar

Joined: Sat Feb 26, 2000 2:01 pm
Posts: 0
You used the right tool for the job, and a clever job it was. Script It is somewhat simplistic and best suited to a basic windows environment, with windows and dialog boxes and such -- due to the fact that window names and keystrokes are it's specialty (and it's limitation, you might say). For the casual user I'd say Scriptit is best for various configuration changes, such as changing video settings, toggling browser settings, quickly navigating to a particular tab deep in a particular program, etc. It couldn't be more perfect for what I wanted it for -- an instant and error free video mode change that otherwise required multiple steps to accomplish, while being small, free and requiring nothing resident in memory.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 5:22 pm 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
I wasn't being critical or anything.

One task I have that I wouldn't mind automating is enabling and disabling cookies, and javascript too, in the browser. Perfect Keyboard would make a mess of something like that.

Another task I've done is to convert mtm1 trk files to mtm2. I'm pretty sure ScriptIt could do that if you can also ignore window names.

As for speed, I found Perfect Keyboard to be too fast sometimes and I had to build in wait stages.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 7:18 pm 
Member
User avatar

Joined: Sat Feb 26, 2000 2:01 pm
Posts: 0
No criticism was perceived, I was just trying to emphasize what might work best in a given situation, and to highlight ScriptIt's flaws. As for the hard sell, or even being here at all, it's just the result of being happy about finding the exact solution I'd been wanting. ;)

As for web browser work, that was just about the only other thing I could think to use it for but I haven't done so yet. The key is you'd have to start with a fresh instance of the browser or launch a fixed page in the browser so that the title bar says what you want it to say, so you can target the window by name and manipulate the menus, and all menu options would have to be navigable by keyboard alone.

I don't think it can ignore window names, monitoring and acting on window names seems to be it's core function.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 5:21 am 
Member

Joined: Sun Sep 08, 2002 2:01 pm
Posts: 205
Location: Switzerland
Quote:
Script It, published by Microsoft years ago (1998) as freeware

sounds interesting.
Where can you get it?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 5:42 am 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
This works

[pre][SCRIPT] REM Netscape=~winwaitactive Netscape={ALT}e Netscape=e## Preferences={p 3}## Preferences={RIGHT}## Preferences={DOWN}## Preferences={TAB}## Preferences={UP 3}## Preferences=+{TAB}## Preferences=a## Preferences={RIGHT}## Preferences=s## Preferences={TAB}## Preferences={SP}## Preferences={TAB 4} Preferences={ENTER} [/pre]

This doesn't

[pre][SCRIPT] REM Netscape=~winwaitactive Netscape={ALT}e Netscape=e Preferences={p 3} Preferences={RIGHT} Preferences={DOWN} Preferences={TAB} Preferences={UP 3} Preferences=+{TAB} Preferences=a Preferences={RIGHT} Preferences=s Preferences={TAB} Preferences={SP} Preferences={TAB 4} Preferences={ENTER} [/pre]

I tried alternate key-combos but if it doesn't get terribly delayed, since there's nothing under five seconds, it just goes all over the place.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 9:10 pm 
Member
User avatar

Joined: Sat Feb 26, 2000 2:01 pm
Posts: 0
Where can you get it? Here.

>> This works / This doesn't

[bump]

Sorry. Such delays are too much. I've now tried to disable scripting in my browser and it failed to work in two different ways. So much for ScriptIt, I guess there could be a lot of problems with the 'focus' timing in a lot of windows.

I tried a different method for browser setting changes - tracking the registry changes and making a reg file (using regedit /s to install it silently). It works but it requires a new instance of the browser for the changes to register properly (unlike when using the browser itself for the changes).


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 12, 2005 7:32 am 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
Netscape saves preferences in a file, not the registry.

What I did for browser focus was drag the shortcut to the taskbar. It seemed to work as far as that went. No open window problems.

When using perfect keyboard, I had to build in wait periods almost all the time. The advantage there was that you could go as short as 1 millisecond or as long as several seconds. I haven't tried to design anything with it for browser settings because, like you note, I don't want anything running in the background that doesn't need to be. That's why I was tempted into trying script it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group