If something seems wrong or incomplete, please enter a comment at the bottom of this page.
- source - main - QA - jswinshell module
jswinshell static members- top - revision - Static functionsExtractIconIcon ExtractIcon( fileName [, iconIndex ] )
Retrieves an icon from the specified executable file, DLL, or icon file.
The function returns undefined if no icon is found.
beware:
This function is not supported for icons in 16-bit executables and DLLs.
MessageBoxinteger MessageBox( content [, caption [, style ] ] )
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information.
The message box returns an integer value that indicates which button the user clicked.
arguments:
- string content: the message to be displayed.
- string caption: the dialog box title.
- integer style: specifies the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags:
- MB_ABORTRETRYIGNORE
- MB_CANCELTRYCONTINUE
- MB_HELP
- MB_OK
- MB_OKCANCEL
- MB_RETRYCANCEL
- MB_YESNO
- MB_YESNOCANCEL
- MB_ICONEXCLAMATION
- MB_ICONWARNING
- MB_ICONINFORMATION
- MB_ICONASTERISK
- MB_ICONQUESTION
- MB_ICONSTOP
- MB_ICONERROR
- MB_ICONHAND
- MB_DEFBUTTON1
- MB_DEFBUTTON2
- MB_DEFBUTTON3
- MB_DEFBUTTON4
- MB_APPLMODAL
- MB_SYSTEMMODAL
- MB_TASKMODAL
- MB_DEFAULT_DESKTOP_ONLY
- MB_RIGHT
- MB_RTLREADING
- MB_SETFOREGROUND
- MB_TOPMOST
return value:
- IDABORT: Abort button was selected.
- IDCANCEL: Cancel button was selected.
- IDCONTINUE: Continue button was selected.
- IDIGNORE: Ignore button was selected.
- IDNO: No button was selected.
- IDOK: OK button was selected.
- IDRETRY: Retry button was selected.
- IDTRYAGAIN: Try Again button was selected.
- IDYES: Yes button was selected.
- 32000: timeout ???
CreateProcessvoid CreateProcess( applicationPath , [ commandLine ], [ environment ], [ currentDirectory ] )
Creates a new process.
arguments:
- string applicationPath
- string commandLine
- string environment
- string currentDirectory
example:
CreateProcess( 'C:\\WINDOWS\\system32\\calc.exe', undefined, undefined, 'c:\\' ); FileOpenDialogstring | undefined FileOpenDialog( [ filters ] [, defaultFileName ] )
Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file. The function returns undefined if the dialog is canceled.
example:
FileOpenDialog( 'executable files|*.exe;*.com;*.cmd;*.bat|all files|*.*' ); ExpandEnvironmentStringsstring ExpandEnvironmentStrings( sourceString )
Expands environment-variable strings and replaces them with the values defined for the current user.
Sleepvoid Sleep( milliseconds )
Suspends the execution of the current process until the time-out interval elapses.
MessageBeepvoid MessageBeep( type )
Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.
arguments:
- integer type:
- -1 : Simple beep. If the sound card is not available, the sound is generated using the speaker.
- 0 : MB_OK SystemDefault
- ICONASTERISK: SystemAsterisk
- ICONEXCLAMATION: SystemExclamation
- ICONHAND: SystemHand
- ICONQUESTION: SystemQuestion
Beepvoid Beep( hertzFrequency, millisecondsDuration )
Generates simple tones on the speaker.
note:
The function is synchronous, it does not return control to its caller until the sound finishes.
RegistryGetvoid RegistryGet( path )
Get a value of the system registry
Static propertiesclipboardstring clipboard
Places or retrieves text data from the clipboard.
class jswinshell::Console- top - revision - constructorconstructor()
Creates a new Console object.
beware:
Only one console per process is allowed. The construction fails if the calling process already has a console.
MethodsClosevoid Close()
Detach the current process from its console.
Writevoid Write( text )
Write text to the console.
arguments:
- string text
Readstring Read( amount )
Read amount bytes of text from the console.
arguments:
- integer amount
Propertiestitlestring title
Get or set the title of the console window.
Examplesvar cons = new Console();
cons.title = 'My console';
cons.Write('Hello world');
class jswinshell::WinError- top -
class jswinshell::Icon- top - revision - constructorconstructor( image | integer )
Icon constructor accepts an Image object or a integer.
The integer value can be one of:
- 0: IDI_APPLICATION
- 1: IDI_QUESTION
- 2: IDI_INFORMATION
- 3: IDI_WARNING
- 4: IDI_ERROR
class jswinshell::Systray- top - revision - constructorconstructor()
Creates a Systray object.
MethodsClosevoid Close()
Close the Systray.
ProcessEventsboolean ProcessEvents()
Precess all pending events of the systray.
The function returns true if at least one of the event function ( see Remarks below ) returns true.
Focusvoid Focus()
Puts the systray into the foreground. Keyboard input is directed to the systray.
PopupMenuvoid PopupMenu()
Opens the systray menu.
PositionArray Position( [reusableArray] )
Returns the [x,y] position pointed by the mouse pointer in the systray icon.
note:
If you provide a reusableArray, the function will use it to store the values.
example:
systray.onmousemove = function( x, y ) {
var pos = systray.Position();
Print( x-pos[0], ', ', y-pos[1], '\n' );
} RectArray Rect( [reusableArray] )
Returns the dimensions [left, top, width, height] of the systray rectangle.
note:
If you provide a reusableArray, the function will use it to store the values.
PropertiesiconIcon | null icon write-only
This is the Icon to be used as systray icon.
visibleboolean visible write-only
Show or hide the systray icon.
beware:
you cannot use this property to get the current visibility of the icon.
textstring text
Get of set the tooltip text of the systray icon.
menuObject menu
The object is a key:value map of all available commands in the menu.
each command has an single keyName and a description object that hole the following properties:
- string | function text
- boolean | function checked
- boolean | function grayed
- boolean separator
- boolean default
- [Icon] | function icon
example:
tray.menu = {
my_ena:{ text:"enable", checked:true },
my_add:{ text:"delete", grayed:true },
sep1:{ separator:true },
my_exit:"Exit"
};
If the value of text, checked, grayed or icon is a function, it is called and the return value is used.
example:
tray.menu = { ena:{ text:"enable", checked:function() { return isChecked } }, ...
Callback functionsThe following functions are called when you call ProcessEvents() according the events received by the tray icon.
- onfocus( true )
- onblur( ALSE )
- onchar( string char )
- oncommand( string id, integer mouseButton )
- onmousemove( integer mouseX, integer mouseY )
- onmousedown( integer mouseButton, true )
- onmouseup( integer mouseButton, ALSE )
- onmousedblclick( integer mouseButton )
example:
var s = new Systray();
s.icon = new Icon( 0 );
s.onmousedown = function( button ) {
MessageBeep();
s.PopupMenu();
} Examplesexample 1:
var s = new Systray();
s.icon = new Icon(new Png(new File('calendar.png').Open(File.RDONLY)).Load());
s.text = "calendar";
s.menu = { exit_cmd:"exit" }
s.onmousedown = function(button) {
if ( button == 2 )
s.PopupMenu();
}
s.oncommand = function(id) {
if ( id == 'exit_cmd' )
exit = true;
}
while ( !exit ) {
s.ProcessEvents();
Sleep(100);
}
example 2:
LoadModule('jsstd');
LoadModule('jswinshell');
var s = new Systray();
s.icon = new Icon( 0 );
s.menu = { add:'Add', exit:'Exit', s1:{ separator:true } };
s.onmousedown = function( button ) {
s.PopupMenu();
}
s.oncommand = function( id, button ) {
switch ( id ) {
case 'exit':
return true;
case 'add':
var fileName = FileOpenDialog( 'executable files|*.exe;*.com;*.cmd;*.bat|all files|*.*' );
if ( !fileName )
return;
var icon = ExtractIcon( fileName );
var text = fileName.substr( fileName.lastIndexOf( '\\' ) + 1 );
s.menu[fileName] = { icon:icon, text:text };
break;
default:
if ( button == 1 )
CreateProcess( id );
else
if ( MessageBox( 'Remove item: ' + id + '? ', 'Question', MB_YESNO) == IDYES )
delete s.menu[id];
}
}
do { Sleep(100) } while ( !s.ProcessEvents() );
- top - main -
|