sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to check if a program is running with Ruby?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 2.0k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W Offline
      Whaat
      last edited by

      I am pretty sure this can be done. I have done some research but have not found what I am looking for yet.

      I just need to know if a given program is running.

      Something like this:

      if ("indigo.exe").is_running?
      
      do something
      
      end
      

      Maybe it has to be done with a system call...but which call?

      SketchUp Plugins for Professionals

      1 Reply Last reply Reply Quote 0
      • tbdT Offline
        tbd
        last edited by

        here is one quick way

        require "win32ole"
        procs = WIN32OLE.connect("winmgmts;\\\\.")
        all_proc = []
        procs.InstancesOf("win32_process").each do |proc|
          all_proc.push proc.name.to_s.downcase
        end
        p all_proc.include?("indigo.exe")
        

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        1 Reply Last reply Reply Quote 0
        • W Offline
          Whaat
          last edited by

          Thanks, but I get this error message when SketchUp loads:

          Error Loading File ProcessTest.rb
          No such file to load -- win32ole
          

          It would be great if this would work without the need for another file.

          SketchUp Plugins for Professionals

          1 Reply Last reply Reply Quote 0
          • tbdT Offline
            tbd
            last edited by

            you need win32ole.so for that example.
            ... but you still need another file to access process identification (win32ole or win32api)

            SketchUp Ruby Consultant | Podium 1.x developer
            http://plugins.ro

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement