WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Systray Icon Questions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IntControl 1007 Slow

 Keywords:  

Question:

I have an icon in the taskbar. When you click on it a WinBatch dialog appears. However, with some users the icon is not responding: the dialog is not showing up. What could be the problem? What can I check?

#DefineFunction SysTraySetup(title, iconfile)
   IntControl(12,1,'',0,0)               ; Allow Windows to be exited with no warning.
   IntControl(54,'',1,0,0)               ; Keep window on top
   iconfile = StrCat(FilePath(IntControl(1004, 0, 0, 0, 0)),iconfile)
   rtv = 0
   rtv = IntControl(1007,1,1,title,iconfile)   ; Add currently-running script to the system tray
#EndFunction

#DefineFunction SysTraySuspend(title, mgmtpw)
   rtq = IntControl( 38, -1, '', 0, 0)  ;-- return quiet mode setting
   IntControl( 38, 1, '', 0, 0)          ;-- enable quiet mode
   While @TRUE
      rtv = IntControl(1007,3,0,title,'')     ; Suspend script until user clicks on the tray icon
      If rtv > 0 Then Break
   EndWhile
   IntControl( 38, rtq, '', 0, 0)  ;-- restore quiet mode

   If rtv == 2
         IntControl(72,2,0,0,0)
         answer = AskYesNo(title,'Terminate program ?')
         If answer == @YES
            rtv = AskPassword (title, 'Geef wachtwoord')
               If rtv == mgmtpw
                  rtv = IntControl(1007,2,2,title,'')     ; Remove currently-running script from the system tray
               Exit
            EndIf
         EndIf
   EndIf
   Return
#EndFunction


SysTraySetup('title','')
While @TRUE
   Message('hello','there')
   SysTraySuspend('title','master')
EndWhile
Exit

Answer:

Not sure what could be happening. Please post the code. Maybe the code doesn't properly handle waiting for the mouse click.

You could try creating a click detection loop with a short delay instead of having the IntControl suspend the script

;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, 0, 0, 0, 0) ;;;;;;;;; does not suspend script
   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

   TimeDelay(.25)     ;;;;;;;;; suspend here instead.
EndWhile

User Reply:

Yes, now I have an immediate response, very nice. But what is the difference between IntControl(1007, 0, 0, 0, 0) and IntControl(1007, 3, 0, 0, 0) ? And what is the function of the TimeDelay ? I tried without it and that works as well.

Answer:

It gets complicated but the '3' option causes a specially designed message pump to execute. The '0' option causes the IntControl to just checks for mouse button activity.

The TimeDelay prevents WinBatch from consuming excessive CPU time while still being able to record mouse events. Check the amount of CPU used by WinBatch with Task Manager when the TimeDelay is not used.


Article ID:   W18295
Filename:   IntControl 1007 Slow.txt
File Created: 2010:12:13:10:56:56
Last Updated: 2010:12:13:10:56:56