forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


refreshing the system tray?!?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
waldrondigital
Newbie


Joined: 01 Mar 2006
Posts: 1

PostPosted: Wed Mar 01, 2006 3:24 am    Post subject: refreshing the system tray?!? Reply with quote

Hello,

I am new to VDS and am a network systems engineer by trade, so my programming skills are a bit rusty - so excuse me if this is obvious and completely stupid.

---

I'm working with a program that calls an app that lives in the system tray when it's active. I'm using KILLTASK to kill the task before my app closes, but it leaves an icon in the system tray after my app's closed and the task has been killed. If you hover the mouse over the tray, it 'refreshes' and the icon disappears....

How can I emulate this behavior with VDS and refresh the system tray? Would it be easier to emulate a mouse movement or something?

PLEASE INCLUDE CODE SNIPPETS IF POSSIBLE...

Here's my code
:Close
IF @ASK(Exiting will terminate all remote connections. Continue?)
ELSE
goto evloop
END
runh %W\wds\WINVNC4.EXE -disconnect
KILLTASK WINVNC4.EXE
rem System Tray refresh code goes here

:Close2
EXIT
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Mar 03, 2006 3:49 am    Post subject: Reply with quote

Welcome to VDSWorld WD.
I'm not sure of a good way to make the actual SysTray refresh in VDS, but you can make the mouse cursor move along it like you would manually, to get the icon to disappear.
Try the code below, it should pass the mouse cursor along the icon you want to go away, and then put it back where it was.
Code:

REM Load the API DLL to use SetCursorPos
LOADLIB user32.dll
REM Get Mouse Pos to put the cursor back later
%%MouseX = @MOUSEPOS(X)
%%MouseY = @MOUSEPOS(Y)
REM Put mouse half way down from the top of the SysTray
%%TrayTop = @winpos(@winexists(#Shell_TrayWnd),T)
%%TrayHeight = @winpos(@winexists(#Shell_TrayWnd),H)
%%TrayTop = @fadd(%%TrayTop,@fdiv(%%TrayHeight,2))
REM Get the width of the desktop
%%TrayLeft = @SYSINFO(SCREENWIDTH)
REM Move the mouse from the right of the screen, to 150 pixels to the left
repeat
  REM Move left in 25 pixel increments
  %%TrayLeft = @fsub(%%TrayLeft,25)
  REM Call the SetCursorPos API
  %P = @LIB(user32,SetCursorPos,INT:,%%TrayLeft,%%TrayTop)
  REM Wait a bit to let the move register
  wait 0.05
until @equal(%%TrayLeft,@fsub(@SYSINFO(SCREENWIDTH),150))
REM Put Mouse Back
%P = @LIB(user32,SetCursorPos,INT:,%%MouseX,%%MouseY)
exit

If you have any questions about it, let me know.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Mar 03, 2006 11:17 am    Post subject: Reply with quote

wow

I was trying to do this a few months ago and gave it up, thanks SnarlinSheep Very Happy Thanks...

I have another mouse question for you below: Idea
@MOUSEDOWN will only work inside your dialog window or your VDS homemade program window! know how to emulate @MOUSEDOWN ?

Just curious
Back to top
View user's profile Send private message Visit poster's website
henrywood
Contributor
Contributor


Joined: 21 Sep 2004
Posts: 66
Location: Copenhagen, Denmark

PostPosted: Fri Mar 03, 2006 12:55 pm    Post subject: A possible solution to @mousedown Reply with quote

Hi !

You may be able to circumveint this limitation of @mousedown using codescript's JustGreatWindow example, and thus drawing a fullscreen transparent VDS dialog in which the @mousedown is registered ?

Please look for the example script at codescript.vdsworld.com under Source code


Henrik
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Mar 03, 2006 4:28 pm    Post subject: Reply with quote

With a transparent window, you'd steal the mouse clicks away from other apps, unless you figured out how to pass the click to the next window in order.
The only other way is to hook the mouse to catch it's messages before they are sent to other windows, but you can't do that with VDS.
Thanks to Microsoft, it'd be kinda hard to make into a VDS extension too.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
henrywood
Contributor
Contributor


Joined: 21 Sep 2004
Posts: 66
Location: Copenhagen, Denmark

PostPosted: Mon Mar 06, 2006 11:17 pm    Post subject: Reply with quote

If I remember, CodeScript mentions on his site that the JustGreatWindow example (and *NOT* the transparent window example) is a transparent and work-thru window so I just figured has a way to go ?


Henrik
Back to top
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Tue Mar 07, 2006 9:13 am    Post subject: Reply with quote

I used to use a macro program called Macro Scheduler, and it was kinda like VDS in a way, but it could do it, so maybe its easier than we think for VDS to be able to do it, it sure would be handy at times.
Nice wish lister I guess... Thanks
Back to top
View user's profile Send private message Visit poster's website
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Tue Apr 11, 2006 3:55 pm    Post subject: Reply with quote

This works for me in closing stubborn tray icons - especially for non-VDS applications.

Code:
 
  window close,#ClassName
  wait 0.1
  killtask appname.exe


I even wrote a small command line exe that uses 2 parameters.

Code:

 OPTION DECIMALSEP, "."

  title TopKiller Usage
  if @not(%1)
    info You need to run TopKiller with 1 or 2 parameters.@cr()Parameter 1 is the name of the exe to kill.@cr()Parameter 2 is the class name of the window to kill.@cr()@cr()         Example:  topkiller ftp4t.exe TfMain@cr()@cr()You can run topkiller with only the 1st parameter@chr(44) but to@cr()use the 2nd parameter you need to include 2 parameters.     ,
  end

  title TopKiller
  if %2
    window close,#%2
    wait .1
  end
  if %1
    killtask %1
    wait .1
  end
  if %2
    window close,#%2
    wait .1
  end
  if %1
    killtask %1
    wait .1
  end
  exit


I like to kill things twice as sometimes once does not work.

_________________
cheers

Dave
Back to top
View user's profile Send private message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Wed Apr 12, 2006 1:41 am    Post subject: Reply with quote

That looks great, but I was allways afraid if I used killtask maybe the
exe would leave some LISTs open or maybe a child window, is this
good practice, safe or niether?
I've really not thought about it much. Rolling Eyes

Snarling Sheep, you could also create a 1x1 pixel CURSOR for your
example, then the MouseGlide would run unnoticed(I'd use a silverish
colored pixed), transparent or a way to make it hidden is another posiblity.
Just an idea. Idea
Back to top
View user's profile Send private message Visit poster's website
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Wed Apr 12, 2006 6:41 am    Post subject: Reply with quote

vtol wrote:
That looks great, but I was allways afraid if I used killtask maybe the exe would leave some LISTs open or maybe a child window, is this good practice, safe or niether?
I've really not thought about it much. Rolling Eyes


Yep, using killtask is why some tray icons get left behind (and who knows what else). If someone used killtask on a couple of my applications there'd be a horrible mess left behind. Though I do conditionally clean things up when it starts, just in case it previously didn't close cleanly.

I guess this is where "Window Close" should be used on the main window instead of killtask. Maybe followed by a @sendmsg if the application asks "are you sure you want close?".

_________________
cheers

Dave
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group