Sign in to follow this  
Followers 0
mrbloody369

Is this even possible?

5 posts in this topic

Hi,

I'm new to Autoit and I don't even know what I want to do if it's even possible in Autoit. The following is what I'm trying to do.

I work with Adobe 5.0 and 7.0, and I have to constantly change versions depending on current needs at the work place. So I'm trying to make my work life move more smoothly by making a script that at the click of a button it will, check to see if adobe(Acrobat.exe) is open, if it is open it will tell me (VIA msgbox) what version is currently running, since it got to the point I can't tell any more with all the pressure to get things done quickly as possible. But if the Adobe is not open at all it will open the the version I want.. So my main question is this even possible? If so can some one point me in the right direction or show me a better way to go abouts what I want to do??

Example of what I have completed so far.

#NoTrayIcon
#include <IE.au3>
#include <GUIConstants.au3>
    
$MainWin = GUICreate("Work GUI" , 400 , 170)
$EndButton = GUICtrlCreateButton ("End", 210, 140, 60)
$AFButton = GUICtrlCreateButton ("AF", 10 , 140 , 30)
GUISetState ()

While 1
$Msg = GUIGetMsg()
If $msg = $AFButton Then
        While 2
            If Not ProcessExists("Acrobat.exe")Then
            Run('C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe')
            Sleep(5000);25 sec wait
            EndIf
            If ProcessExists("Acrobat.exe")Then
        ;Func $VS
        ;sleep(600)
            MsgBox("","Acrobat is Open",$version," is all ready open, Close it and try again.")
            Sleep(1000)
            ExitLoop
        EndIf
        WEnd    
    EndIf
         If $msg = $EndButton Then ExitLoop
         If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func = $VS
    If ProcessExists("Acrobat.exe")Then
    ;??? get Description: txt from properties of the Acrobat.exe??
    ;pass txt to $version to have display in the msgbox txt
    EndIf
EndFunc

Thanks for any and all help.

Mr B.


Favorite Quotes"If you apply your mind you can create any thing you can dream of" "Any thing can get done by simply click of a button"

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

I'm new to Autoit and I don't even know what I want to do if it's even possible in Autoit. The following is what I'm trying to do.

I work with Adobe 5.0 and 7.0, and I have to constantly change versions depending on current needs at the work place. So I'm trying to make my work life move more smoothly by making a script that at the click of a button it will, check to see if adobe(Acrobat.exe) is open, if it is open it will tell me (VIA msgbox) what version is currently running, since it got to the point I can't tell any more with all the pressure to get things done quickly as possible. But if the Adobe is not open at all it will open the the version I want.. So my main question is this even possible? If so can some one point me in the right direction or show me a better way to go abouts what I want to do??

Should be possible - There are methods to retrieve the running Process list. If you can determine the full path of the active "Acrobat.exe" (someone may have even written a script for this already), then you could determine the version via the path. If the installation paths aren't standard, you could then extend it to using FileGetVersion() to determine which was running.

edit: rewording for clarification

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Think so:

#NoTrayIcon
#include <IE.au3>
#include <GUIConstants.au3>

$MainWin = GUICreate("Work GUI", 400, 170)
$EndButton = GUICtrlCreateButton("End", 210, 140, 60)
$AFButton = GUICtrlCreateButton("AF", 10, 140, 30)
$ProcessName = "Acrobat.exe"
GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = $AFButton Then
        While 2
            If Not ProcessExists($ProcessName) Then
                Run('C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe')
                Sleep(5000);25 sec wait
            EndIf
            If ProcessExists($ProcessName) Then
                $version = _GetVersion($ProcessName)
                ;sleep(600)
                MsgBox("", "Acrobat is Open", $version & " is already open. Close it and try again.")
                Sleep(1000)
                ExitLoop
            EndIf
        WEnd
    EndIf
    If $Msg = $EndButton Then ExitLoop
    If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func _GetVersion($Process)
    Dim $FullPath
    $PID = ProcessExists($Process)
    If Not $PID Then
        SetError(1)
        Return ""
    EndIf
    ; Ripped off (respectfully) from [url="http://www.autoitscript.com/forum/index.php?s=&showtopic=19370&view=findpost&p=200047"][b][u]WinGetPath[/u][/b][/url]
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $PID, "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            If $objItem.ExecutablePath Then $FullPath = $objItem.ExecutablePath
        Next
    EndIf
    If $FullPath <> "" Then
        Return FileGetVersion ( $FullPath )
    Else
        SetError(2)
        Return ""
    EndIf
EndFunc   ;==>_GetVersion

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Should be possible - There are methods to retrieve the running Process list. If you can determine the full path of the active "Acrobat.exe" (someone may have even written a script for this already), then you could determine the version via the path. If the installation paths aren't standard, you could then extend it to using FileGetVersion() to determine which was running.

edit: rewording for clarification

Thanks for your help, I keeped getting 0.0.0.0 for version number with FileGetVersion(prob. a user issue :) ).

Think so:

#NoTrayIcon
#include <IE.au3>
#include <GUIConstants.au3>

$MainWin = GUICreate("Work GUI", 400, 170)
$EndButton = GUICtrlCreateButton("End", 210, 140, 60)
$AFButton = GUICtrlCreateButton("AF", 10, 140, 30)
$ProcessName = "Acrobat.exe"
GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = $AFButton Then
        While 2
            If Not ProcessExists($ProcessName) Then
                Run('C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe')
                Sleep(5000);25 sec wait
            EndIf
            If ProcessExists($ProcessName) Then
                $version = _GetVersion($ProcessName)
               ;sleep(600)
                MsgBox("", "Acrobat is Open", $version & " is already open. Close it and try again.")
                Sleep(1000)
                ExitLoop
            EndIf
        WEnd
    EndIf
    If $Msg = $EndButton Then ExitLoop
    If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func _GetVersion($Process)
    Dim $FullPath
    $PID = ProcessExists($Process)
    If Not $PID Then
        SetError(1)
        Return ""
    EndIf
   ; Ripped off (respectfully) from WinGetPath
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $PID, "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            If $objItem.ExecutablePath Then $FullPath = $objItem.ExecutablePath
        Next
    EndIf
    If $FullPath <> "" Then
        Return FileGetVersion ( $FullPath )
    Else
        SetError(2)
        Return ""
    EndIf
EndFunc  ;==>_GetVersion
[
;) Thanks for coding my issues away.. Very gratefull. ;)

Mr B.


Favorite Quotes"If you apply your mind you can create any thing you can dream of" "Any thing can get done by simply click of a button"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

From the Help file on FileGetVersion:

Failure: Returns "0.0.0.0" if no version information (or other error)

Probably need to do error checking to confirm that you are getting the correct path and that the file has version information. Edited by bluebearr

BlueBearrOddly enough, this is what I do for fun.

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