Hi All,

The following function works fine on Mac but on PC it doesn't seem to work 100% of the time.

I've checked this and the window title etc. is set correctly and if I run the same JavaScript from shell it brings the app/window to the front ok.

Here's the flow:

Launch Application
Application Launches iTunes and Internet Explorer.
---At this point the Application NOT in front, iTunes is.

So, I want to bring the Application to the Front, the function below, runs and selects the correct window, but it just won't go to the front! I've been trying to make this work on and off for 1.5 days now and just can't seem to find a solution.

One thing that I really can't understand is why RunRev doesn't have a in-built way of bringing the Application to the Front? It seems like a really basic thing to want to do!

Anyone with any ideas on this? I really need to get this working ASAP as I have to do a release tomorrow and this is the last remaining problem.

Thanks a lot
All the Best
Dave

------------------------------------------------------------
--
-- BringToFront
--
-----------------------------------------------------------
function BringToFront theServiceKindToActivate
  local myAppleScriptCode
  local myAppleScriptResult
  local myErrorString
  local myJavaScriptCode
  local myShellResult
  local myJavaScriptResult
  local myAppName
  local myStackLongID
  local myWindowTitle

  set the itemDelimiter to "/"
  put  item -1 of the address into myAppName

put ISMGetStackForService(theServiceKindToActivate) into myStackLongID
  if myStackLongID <> empty then
    put the title of myStackLongID into myWindowTitle
  end if

  --
  --  Different things for Different Platforms
  --
  switch the platform

    --
    --  Handle Mac
    --
  case "MacOS"
put "tell application " & UtilStringAddQuotes(myAppName) & " to activate" & cr into myAppleScriptCode
    do myAppleScriptCode as "AppleScript"

    put the result into myAppleScriptResult
    put "Error in LibAppleScriptiGenXBringToFront:" into myErrorString
if LibAppleScriptiTunesCheckReturnValue (myAppleScriptResult,false,"LibAppleScriptiGenXBringToFront",myErrorStri ng) = false then
      return myAppleScriptResult
    end if

put UtilStringRemoveQuotes(myAppleScriptResult) into myAppleScriptResult

    if paramCount() <> 1 then
      breakpoint
    end if

    return myAppleScriptResult
    break

    --
    -- Handle Windows
    --
  case "Win32"
put "var Shell = WScript.CreateObject(" & UtilStringAddQuotes ("wscript.shell") & ");" & cr into myJavaScriptCode --put "Shell.activate(" & UtilStringAddQuotes(myAppName) & ");" & cr after myJavaScriptCode put "Shell.activate(" & UtilStringAddQuotes(myWindowTitle) & ");" & cr after myJavaScriptCode
    put cr & cr & cr after myJavaScriptCode

put LibScriptExecuteCode (myJavaScriptCode,"GenXBringToFront","JavaScript",myShellResult) into myJavaScriptResult
    if myJavaScriptResult <> empty then
      breakpoint
      return myJavaScriptResult
    end if
    break
  end switch

  return empty
end BringToFront



_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to