Amerigo Posted August 13, 2008 Posted August 13, 2008 Dear Sir or Ma'am,Perhaps you can help with this script?I want it to open WordWeb whether or not it is already in the system tray. I use Responding Heads to run AutoIt Scripts. If you can convert this to VB for RH to use without AutoIt, that would be even better.Opt("WinTitleMatchMode",2) If WinActive("WordWeb") Then ~~~(this probably won't work because its not active if in the system tray?)Send("^%W") ~~~(cntl+alt+W)Else run "C:\Program Files\WordWeb\wweb32.exe" ~~~(error here. Run command???)Sleep(10000) ~~~(time it takes to load???)Send("^%W") End IfThank you so much,Amerigo
ReDucTor Posted August 13, 2008 Posted August 13, 2008 http://www.autoitscript.com/autoit3/docs/f...ocessExists.htmTry process exists insteadIf ProcessExists ("wweb32.exe") == 0 Then run("C:\Program Files\WordWeb\wweb32.exe") sleep(100)EndIfSend("^!w")
MHz Posted August 14, 2008 Posted August 14, 2008 You have a tray executable and a no tray executable and also window states to consider. I chose the cover all known scenarios.; path to webword directory$ww_path = @ProgramFilesDir & '\WordWeb'; WordWeb NoTray executable$exe_notray = 'wwnotray.exe'; WordWeb Tray executable$exe_tray = 'wweb32.exe'; main window title$title = '[CLASS:TTHeDi]'Select Case WinActive($title) ; nothing to do Exit Case ProcessExists($exe_notray) And Not WinActive($title) ; restore and activate the window WinSetState($title, '', @SW_RESTORE) WinActivate($title) Case ProcessExists($exe_tray) And Not WinActive($title) ; run tray exe to activate the window _RunWordWeb($exe_tray) Case Else ; no process running so choose $exe_notray or $exe_tray to run _RunWordWeb($exe_tray)EndSelectExitFunc _RunWordWeb($file) ; check to ensure the file to run is available, else return if not If Not FileExists($ww_path & '\' & $file) Or $file = '' Then Return SetError(1) EndIf Switch $file Case $exe_notray ; run no tray exe to show window Run('"' & $ww_path & '\' & $exe_notray & '"') ; wait for the window and then activate it WinWait($title, '', 5) WinActivate($title) Case $exe_tray ; run instances of tray exe until the window is active Do Run('"' & $ww_path & '\' & $exe_tray & '"') If Not ProcessExists($exe_tray) Then ; something is incorrect so return from this function Return SetError(2) Else Sleep(250) ; activate the window WinActivate($title) EndIf Until WinActive($title) EndSwitchEndFuncStarting a 2nd instance of the tray process seems to bring up the window so I chose that idea rather then the hotkey idea.Note that the keyword "Else" likes it's own line in AutoIt3 except for "Case Else" as to your code error. Also "End If" needs to be "EndIf".
Amerigo Posted August 14, 2008 Author Posted August 14, 2008 Thanks to both of you.MHz, I like the way you think. Covering all the bases.However, there is a glitch somewhere. I tried it with WordWeb completely off, and it worked, and worked, and worked.....It seems to have gotten caught in a loop where it tries to keep opening WordWeb.
MHz Posted August 14, 2008 Posted August 14, 2008 It seems to have gotten caught in a loop where it tries to keep opening WordWeb.Sorry. My results are different for some reason.This will use the Ctrl+Alt+w hotkey; path to webword directory$ww_path = @ProgramFilesDir & '\WordWeb'; WordWeb NoTray executable$exe_notray = 'wwnotray.exe'; WordWeb Tray executable$exe_tray = 'wweb32.exe'; main window title$title = '[CLASS:TTHeDi]'Select Case WinActive($title) ; nothing to do Exit Case ProcessExists($exe_notray) And Not WinActive($title) ; restore and activate the window WinSetState($title, '', @SW_RESTORE) WinActivate($title) Case ProcessExists($exe_tray) And Not WinActive($title) ; run tray exe to activate the window _RunWordWeb($exe_tray) Case Else ; no process running so choose $exe_notray or $exe_tray to run _RunWordWeb($exe_tray)EndSelectExitFunc _RunWordWeb($file) ; check to ensure the file to run is available, else return if not If Not FileExists($ww_path & '\' & $file) Or $file = '' Then Return SetError(1) EndIf Switch $file Case $exe_notray ; run no tray exe to show window Run('"' & $ww_path & '\' & $exe_notray & '"') If Not @error Then ; wait for the window and then activate it WinWait($title, '', 5) WinActivate($title) EndIf Case $exe_tray ; run tray exe Run('"' & $ww_path & '\' & $exe_tray & '"') If Not @error Then ; wait for hidden tray icon window WinWait('WordWeb Tray Icon', '', 5) Sleep(500) ; if the window is not active, then use the hotkey If Not WinActive($title) Then WinActivate($title) Send('^!w') EndIf EndIf EndSwitch Sleep(500) ; another attempt to activate the window if needed If Not WinActive($title) Then WinActivate($title) EndIfEndFuncIf you wish, you can run the no tray executable instead by changing the parameter of _RunWordWeb() in the Case Else part which shows a window which behave like a normal window.before: Case Else ; no process running so choose $exe_notray or $exe_tray to run _RunWordWeb($exe_tray)EndSelectafter: Case Else ; no process running so choose $exe_notray or $exe_tray to run _RunWordWeb($exe_notray)EndSelect
Amerigo Posted August 14, 2008 Author Posted August 14, 2008 It works great now. Thanks a million!Now about that intimacy program....
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now