IntControl 1007

Syntax:

IntControl (1007, p1, p2, p3, p4)

 

Add/remove/check tray icon.

 

p1

Meaning

Parameters

Notes

0

Check whether tray icon has been clicked (and reset "clicked" state)

 

p2 = ignored

p3 = ignored

p4 = ignored

This function will return one of the following values:

Value Meaning

0 Not clicked

1 Left click 

2 Right click 

Note: Each time you call this function the "click state" will be reset to 0 (not clicked).

 

1

Add currently-running script to the system tray

 

p2 = 1 or 2

p3 = tool tip

p4 = icon file

p2 can be one or more of the following flags, combined with the binary OR ("|") operator:

Value Meaning

1 Hide regular WinBatch icon while the icon is in the system tray 

2 Suspend script until user clicks on the tray icon. The WinBatch script will be suspended until the user clicks on the tray icon, at which point the script will continue, and this function will return one of the click values. Otherwise, the WinBatch script will continue running, and you can periodically check to see whether the user has clicked on the tray icon by calling this function with p1 == 0.

 

2

Remove currently-running script from the system tray

p2 = ignored

p3 = ignored

p4 = ignored

 

3

Suspend script until user clicks on the tray icon

 

p2 = timeout value in milliseconds after which the script will automatically continue. If 0, there is no timeout.

p3 = ignored

p4 = ignored

This can be used at any point after a WinBatch script has already been placed in the tray. When the user clicks on the tray icon, it will return one of the click values as listed for p1 == 0.

 

4

Modify currently-running script in the system tray

 

p2 = 1 or 2

p3 = tool tip

p4 = icon resource

p2 can be one or more of the following flags, combined with the bitwise OR ("|") operator:

Value Meaning

1 Modify tool tip (p3 specifies the new tool tip) 

2 Modify icon (p4 specifies the new icon file) 

p3 can be the tool tip (i.e., string that is displayed when the mouse passes over the tray icon), or "" for none.

p4 can be icon file, or "" for the default icon. If a file name is specified, it can be a .ICL file (icon library), or an .EXE or .DLL (or similar resource file) containing icons. If it is a resource containing multiple icons, by default the first icon in the file is used.

You can specify a different icon using the following format:

"filename|#"

 

where "filename" is the name of the file, followed by a vertical bar and then the index of the desired icon in the file ("#"). The first icon in a file has an index of  0. If an invalid icon file is specified, the default icon will be used.

Note: The icon resource must contain multiple images if you want to specify an index greater than zero.

 

 

Returns @TRUE (success) or @FALSE (failure), or a click value.

 

Example:
;This intcontrol puts script in systray and hides icon on taskbar
IntControl(1007, 1, 1, "YooHoo", "")
While 1
   ;This intcontrol suspends the script until user clicks on the tray icon
   clicktype = IntControl(1007, 3, 0, 0, 0)
   Switch clicktype
      Case 1
         Pause("Notice","User LEFT clicked on icon. Press Cancel to Exit.")
         Break
      Case 2
         Pause("Notice","User RIGHT clicked on icon. Press Cancel to Exit.")
         Break
   EndSwitch
EndWhile
Exit

 

; Use .ico files to modfiy icon
icons = FileItemPath ( 'C:\Program Files\WinBatch\Icons\*.ico' )
IntControl(1007, 1, 1, '', '')
For x=1 To 10
  ico = ItemExtract( x, icons, @TAB )
  IntControl(1007, 4, 2, '', ico)
  TimeDelay(1)
Next
Exit

 

; Use a resource to modify icon
IntControl(1007, 1, 1, '', '')
For x=0 To 10

windir = DirWindows(1) Click=IntControl(1007, 4, 2, '', windir : 'Shell32.dll|' : x) TimeDelay(1) Next Exit