Jump to content
Sign in to follow this  
fikri1979

How to run external software

Recommended Posts

fikri1979

Hallo All....

i need help how to create script like this :

1. when i click  "LOAD" button will display a dialog open to search external software and then the dirpath will shown

   post-81604-0-72380700-1395460090_thumb.j

   post-81604-0-63543800-1395460121_thumb.j

   post-81604-0-36004900-1395460155_thumb.j

2. When i click "SAVE" button  it is automatically saved dirpath

3. last when I click the "START" button it will run the external software from that dirpath

 Please, can give me example to create script?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 463, 138, 298, 267)
$Input1 = GUICtrlCreateInput("Input1", 56, 16, 265, 21)
$Button1 = GUICtrlCreateButton("LOAD", 336, 16, 49, 25)
$Button2 = GUICtrlCreateButton("START", 184, 64, 105, 41)
$Button3 = GUICtrlCreateButton("SAVE", 392, 16, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Chimp

something like this?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 463, 138, 298, 267)
$Input1 = GUICtrlCreateInput("Input1", 56, 16, 265, 21)
$Button1 = GUICtrlCreateButton("LOAD", 336, 16, 49, 25)
$Button2 = GUICtrlCreateButton("START", 184, 64, 105, 41)
$Button3 = GUICtrlCreateButton("SAVE", 392, 16, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $MyFile = FileOpenDialog('Please choose file', '', 'All files (*.*)', 1)
            GUICtrlSetData($Input1, $MyFile)
        Case $Button2
            ShellExecute(GUICtrlRead($Input1))
        Case $Button3
            MsgBox(0,"????","what to do with this??")
    EndSwitch
WEnd
  • Like 1

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
fikri1979

 

something like this?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 463, 138, 298, 267)
$Input1 = GUICtrlCreateInput("Input1", 56, 16, 265, 21)
$Button1 = GUICtrlCreateButton("LOAD", 336, 16, 49, 25)
$Button2 = GUICtrlCreateButton("START", 184, 64, 105, 41)
$Button3 = GUICtrlCreateButton("SAVE", 392, 16, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $MyFile = FileOpenDialog('Please choose file', '', 'All files (*.*)', 1)
            GUICtrlSetData($Input1, $MyFile)
        Case $Button2
            ShellExecute(GUICtrlRead($Input1))
        Case $Button3
            MsgBox(0,"????","what to do with this??")
    EndSwitch
WEnd

 

thank you very much for your help... :thumbsup: 

i have tried like this below..

on the save button, I want to be when it was closed and then opened again it will automatically appear paths that have been stored earlier..

 
is there any other way that is much easier to run the save button??
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $readpath = IniRead(@ScriptDir & "\Config.ini","Path", "soft", "NotFound")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 463, 138, 298, 267)
$Input1 = GUICtrlCreateInput($readpath, 56, 16, 265, 21)
$Button1 = GUICtrlCreateButton("LOAD", 336, 16, 49, 25)
$Button2 = GUICtrlCreateButton("START", 184, 64, 105, 41)
$Button3 = GUICtrlCreateButton("SAVE", 392, 16, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $MyFile = FileOpenDialog('Please choose file', '', 'All files (*.*)', 1)
            GUICtrlSetData($Input1, $MyFile)
        Case $Button2
            ShellExecute(GUICtrlRead($Input1))
        Case $Button3
            MsgBox(0,"Message","saved")
            IniWrite(@ScriptDir & "\Config.ini", "Path", "soft", GUICtrlRead($Input1))
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Chimp

 

thank you very much for your help... :thumbsup: 

i have tried like this below..

on the save button, I want to be when it was closed and then opened again it will automatically appear paths that have been stored earlier..

 
is there any other way that is much easier to run the save button??

 

You are welcome :)

I think your choice to use an INI file to save the path is the right one.

  • Like 1

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
fikri1979

You are welcome :)

I think your choice to use an INI file to save the path is the right one.

 

once again,...

How about this

1. when click the exit button it will automatically close that external software too..

2. When click the "Start" Button then It will disable Start Button..

i have tried like this, how to correct it?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $readpath = IniRead(@ScriptDir & "\Config.ini","Path", "soft", "NotFound")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 463, 138, 298, 267)
$Input1 = GUICtrlCreateInput($readpath, 56, 16, 265, 21)
$Button1 = GUICtrlCreateButton("LOAD", 336, 16, 49, 25)
$Button2 = GUICtrlCreateButton("START", 184, 64, 105, 41)
$Button3 = GUICtrlCreateButton("SAVE", 392, 16, 57, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ProcessClose($Input1)     ; to close external software
            Exit
        Case $Button1
            $MyFile = FileOpenDialog('Please choose file', '', 'All files (*.*)', 1)
            GUICtrlSetData($Input1, $MyFile)
        Case $Button2
            ShellExecute(GUICtrlRead($Input1))
        Case $Button3
            MsgBox(0,"Message","saved")
            IniWrite(@ScriptDir & "\Config.ini", "Path", "soft", GUICtrlRead($Input1))
   EndSwitch
      ; to disable START Button when external software is exsist
      If NOT ProcessExists($Input1) AND BitAND(GUICtrlGetState($Button1), $gui_disable) = $gui_disable Then
      GUICtrlSetState($Button1, $gui_enable)
      EndIf
WEnd

Share this post


Link to post
Share on other sites
fikri1979

What do you see wrong with this?

ProcessExists($Input1)

i'm sorry i don't know cause i'm beginner..

how to correct it my script?

Share this post


Link to post
Share on other sites
Chimp

Hi fikri1979

Mr. JohnOne is pointing where you will find the bug

I give you another little help:

$Input1 is the reference to the InputBox, not to the external program which was launched...

add a variable to the ShellExecute command in this way (this will be handy later)
 $MyRef = ShellExecute (GUICtrlRead ($ Input1))

the ShellExecute command returns a reference to something that... I can not remember now,
please Take a look at the ShellExecute command in help

  • Like 1

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
fikri1979

I finally tried the following script and successfully ...
is there any other way that is more practical?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

Global $readpath = IniRead(@ScriptDir & "\Config.ini","Path", "injek", "NotFound")


#Region ### START Koda GUI section ### Form=latihan shel execute.kxf
$Form1_1 = GUICreate("Form1", 340, 133, 285, 191)
$btnstart = GUICtrlCreateButton("START", 48, 48, 89, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$btnstop = GUICtrlCreateButton("STOP", 160, 48, 89, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lokasinjek = GUICtrlCreateInput($readpath, 40, 16, 233, 21)
$btnganti = GUICtrlCreateButton("....", 280, 16, 33, 25)
$Inputtitle = GUICtrlCreateInput("pid", 160, 88, 113, 21)
$Label1 = GUICtrlCreateLabel("TITLE", 96, 88, 34, 17)
GUISetState(@SW_SHOW)
cek()

#EndRegion ### END Koda GUI section ###

While 1
   $nMsg = GUIGetMsg()
      Switch $nMsg
         Case $GUI_EVENT_CLOSE
            Exit
         Case $btnganti
             $MyFile = FileOpenDialog('Browse', '', 'All files (*.*)', 1)
            GUICtrlSetData($lokasinjek, $MyFile)
         case $btnstart
            Example()

         case $btnstop
            stop()
      EndSwitch
WEnd

Func cek()
  GUICtrlSetState($btnstart, $gui_enable)
  GUICtrlSetState($btnstop, $gui_disable)
EndFunc

Func Example()
  ShellExecute(GUICtrlRead($lokasinjek))
  GUICtrlSetState($btnstart, $gui_disable)
  GUICtrlSetState($btnstop, $gui_enable)
  sleep(1000)
  ; Retrieve the window title of the active window.
  GUICtrlSetData($Inputtitle,WinGetProcess("[ACTIVE]"))
EndFunc

Func stop()
   ProcessClose(GUICtrlRead($Inputtitle))
   GUICtrlSetState($btnstart, $gui_enable)
   GUICtrlSetState($btnstop, $gui_disable)

EndFunc

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  

×