Sign in to follow this  
Followers 0
monte

flash tray icon help!

2 posts in this topic

Hello, the following code flashes the tray icon in the beginning of the function, stops it at the end but after the function exits the tray icon begins flashing again, after a brief pause and then the script hangs. What am I doing wrong?

Please note: I'm opening a url that launches a lotus notes database, this will not work for you in testing the script. I'm looking for a semantics error, not sytax. Any help would be greatley appreciated and sorry about the script not fully functional. Thanks.

#include <IE.au3>
#Include <Constants.au3>
#NoTrayIcon

;;;;;;;;;
;hotkeys
;;;;;;;;;
HotKeySet("^#b", "cmd")      ;cmd prompt
HotkeySet("^#c", "copy")        ;copy
HotkeySet("^#s", "notesDb") ; launch notes db

;;;;;;
;tray
;;;;;;
Opt("TrayMenuMode",1)
$cmd   = TrayCreateItem("Cmd Prompt  - Ctrl Win B")
$copy   = TrayCreateItem("Copy  - Ctrl Win C")
$notes   = TrayCreateItem("Notes Db  - Ctrl Win N")
TrayCreateItem("")
$exititem      = TrayCreateItem("Exit")

TraySetState()
TraySetToolTip("Hotkeys")

$hotkeyFlag = 0

While 1
  $msg = TrayGetMsg()
  Select
    Case $msg = 0
      ContinueLoop
    Case $msg = $exititem
      ExitLoop
    Case $msg = $cmd
      cmd()
    Case $msg = $copy
      copy()
    Case $msg = $notes
      $hotkeyFlag = 1
      notesDb()
      $hotkeyFlag = 0
  EndSelect
WEnd

;;;;;;
;CMD
;;;;;;
func cmd()
  TraySetState(4)
  Run(@ComSpec & " /k color 02&prompt #&cls" & @cr)
  traysetstate(8)
endfunc

;;;;;;
;Copy
;;;;;;
func copy()
 ;activate previous window and copy what's selected
 ;winactivate ????
  sleep(100)
  send("^c", 0)
  sleep(100)
  msgbox(0, "Hotkeys", "You copied:" & @cr & stringstripws(ClipGet(), 8)
endfunc

;;;;;;
;Access Lotus Notes Db
;;;;;;
func notesDb()
  traysetstate(4)
  if $hotkeyFlag = 1 then
    sleep(100)
    Send("!{tab}")
  endif
  sleep(100)
  send("^c", 0)
  sleep(100)
  $node = stringstripws(ClipGet(), 8)
  ###################################################################
  # note:  the following url won't work in order to test this script
  ###################################################################
  $oIE = _IECreate ("some url to open notes db=" & $node, 0, 0, 1, 0)
  while 1
    sleep(1500)
    if winexists("some url to open notes db=") <> 1 then
      if $oIE then _IEQuit ($oIE)
      exit
    else
      $sText = _IEBodyReadText ($oIE)
      if stringinstr($sText, "Error") then 
        msgbox(0, "USS Hotkeys", $node & " may not be in SHI, please check manually.")
        ###################################################################
        # note:  the following url won't work in order to test this script
        ###################################################################
        $oIENoShi = _IECreate ("notes://launch db", 0, 0, 1)
        _IEQuit ($oIENoShi) 
      endif
    endif
  wend
  traysetstate(8)
endfunc

Share this post


Link to post
Share on other sites



note: it works sometimes, but mainly doesn't...leading me to believe it's a timing issue, possibly with my IE object?

This needs an explanation, sorry: If the above url is correct (the $node in the clipboard exists in the database), then the IE window is only open for a brief second (to launch the database), however if it doesn't exist in the db, then the window remains open. This leads to my while loop checking if the window is still open and if it is getting the "error" statement to confirm that the error exists.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0