BigDod Posted August 2, 2005 Share Posted August 2, 2005 I am very new to this programming lark so please forgive any stupid questions I may ask. I have put together a script to control VNC but when I close it I can't delete the files automatically because vnchooks.dll is still in use. Is there any way I can make sure the dll is not in use before I close the program. The script does not remove the files, it is done by the self extractor program. My script is below, please do not laugh. expandcollapse popup#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Opt("TrayIconHide", 1) ; GUI GuiCreate("Remote Control", 200, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; PIC GuiCtrlCreatePic("logo.bmp",10,10, 180,181,$SS_SUNKEN) ; BUTTON $Button1=GuiCtrlCreateButton("Connect", 10, 250, 80, 30) $Button2=GuiCtrlCreateButton("Close", 110, 250, 80, 30) GUICtrlSetOnEvent($Button1, "ConnectButton") GUICtrlSetOnEvent($Button2, "CloseButton") ; TEXT GuiCtrlCreateLabel("Tel :- **** ******[CODE] before Connect", 10, 210, 190, 30) GUICtrlSetColor(-1,0xff0000) ; Red GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func CLOSEClicked() Run("winvnc.exe -kill") Sleep(2000) Exit EndFunc Func ConnectButton() $remote_Station = INPUTBOX("Remote Control", "Remote Control Address", "", "", -1, 120) Run("winvnc.exe -connect " & $remote_station) EndFunc Func CloseButton() Run("winvnc.exe -kill") Sleep(2000) Exit EndFunc Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Truffle Posted August 2, 2005 Share Posted August 2, 2005 (edited) You may want to look at the ProcessClose function and add it near the end of your CloseButton functionProcessClose("notepad.exe")$PID = ProcessExists("notepad.exe") ; Will return the PID or 0 if the process isn't found.If $PID Then ProcessClose($PID) Edited August 2, 2005 by Truffle Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2005 Share Posted August 2, 2005 (edited) While 1 Sleep(1000) ; Idle aroundWEndsleep(1000) is 1 full second... I have found this to be to long in an idle.. maybesleep(100)would work better8) Edited August 2, 2005 by Valuater Link to comment Share on other sites More sharing options...
BigDod Posted August 2, 2005 Author Share Posted August 2, 2005 You may want to look at the ProcessClose function and add it near the end of your CloseButton function<{POST_SNAPBACK}>Thanks for you quick answer.Run("winvnc.exe -kill") in the script is supposed to kill off the process and I added the sleep(2000) in case the program was exiting too fast for the dll to close. Can the ProcessClose function work with a dll even though it does not show in task manager Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2005 Share Posted August 2, 2005 Can the ProcessClose function work with a dll even though it does not show in task manager<{POST_SNAPBACK}>Check this; List all processes $list = ProcessList() for $i = 1 to $list[0][0] msgbox(0, $list[$i][0], $list[$i][1]) nextif it shows... then yes8) Link to comment Share on other sites More sharing options...
BigDod Posted August 2, 2005 Author Share Posted August 2, 2005 Check this; List all processes $list = ProcessList() for $i = 1 to $list[0][0] msgbox(0, $list[$i][0], $list[$i][1]) nextif it shows... then yes8)<{POST_SNAPBACK}>Thanks but it does not appear as a running process. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
herewasplato Posted August 2, 2005 Share Posted August 2, 2005 ...let me get this straight. You give someone this file/program that extracts the vncviewer and runs your AutoIt GUI. Then when your GUI closes VNC, the other program cannot clean up the VNC files "because vnchooks.dll is still in use". ...if I have the scenario correct, then I would suggest that you pick one of the following actions: 1) keep banging your head against that wall until you find what is locking the dll (in a post a while back, I think that I read about a tool that will tell you what is locking what - but I could not locate that info today) or 2) change to another flavor of VNC. I manually tested RealVNC 4.1 "free edition". I connected to a remote system. I disconnected. I manually deleted all of the files in the VNC folder without a problem. Caveats: I'm not a fan of RealVNC. Your mileage may vary.... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
HardCopy Posted August 2, 2005 Share Posted August 2, 2005 ...let me get this straight. You give someone this file/program that extracts the vncviewer and runs your AutoIt GUI. Then when your GUI closes VNC, the other program cannot clean up the VNC files "because vnchooks.dll is still in use"....if I have the scenario correct, then I would suggest that you pick one of the following actions:1) keep banging your head against that wall until you find what is locking the dll (in a post a while back, I think that I read about a tool that will tell you what is locking what - but I could not locate that info today)or2) change to another flavor of VNC.I manually tested RealVNC 4.1 "free edition".I connected to a remote system.I disconnected.I manually deleted all of the files in the VNC folder without a problem.Caveats:I'm not a fan of RealVNC.Your mileage may vary....<{POST_SNAPBACK}>Download this useful little tool.Installs tiny and available from the right click context menu.just right click on file, click wholockme and it'll tell you.http://www.dr-hoiby.com/WhoLockMe/index.phphthHardcopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
BigDod Posted August 3, 2005 Author Share Posted August 3, 2005 Many thanks to all who took the time to try and help me. I think I have solved the problem. Winvnc was not closing down properly and that was keeping vnchooks.dll active. I have modified my script to try and take care of this. I am adding my modified script in case it is of use to any less knowledgable than me in the art of programming (if that is possible). expandcollapse popup#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Opt("TrayIconHide", 1) ; GUI GuiCreate("Remote Control", 200, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; PIC GuiCtrlCreatePic("logo.bmp",10,10, 180,181,$SS_SUNKEN) ; BUTTON $Button1=GuiCtrlCreateButton("Connect", 10, 250, 80, 30) $Button2=GuiCtrlCreateButton("Close", 110, 250, 80, 30) GUICtrlSetOnEvent($Button1, "ConnectButton") GUICtrlSetOnEvent($Button2, "CloseButton") ; TEXT GuiCtrlCreateLabel("Tel :- ***** ****** before Connect", 10, 210, 190, 30) GUICtrlSetColor(-1,0xff0000) ; Red GUISetState(@SW_SHOW) While 1 Sleep(100) ; Idle around WEnd Func CLOSEClicked() Run("winvnc.exe -kill") $PID = ProcessExists("winvnc.exe"); Will return the PID or 0 if the process isn't found. If $PID Then ProcessClose($PID) Exit EndFunc Func ConnectButton() $remote_Station = INPUTBOX("Remote Control", "Remote Control Address", "", "", -1, 120) Run("winvnc.exe -connect " & $remote_station) EndFunc Func CloseButton() Run("winvnc.exe -kill") $PID = ProcessExists("winvnc.exe"); Will return the PID or 0 if the process isn't found. If $PID Then ProcessClose($PID) Exit EndFunc BTW Herwasplato Your understanding of the process is correct. I use the single click part of UltraVNC because it allows file transfer and has been modified to be used purely for reverse connection. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
BigDod Posted August 4, 2005 Author Share Posted August 4, 2005 Although I have fixed the dll active problem I now have another one. When I close the program the tray icon stays visible until I attempt to put the cursor on top of it. I know there is MouseMove command available but how do I know the position to move the cursor to as people use different screen resolutions and have various tray icons visible. Thanks in advance Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
seandisanti Posted August 4, 2005 Share Posted August 4, 2005 Although I have fixed the dll active problem I now have another one. When I close the program the tray icon stays visible until I attempt to put the cursor on top of it. I know there is MouseMove command available but how do I know the position to move the cursor to as people use different screen resolutions and have various tray icons visible.Thanks in advance<{POST_SNAPBACK}>1) you have 2 functions with the statements:Run("winvnc.exe -kill") $PID = ProcessExists("winvnc.exe"); Will return the PID or 0 if the process isn't found. If $PID Then ProcessClose($PID) Exiteither should be able to be removed. (don't feel bad, happens frequently when you change strategies mid script)2)right after your attempt to exit the program the right way run("winvnc.exe -kill") you have it kill the process if it's active... what i would suggest would be....RunWait("winvnc.exe -kill","C:\");with the directory where your winvnc is located put in for the second parameter. you may run into issues using a run()/runwait() with a parameter(if you see a second vnc pop up or if the window gets activated and doesn't do anything)if that happens, you may want to change"winvnc.exe -kill" to '"winvnc.exe -kill"'. all i did was surround the string with single quotes outside of the double quotes. Link to comment Share on other sites More sharing options...
BigDod Posted August 4, 2005 Author Share Posted August 4, 2005 Thanks I tried both the RunWait command and also removing winvnc -kill. using the RunWait the winvnc program takes around 15 seconds to close Using only the ProcessClose closes winvnc but leaves the tray icon as described in my previous post. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Zedna Posted August 4, 2005 Share Posted August 4, 2005 (edited) I think core of problem is in using Run() instead of RunWait(),so DLL is blocked because VNC isn't so quick andcode after Run() is executed immediatelly (too early).Try it and if I'm right then PID code is obsolete there. EDIT: Now I noticed, that somebody tell about RunWait before me, so sorry. Edited August 4, 2005 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
BigDod Posted August 4, 2005 Author Share Posted August 4, 2005 I think core of problem is in using Run() instead of RunWait(),so DLL is blocked because VNC isn't so quick andcode after Run() is executed immediatelly (too early).Try it and if I'm right then PID code is obsolete there. <{POST_SNAPBACK}>Does this mean there is no solution to the tray icon remaining and that I will just have to live with the 15 sec delay Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
seandisanti Posted August 4, 2005 Share Posted August 4, 2005 Does this mean there is no solution to the tray icon remaining and that I will just have to live with the 15 sec delay <{POST_SNAPBACK}>the reason the tray icon is staying, is because you're not exiting the program the right way, but instead stoppint the process. that's like ending the process in the task manager, it will have the same result. as far as the 15 seconds, that's just how long it takes for the program to exit i guess. did you try putting single quotes around your double quotes for the run('"winvnc.exe -kill"') that may do it also. personally i'd just change the line to a runwait (which you say you did) and surrounding your double quotes with single quotes on the file name to execute. also make sure to specify the working directory. Link to comment Share on other sites More sharing options...
herewasplato Posted August 5, 2005 Share Posted August 5, 2005 Does this mean there is no solution to the tray icon remaining and that I will just have to live with the 15 sec delay <{POST_SNAPBACK}>That depends, is there a "no icon" option with this VNC?You stated, "Although I have fixed the dll active problem..."What method of killing/closing VNC frees up the hooks DLL in under 15 seconds?Maybe someone at UltraVNC has a faster close method or shutdown sequence. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
BigDod Posted August 5, 2005 Author Share Posted August 5, 2005 I have tried all that was suggested but none seem to make it better. I have settled on the RunWait method as it exits cleanly (all be it slowly) and allows the program to delete the files after use. Many thanks for all your help. Maybe I should leave programming to the experts. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
BigDod Posted August 5, 2005 Author Share Posted August 5, 2005 That depends, is there a "no icon" option with this VNC?You stated, "Although I have fixed the dll active problem..."What method of killing/closing VNC frees up the hooks DLL in under 15 seconds?Maybe someone at UltraVNC has a faster close method or shutdown sequence.<{POST_SNAPBACK}>The method of killing VNC fast is the ProcessClose one which leaves the tray icon. There is no "no icon" option with VNC. I did try removing the icon with reshack and using the ProcessClose method but decided against it as it did not let people see when they were still connected to my computer. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
seandisanti Posted August 10, 2005 Share Posted August 10, 2005 Maybe I should leave programming to the experts.<{POST_SNAPBACK}>nah, 'cause if the experts had said that when they were at the same stage as you (and every single one of them was at some point) then there'd be no experts to leave it to. Link to comment Share on other sites More sharing options...
w0uter Posted August 10, 2005 Share Posted August 10, 2005 run vnc as a service and you dont have an icon My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now