Jump to content

How to run external software


Go to solution Solved by Gianni,

Recommended Posts

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
Link to comment
Share on other sites

  • Solution

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

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

 

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.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
Share on other sites

  • 3 weeks later...

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...