fikri1979 Posted March 22, 2014 Share Posted March 22, 2014 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 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 More sharing options...
Bert Posted March 22, 2014 Share Posted March 22, 2014 look at my vollatran project. It may not be what you have in mind but it may be a different direction for you that you may like. Otherwise look at FileOpenDialog, fikri1979 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Solution Gianni Posted March 22, 2014 Solution Share Posted March 22, 2014 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 fikri1979 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
fikri1979 Posted March 22, 2014 Author Share Posted March 22, 2014 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... 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 More sharing options...
Gianni Posted March 22, 2014 Share Posted March 22, 2014 thank you very much for your help... 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. fikri1979 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
fikri1979 Posted March 23, 2014 Author Share Posted March 23, 2014 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 More sharing options...
JohnOne Posted March 23, 2014 Share Posted March 23, 2014 What do you see wrong with this? ProcessExists($Input1) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
fikri1979 Posted March 23, 2014 Author Share Posted March 23, 2014 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? Link to comment Share on other sites More sharing options...
JohnOne Posted March 23, 2014 Share Posted March 23, 2014 Try to compare it with this. ShellExecute(GUICtrlRead($Input1)) fikri1979 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Gianni Posted March 23, 2014 Share Posted March 23, 2014 Hi fikri1979 Mr. JohnOne is pointing where you will find the bugI 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 fikri1979 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
JohnOne Posted March 23, 2014 Share Posted March 23, 2014 i'm sorry i don't know cause i'm beginner.. how to correct it my script? $Input1 is an identifier to a control in your script, you need to read what's in that control. fikri1979 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
fikri1979 Posted April 7, 2014 Author Share Posted April 7, 2014 I finally tried the following script and successfully ...is there any other way that is more practical? expandcollapse popup#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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now