ussr Posted June 19, 2011 Share Posted June 19, 2011 Hi All I would like to make a basic gui script to control applications . I want to write ini and open and close process according to the ini file. The script write the value into ini file. That is working . But Im confused about the time func , kill and close ,read too. I dont know how to put it together . The script is not working! Please correct me. Link to comment Share on other sites More sharing options...
ussr Posted June 19, 2011 Author Share Posted June 19, 2011 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet( "{ESC}", "end" ) Func end() Exit 0 EndFunc Global $Form1 = GUICreate("Form1", 485, 285, 282, 117) Global $Combo1 = GUICtrlCreateCombo("open min", 24, 32, 145, 25) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59") Global $Combo2 = GUICtrlCreateCombo("open hour", 24, 88, 145, 25) GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24") Global $Combo3 = GUICtrlCreateCombo("close min", 304, 32, 145, 25) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59") Global $Combo4 = GUICtrlCreateCombo("close hour", 304, 88, 145, 25) GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24") Global $Input1 = GUICtrlCreateInput("Input1", 176, 192, 121, 21) Global $Button1 = GUICtrlCreateButton("1", 200, 144, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Sleep(10) $min = IniRead("C:\b.ini", "section", "1","") $hour = IniRead("C:\b.ini", "section", "2","") $mins = IniRead("C:\b.ini", "section", "3","") $hours = IniRead("C:\b.ini", "section", "4","") Sleep(50) read() Case $Combo1 st() Case $Combo2 ra() Case $Combo3 ba() Case $combo4 ta() EndSwitch WEnd func st() IniWrite("C:\b.ini", "section", "1",GUICtrlRead($Combo1) ) EndFunc func ra() IniWrite("C:\b.ini", "section", "2",GUICtrlRead($Combo2) ) EndFunc func ba() IniWrite("C:\b.ini", "section", "3",GUICtrlRead($Combo3) ) EndFunc func ta() IniWrite("C:\b.ini", "section", "4",GUICtrlRead($Combo4) ) EndFunc Func read() Sleep(20) While 1 If @MIN = $min And @HOUR = $hour Then Run (@ProgramFilesDir&"\uTorrent\uTorrent.exe") Return Sleep(20) EndIf WEnd EndFunc func close() While 2 if @MIN = $mins And @HOUR = $hours Then kill() EndIf WEnd EndFunc func kill() Sleep(5) For $i = 1 To 5 If ProcessExists ("uTorrent.exe")Then ProcessClose("uTorrent.exe") Sleep(1000) Else ExitLoop EndIf Next EndFunc Func time() $Form1 = GUICreate("Form1", 320, 60, 100, 124) $Label5 = GUICtrlCreateLabel("Time", 376, 8, 50, 17) $Label6 = GUICtrlCreateLabel("H:"&@HOUR&" M:"&@MIN, 50, 8, 500, 17) GUISetState(@SW_SHOW) While 1 Sleep(500) Global $rData = @HOUR&" : "&@MIN GuiCtrlSetData($Label6 ,$rData) WEnd EndFunc Edited June 20, 2011 by Valik Added code tag. Link to comment Share on other sites More sharing options...
ussr Posted June 19, 2011 Author Share Posted June 19, 2011 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet( "{ESC}", "end" ) Func end() Exit 0 EndFunc Global $Form1 = GUICreate("Form1", 485, 285, 282, 117) Global $Combo1 = GUICtrlCreateCombo("open min", 24, 32, 145, 25) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59") Global $Combo2 = GUICtrlCreateCombo("open hour", 24, 88, 145, 25) GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24") Global $Combo3 = GUICtrlCreateCombo("close min", 304, 32, 145, 25) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59") Global $Combo4 = GUICtrlCreateCombo("close hour", 304, 88, 145, 25) GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24") Global $Input1 = GUICtrlCreateInput("Input1", 176, 192, 121, 21) Global $Button1 = GUICtrlCreateButton("1", 200, 144, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Sleep(10) $min = IniRead("C:\b.ini", "section", "1","") $hour = IniRead("C:\b.ini", "section", "2","") $mins = IniRead("C:\b.ini", "section", "3","") $hours = IniRead("C:\b.ini", "section", "4","") Sleep(50) read() Case $Combo1 st() Case $Combo2 ra() Case $Combo3 ba() Case $combo4 ta() EndSwitch WEnd func st() IniWrite("C:\b.ini", "section", "1",GUICtrlRead($Combo1) ) EndFunc func ra() IniWrite("C:\b.ini", "section", "2",GUICtrlRead($Combo2) ) EndFunc func ba() IniWrite("C:\b.ini", "section", "3",GUICtrlRead($Combo3) ) EndFunc func ta() IniWrite("C:\b.ini", "section", "4",GUICtrlRead($Combo4) ) EndFunc Func read() Sleep(20) While 1 If @MIN = $min And @HOUR = $hour Then Run (@ProgramFilesDir&"\uTorrent\uTorrent.exe") Return Sleep(20) EndIf WEnd EndFunc func close() While 2 if @MIN = $mins And @HOUR = $hours Then kill() EndIf WEnd EndFunc func kill() Sleep(5) For $i = 1 To 5 If ProcessExists ("uTorrent.exe")Then ProcessClose("uTorrent.exe") Sleep(1000) Else ExitLoop EndIf Next EndFunc Func time() $Form1 = GUICreate("Form1", 320, 60, 100, 124) $Label5 = GUICtrlCreateLabel("Time", 376, 8, 50, 17) $Label6 = GUICtrlCreateLabel("H:"&@HOUR&" M:"&@MIN, 50, 8, 500, 17) GUISetState(@SW_SHOW) While 1 Sleep(500) Global $rData = @HOUR&" : "&@MIN GuiCtrlSetData($Label6 ,$rData) WEnd EndFunc Edited June 20, 2011 by Valik Added code tag. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 19, 2011 Share Posted June 19, 2011 (edited) Nothing to see here. Literally. Post some code and explain what doesn't work in it. Remember we can't help you until it gets down to a question of AutoIt usage. Edit: Hmm. Careful what you ask for, huh? Edited June 19, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
guinness Posted June 19, 2011 Share Posted June 19, 2011 would like to make a basic gui script to control applications .Welcome to AutoIt. Have a look in the Help File for GUICreate() & IniRead() as these entries both have great Examples of what to do with them. I want to write ini and open and close process according to the ini file.Run(), ProcessClose() & IniWrite()But Im confused about the time func , kill and close ,read too.What time Function? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 19, 2011 Share Posted June 19, 2011 Post code inside [code]... tags. See the angle brackets button above the forum editor. The time() function is never called, and if it is it will never exit, so what was the point of it?You'll have to tell us what you thought the other functions were supposed to do. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ussr Posted June 19, 2011 Author Share Posted June 19, 2011 Hi The time ,kill,close func are not called on purpose . I wanted to use them but I dont know how. The script above is not working I tried to figure out how to.. ,but It is not working. Forget it . -Basically I need a gui scrip to start and close the process according the ini file. combo box 1(min), 2(hour) open time combo box 3(min),4(hour) close. -And I tried to use visible time on the gui. func time() But it is not working together with gui event. -I also have problem to close process . For $i = 1 To 5 If ProcessExists ("uTorrent.exe")Then ProcessClose("uTorrent.exe") Sleep(1000) Too many problems . Autoit is really difficult for an amature. Thank you for your reply . Link to comment Share on other sites More sharing options...
guinness Posted June 19, 2011 Share Posted June 19, 2011 (edited) Autoit is really difficult for an amature.Anything is difficult if you haven't used it before. And how easy would you want it to be? -Basically I need a gui scrip to start and close the process according the ini file.What does the INI File look like? Because if it looks like this (see below) then I would consider looking at the Example in INIReadSection(), with the Section being "Processes" INI Example: [Processes] Process1=Something.exe Process2=SomethingElse.exe Process3=SomethingElseAgain.exe If your haveing a problem calling Functions then search in the Help File for "Func...Return...EndFunc" And to conclude your small Example in the previous post is missing a Next. Edited June 19, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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