My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
jswinshell  
jswinshell module
doc
Updated May 31, 2009 by sou...@gmail.com

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 functions

ExtractIcon

Icon 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.

MessageBox

integer 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:
  1. string content: the message to be displayed.
  2. string caption: the dialog box title.
  3. 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 ???

CreateProcess

void CreateProcess( applicationPath , [ commandLine ], [ environment ], [ currentDirectory ] )
Creates a new process.
arguments:
  1. string applicationPath
  2. string commandLine
  3. string environment
  4. string currentDirectory
example:
 CreateProcess( 'C:\\WINDOWS\\system32\\calc.exe', undefined, undefined, 'c:\\' );

FileOpenDialog

string | 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|*.*' );

ExpandEnvironmentStrings

string ExpandEnvironmentStrings( sourceString )
Expands environment-variable strings and replaces them with the values defined for the current user.

Sleep

void Sleep( milliseconds )
Suspends the execution of the current process until the time-out interval elapses.

MessageBeep

void MessageBeep( type )
Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.
arguments:
  1. 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

Beep

void 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.

RegistryGet

void RegistryGet( path )
Get a value of the system registry

Static properties

clipboard

string clipboard
Places or retrieves text data from the clipboard.

class jswinshell::Console

- top - revision -

constructor

constructor()
Creates a new Console object.
beware:
Only one console per process is allowed. The construction fails if the calling process already has a console.

Methods

Close

void Close()
Detach the current process from its console.

Write

void Write( text )
Write text to the console.
arguments:
  1. string text

Read

string Read( amount )
Read amount bytes of text from the console.
arguments:
  1. integer amount

Properties

title

string title
Get or set the title of the console window.

Examples

var cons = new Console();
cons.title = 'My console';
cons.Write('Hello world');

class jswinshell::WinError

- top -


class jswinshell::Icon

- top - revision -

constructor

constructor( 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 -

constructor

constructor()
Creates a Systray object.

Methods

Close

void Close()
Close the Systray.

ProcessEvents

boolean 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.

Focus

void Focus()
Puts the systray into the foreground. Keyboard input is directed to the systray.

PopupMenu

void PopupMenu()
Opens the systray menu.

Position

Array 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' );
  }

Rect

Array 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.

Properties

icon

Icon | null icon write-only
This is the Icon to be used as systray icon.

visible

boolean visible write-only
Show or hide the systray icon.
beware:
you cannot use this property to get the current visibility of the icon.

text

string text
Get of set the tooltip text of the systray icon.

menu

Object 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 functions

The 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();
 }

Examples

example 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 -


Sign in to add a comment
Powered by Google Project Hosting