Sign in to follow this  
Followers 0
Kenzo2011

Execute a program and show a service status

13 posts in this topic

Hi all,

I want to execute itunes and show a service status of this service when I choose itunes at list view and press start button.

I spend more time to research but I don't know how to do it.

Please instruct me to solve this code.

Thanks all !

Process list.au3

Share this post


Link to post
Share on other sites



My purpose : I want to use autoit in order to open all programs in my computer such as autoit, yahoo, itunes, word, excel, firefox, media... without shortcut on a screen.

If AutoIT is executed. It will show "AutoIT.exe is running" at Status in GUICtrlCreateListView.

I know ProcessExists function to check service status but I don't know how to complete mycode.

Because I am a newbie so I need to learn from your experience.

Please instruct me how to write code.

Many thanks !

Share this post


Link to post
Share on other sites

Anyone help me how to do it ? :graduated:

Share this post


Link to post
Share on other sites

What you need to do is try something.

You can post here for as long as you can be bothered, and you might get someone finish your code. Or you could read the help documentation on your listview and processexists function, have a go at implementing them and post your efforts.

I guarantee you will get help quicker with the latter.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Forum tags and html are not cooperating.

Anyway .. this should help.

$itunes = GUICtrlCreateListViewItem("Itunes", $ListView1)

GUICtrlSetData($itunes, '|' & ProcessExists('itunes.exe'))

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

It work well.

Thanks for your instruction, Hobby Coder !

Share this post


Link to post
Share on other sites

Hi all,

I can open the program and show service status. But it can not return 'not running' status when I close notepad.exe.

Can you help me how to do that ?

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <Process.au3>
Opt('MustDeclareVars', 1)
Dim $listview, $notepad, $start, $close, $msg
Execute_process()
Func Execute_process()
GUICreate("Execute program",380, 400,-1,-1)
  $listview = GUICtrlCreateListView("Program|Status", 40, 30, 300, 300, $WS_EX_ACCEPTFILES)
  $notepad = GUICtrlCreateListViewItem("Notepad | Not running", $listview)
   GUICtrlSetColor(-1, 0x0000CC)
  $start = GUICtrlCreateButton("Start", 40, 350, 100, 25)
  $close = GUICtrlCreateButton("Close", 240, 350, 100, 25)
GUISetState()
checkprocess()
Global $last_forcus_list_view
Do
  $msg = GUIGetMsg()
   Switch $msg
    Case $start
     Switch $last_forcus_list_view
     
      Case $notepad
       run("notepad.exe")
       GUICtrlSetData($notepad,"Notepad | Running")   
      
      Case Else
       MsgBox(0,"","Start ?")
      
     EndSwitch
    Case $notepad
     $last_forcus_list_view=$notepad
   EndSwitch
Until $msg = $close
  Exit
EndFunc
Func checkprocess()
If ProcessExists("notepad.exe") Then GUICtrlSetData($notepad,"Notepad | Running")

EndFunc

Thanks for your sharing !

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Pls, instruct me how to do it, everybody !

Edited by Kenzo2011

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Here's something to play with ...

#include "WindowsConstants.au3"
#include "GUIConstantsEx.au3"
#include "ListViewConstants.au3"
#include "Process.au3"
Opt('MustDeclareVars', 1)
Local $listview, $notepad, $start, $close, $msg
Execute_process()
Func Execute_process()
    GUICreate("Execute program", 380, 400, -1, -1)
    $listview = GUICtrlCreateListView("Program|Status", 40, 30, 300, 300, $WS_EX_ACCEPTFILES)
    GUICtrlSendMsg($listview, 0x101E, 0, 140)
    GUICtrlSendMsg($listview, 0x101E, 1, 140)
    $notepad = GUICtrlCreateListViewItem("Notepad | Not running", $listview)
    GUICtrlSetColor(-1, 0x0000CC)
    $start = GUICtrlCreateButton("Start", 40, 350, 100, 25)
    $close = GUICtrlCreateButton("Close", 240, 350, 100, 25)
    GUISetState()
    checkprocess()
    Global $last_forcus_list_view
    AdlibRegister('checkprocess', 2000)
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case -3, $close
                ExitLoop
            Case $start
                Switch $last_forcus_list_view
                    Case $notepad
                        Run("notepad.exe")
                    Case Else
                        MsgBox(0, "", "Start ?")
                EndSwitch
            Case $notepad
                $last_forcus_list_view = $notepad
        EndSwitch
    WEnd
EndFunc
AdlibUnRegister('checkprocess')
GUIDelete()
Exit
Func checkprocess()
    If ProcessExists("notepad.exe") Then
        GUICtrlSetData($notepad, "Notepad | Running")
    Else
        GUICtrlSetData($notepad, "Notepad | Not Running")
    EndIf

EndFunc
Still having problems with tags.IE: #include leftarrow/rightarrow and inbetween is missing unless I replace arrows with quotes ""

html tags "p" and "/p" are in the edit code - which has not been in the past.

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

Got it to work now.

Thanks again for your support , Hobby !

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Credit: AutoIt help

Thanks.. idea ripdad

Discription:Select to run programs in the GUIctrl edit.

I write modify code from help of autoit.

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("My GUI", 220, 170, -1, -1)
$nEdit = GUICtrlCreateEdit ("", 10, 30, 200, 100)
GUICtrlCreateLabel("Clicked Program name to Run", 10, 10, 200)
GUICtrlCreateButton ("RUN", 60, 140, 100)
GUISetState ()
Dim $array[2]
$array[0] = "=====Programs name====="
$array[1] = "Notepad"&@CRLF&"Calculator"
$output = ""
For $i = 0 To UBound($array)-1
   $output = $output&$array[$i]&@CRLF
Next
GUICtrlSetData ($nEdit, $output)
Do
    $msg = GUIGetMsg()
    If $msg > 0 Then
        $i = GUICtrlSendMsg($nEdit, $EM_LINEINDEX, -1, 0)
        $nline = GUICtrlSendMsg($nEdit, $EM_LINEFROMCHAR, $i, 0)
        GUICtrlSetState ($nEdit,$GUI_FOCUS)
        Select
            Case $nLine = 1
                ShellExecute("Notepad.exe")
            Case $nLine = 2
                ShellExecute("Calc.exe")
            Case Else
               MsgBox(4096, "", "No, Program name.") 
        EndSelect
    EndIf
Until $msg = $GUI_EVENT_CLOSE
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

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