Tweak Plugin DocumentationTweak Plugin by Eric Tetz, Copyright 2000.Updated on April 19, 2000 by Liquid Dust. Index
Downloads
General NotesConventions:In all the script code examples below, I use "x" in place of the plugin name. In your app, x is replaced with the name of the plugin object. All script samples are color-coded. The actual functions ("commands") that are included in the plugin, are also color-coded.Passing string parameters to the plugin Many of the plugin functions described below use string parameters. To pass a string parameter to a MMB plugin you must call PluginSet() with a string variable. Note, this means you cannot pass a string like this: PluginSet("x","This is my string!") You must first put the string into a string variable: mystring$='This is my string!' PluginSet("x","mystring$")Macro expansion Every time you pass a string to the plugin, the plugin automatically replaces <SrcDir> and <Embedded> with the correct values. I only support these right now because they seem to be the most important, but if somebody needs some other one, let me know.back to top Change Video ModesThis is a set of two functions:VidModeChange VidModeRestoreYou tell the plugin which display mode by passing it a string in the form: "WIDTH|HEIGHT|BPP"Note: BBP (Bits Per Pixel) is optional. Change to 640x480 w/ 256 colors vidmode$ = '640|480|8' PluginSet ("x","vidmode$") PluginRun ("x","VidModeChange")Restore display mode in effect at app startup: PluginRun ("x","VidModeRestore")back to top Open File DialogThis allows the plugin user to display the display the Windows "Open File" dialog. MMB let's you display this dialog, but it doesn't give a lot of flexibility, and most importantly, it stores the resulting filename in the <File> macro, which cannot be retrieved into a string variable.The following functions are included: FDSetDefaultDir - set default directory use by Open File dialog FDSetFilter - set extension filter used (same as MMB's filter) FDOpenFileDialog - displays the Open File dialog FDSaveFileDialog - displays the Save File dialog FDGetFileName - gets the full path to the file selected by the user FDGetFilePath - gets just the filename of the file selected by the userExample usage: filter$='Foo Documents|*.foo|Bar Documents|*.bar' PluginSet ("x","filter$") PluginRun ("x","FDSetFilter"); defaultdir$='<SrcDir>\Projects' PluginSet ("x","defaultdir$") PluginRun ("x","FDSetDefaultDir") PluginRun ("x","FDOpenFileDialog"); PluginRun ("x","FDGetFilePath") PluginGet ("x","path$") PluginRun ("x","FDGetFileName") PluginGet ("x","filename$");back to top Message BoxThis allows the plugin user to display the display the Windows "Message Box" dialog. MMB let's you display this dialog, but it doesn't give you complete control over it.Function name: MessageYou specify the message text, title bar text, and flags by calling PluginSet with a specially formatted string: "message text|title bar text|flags" The message text now supports the following characters, which allow for basic text formatting: \n
- New line. All the text that follows after this
character,
Note: If you want to insert a literal '\' character, you must preceed it with another slash ('\'), e.g, if you type: 'The directory called C:\\Pictures\\Recent has not been found', it will be displayed like this in the message box: 'The directory called C:\Pictures\Recent has not been found'. The flags may be combined using the '+' characters.
back to top** message box with Yes & No buttons and question mark icon message$='Would you like to register?\n\n\t\Please Do!|My Groovy App|byn+iq' PluginSet ("x","message$") PluginRun ("x","Message"); ** get the return value and act accordingly PluginGet ("x","selected$") if (selected$ = 'y') ** do registration end Registry IOThis allows you to create, delete, read and write registry keys.This is done with a set of five functions: RegistrySetRootKey RegistryCreateKey RegistryDeleteKey RegistryGetValue RegistrySetValueAll the functions require you to first call PluginSet() with a string variable to pass the function it's parameters. After calling any of the functions, calling PluginGet() with an int variable will return 1 if the operation was successful and 0 if it was not. Function descriptions: RegistrySetRootKey Sets the root key used by all the other registry functions.RegistryCreateKey Creates a new key in the registry. Can create more than one key at a time. For example, if you pass were to pass it "Software\\MyMMBApp\\UserSettings", it will create MyMMPApp and UserSettings keys (if they didn't already exist)RegistryDeleteKey Deletes a named key in the registry. Under Windows 95, the key cannot have any subkeys. Under Windows NT, any subkeys will be nuked as well. BE EXTREMELY CAREFUL WITH THIS FUNCTION!!!! I believe that if you were to pass in a zero-length string, or just forget to call PluginSet() first, you could nuke a whole branch of your registry!RegistrySetValue Set a value for any key in the registry. If the specified value name does not already exists, it will be created. Usage: Call PluginSet() with a string containing the key to set, the name of the value, and the actual value. Each part of the string is separated by the '|' character like this: "full path to the registry key|value name|value to set" If you want to set the default value for a key, just leave out the value name, like this: "full path to the registry key|value to set" For example, if you wanted to change the "Control Panel\\Desktop" key in the HKEY_CURRENT_USER branch of the registry. The full MMB script to do that would be: rootkey$='HKEY_CURRENT_USER' PluginSet("x","rootkey$") PluginRun("x","RegistrySetRootKey") setvalcmd$='Control Panel\Desktop|wallpaper|C:\Windows\Bubbles.bmp' PluginSet("x","setvalcmd$" PluginRun("x","RegistrySetValue")RegistryGetValue Get a value for any key in the registry. Usage: Call PluginSet() with a string containing the key and value name to read: "full path to the registry key|value name" If you want to get the default value for a key, just leave out the value name, like this: "full path to the registry key" For example, here's the full MMB script to read the path of the current Windows wallpaper: rootkey$='HKEY_CURRENT_USER' PluginSet("x","rootkey$") PluginRun("x","RegistrySetRootKey") setvalcmd$='Control Panel\Desktop|wallpaper' PluginSet("x","setvalcmd$" PluginRun("x","RegistryGetValue") PluginGet("x","wallpaper$") Message("","wallpaper$")back to top Tray IconAvailable tray Functions:MinimizeToTrayIconExamples: Minimize the app to the system tray icon$ = '<Embedded>\Butterfly.ico' PluginSet ("x","icon$") PluginRun ("x","MinimizeToTrayIcon")Setting the tray icon tooltip (only works while minimized) tooltip$='My MMB App' PluginSet("x","tooltip$") PluginRun("x","UpdateTrayIconTooltip")Update the icon used in the system tray (only works while minimized): iconpath$='<Embedded>\MyIcon.ico' PluginSet("x","iconpath$") PluginRun("x","UpdateTrayIcon")To find out if the app is minimized (to tray) from script: PluginRun("x","TrayIconIsMinimized") PluginGet("x","isMinimized")back to top Change ShapeYou must first create a region data file with CreateRegion.exe. You tell the plugin where the region data is at by calling PluginSet() with the filename. <SrcDir> and <Embedded> macros are supported. You then call PluginRun("PluginName","SetRegion") to apply the region to the MMB app window.Available Functions: SetRegionExample of setting the window shape: region$ = '<Embedded>\traingle.rgn' PluginSet ("x","region$") PluginRun ("x","SetRegion")Note: You can later reset the custom window shape, by using the ResetRegion() function. Example of resetting the window shape: PluginRun ("x","ResetRegion") Get Date & Timeback to topYou pass the plugin a special format string. The plugin replaces the format flags with current date and time information. See the example below. Available Date & Time Function: DateFormatFormat flags: %dw = day of the week (0=Sunday,1=Monday,etc) %d = day %mo = month %y = year %h = hour %m = minute %s = secondShow the current date & time in a message box date$='%d \%mo \%y %h:%m:%s' PluginSet("x","date$") PluginRun("x","DateFormat") PluginGet("x","date$") Message ("","date$")back to top Detect App InstancesAllows you to detect how many instances there are of any running application. You must pass the plugin the full path to the app. <Embedded> and <SrcDir> macros are supported.Available function: GetNumInstancesPreventing multiple instances (assumes your exe is named Autorun.exe) appPath$='<SrcDir>\Autorun.exe' PluginSet("x","appPath$") PluginRun("x","GetNumInstances") PluginGet("x","instances") if (instances > 1) Exit() endback to top Detect CPU Vendor & SpeedAllows you to detect the vendor of the CPU and get a close guess-timate of it's speed.Functions: CpuGetName CpuGetSpeedExample: PluginRun ("x","CpuGetName") PluginGet ("x","cpuName$") PluginRun ("x","CpuGetSpeed") PluginGet ("x","cpuMhz") message$='You have a ' + cpuName$ + ' CPU running at ' + CHAR(cpuMhz) + ' Mhz.' Message("","message$")back to top Getting Command Line ArgsAllows you to get the individual command line arguments used to start up your app.Functions: CmdLineCount - get the number of command line arguments CmdLineArg - retrieve an arg CmdLineCount returns the total number of args. The args are indexed [1 to NUMARGS]. The first arg is always the path to the app executable. If you're running in the designer, or you have compiled the app but did not create a stand-alone app, the second parameter will be the full path to the .mbd file.Example: PluginRun("x","CmdLineCount") PluginGet("x","argc") for i = 1 to argc PluginSet("x","i") PluginRun("x",CmdLineArg") PluginGet("x","arg$") message$ = 'Arg ' + CHAR(i) + ' is ' + arg$ Message ("","message$") endback to top Manipulate INI FilesAllows MMB apps to read and write INI (windows .ini) files.Available Functions: IniSetFile - set the INI file to read and write fromNOTE: After calling IniRead, IniWrite and IniDelete you can call PluginGet with an int variable to determine if the operation was successful. A return value of 0 means failure, 1 means success. The INI file format is the standard, familiar Windows INI file format
-
[SectionName]NOTE: INI file reads and writes are cached in memory to make them very fast. This means that you could do extensive reads, writes and deletes on an INI file only to open it in notepad and find no changes! Rest assured that as soon as your application exits any cached changes will get written to the file. Function Reference: IniSetFile Set the INI file to read and write from. You can also use
this function to
Usage: Call PluginSet() with the full path to the INI file,
then call
Example: inifile$ = '<Embedded>\MyApp.INI'
IniRead Read a value from a section of the INI file Usage: Call PluginSet() with a string containing the section
name and data item name
'section name|data item' Then call PluginRun("x","IniRead")
to read the data from the INI file and
Example: args$='eric|surname'
IniWrite Write a value to a section of the INI file Usage: Call PluginSet() with a string containing the section
name, data item name, and
'section name|data item|new value' Then call PluginRun("x","IniWrite") to write the value to the INI file. Example: args$='eric|surname|Tetz'
IniDelete Delete a data item OR whole section from the INI file. Usage: (to delete a single data item) Call PluginSet() with a string containing the
section name and the data item
'section name|data item' The call PluginRun("x","IniDelete") to delete the data item. Example: args$='eric|surname'
Usage: (to delete a whole section) Call PluginSet() with a string containing the
section name to delete.
Example: args$='eric'
Popup MenusAllows MMB apps to display popup menus on a left or right mouse click. It supports one popup menu for any given MMB app, but it (the menu) can change to suit the situation.Note: Popup menus may not work inside MMB-designer (it sometimes does), but it works fine in the compiled project. Available Functions: MenuReset
- clears all items off the current menu (resets the menu)
Usage of Functions: MenuReset This function clears all the current menu items. Call this to destroy all current menus, before creating a new menu. Example: ** Get rid of any previously existing menu itemsMenuAddItem This function is used to add items to the popup menu. Use this function repetitively to add as many items as you want to your menu. Note: Dividers can also be added by adding a menu item named "-". (See the example below). Example: ** Create a menu existing out of a couple of items
Call this function to show the popup menu, after the items have been added. (You can specify a x,y position, or just let it popup at the current mouse position). To get the result of the item that the user has clicked on the menu, call PluginGet("x","selected"). An integer will be returned: – 0 means failure (the user did not click on any menu item);
Example: ** Show menu and get resultsIf you want to open the popup menu at a specific position, then simply pass the X and Y positions to the plugin. You should, however, pass in the "x|y" with PluginRun() before calling MenuShow. Example: pos$ = '20|20'MenuSetHandler This function is used to make right-click-popup-menus possible, and to run a certain MMB script when a certain menu-item is selected. Usage: First create a menu, and then set a handler. The next time the user right-clicks on the MMB window, the menu is shown. After the user selects something on the menu, the handler is called. A "handler" is basically just a keystroke. You should first setup a script to handle "right-click messages". Then specify in MenuSetHandler() what hotkey activates that script. You can use any hotkey that is a valid trigger for a MMB script. For example: "X"Example: ** Tell the plugin which keystroke to send to MMB when a menu item is selected...Note: To add a right-click-popup-menu to the tray icon of your minimized app, just call MenuSetHandler() before minimizing, and you can set the handler to something for your tray icon. MenuClearHandler Call this function to clear (reset) the current active handler. By calling this function, the right-click-popup menu will become inactive. Example: PluginRun("x","MenuClearHandler")Understanding and using handlers step by step: (For New Users)
Enable Client Area DragYou can use Tweak to enable the "client area drag" and "show window contents while dragging" for the MMB window. "Client area drag" means you can drag the window by clicking anywhere, not just the title bar. "Show window contents while dragging" means your window's graphics are visible while dragging. (Normally Windows shows a drag rectange while dragging and waits until you stop dragging to repaint the window.)Available Function: EnableClientAreaDragExample: PluginRun("Tweak","EnableClientAreaDrag")back to top Change the WallpaperYou can use tweak to set the Desktop Wallpaper. You can specify a path to a bitmap image that is to be used as Wallpaper (or maybe use an open-file dialog box, so that the user can choose a bitmap file that he/she prefers (see the TweakDemo)). You can also specify if the change in Wallpaper should be permanent, or temporary (e.g. for previewing). Further more, Tweak aslo provides the ability to specify a particular style in which the Wallpaper should be displayed (centered, tiled or strethed). All of the above is achieved with the following function:SetWallpaperTo use the function, you have to pass parameters into a string, in the following form: Bitmap for Wallpaper|Bitmap Display Style|CommitThe "Commit" parameter is optional. If no "commit" value is specified, the Wallpaper will be set permanently (thus, the default for the "commit"-parameter is "1"). Example: (produces tiled permanent "bubbles" as Wallpaper) *---Set the parameters---*Or, optionally, without the "commit" parameter: (produces the same effect as script above) *---Set the parameters---*back to top Snap an MMB-application to the Desktop's edgesYou can add the ability to snap to the edges of the Windows Desktop, to your MMB-application. If the app window is moved (by the user) within a specified distance (the default is 15 pixels) from the edges of the desktop, it will snap to (align with) the edge(s) of the desktop.Available functions: EnableEdgeSnapUsage: EnableEdgeSnap & DisableEdgeSnap Simply call these functions to enable and disable the "snapping" of the application. Examples:
PluginRun("x","EnableEdgeSnap")SetEdgeSnapDistance This function is optional. It sets the distance (between the MMB-app and the edge of the Windows Desktop) that will cause the MMB-app to snap to the edge of the desktop. Please note that the value (which is always in pixels) that is passed to the plugin , is passed in the form of an integer, and not in the form of a string. Example: ***Set the snap distance to 180 pixels***GetEdgeSnapDistance This function simply returns the current "snapping distance" in pixels. If no distance was set by using "SetEdgeSnapDistance", it will return the default value of "15". Example usage: PluginRun("x","GetEdgeSnapDistance") Memory StatsThis allows the plugin user to display the Windows memory statistics. There are 7 different Stats that can be displayed. You can use these in an about box, a system memory monitor application or if you just want to know how much memory you have in your machine. Available functions: GetMemoryLoad Usage: GetMemoryLoad
Returns the percent of memory in use. Example usage: PluginRun("x","GetMemoryLoad") GetTotalPhys Returns the bytes of physical memory. Example usage: PluginRun("x","GetTotalPhys") GetAvailPhys Returns the free bytes of physical memory. Example usage: PluginRun("x","GetAvailPhys") GetTotalPageFile Returns the bytes of the paging file. Example usage: PluginRun("x","GetTotalPageFile") GetAvailPageFile Returns the free bytes of the paging file. Example usage: PluginRun("x","GetAvailPageFile") GetTotalVirtual Returns the user bytes of address space. Example usage: PluginRun("x","GetTotalVirtual") GetAvailVirtual Returns the user free bytes of address space. Example usage: PluginRun("x","GetAvailVirtual") All of the examples where you see bytes can be converted to display Megabytes (MB). Example: PluginRun("x","GetTotalPhys")
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||