yasha Posted November 11, 2018 Share Posted November 11, 2018 Need help in running My program goes something like this While ct less than 30 If = 1 run this End if If = 2 run this End if Now i want to run both these using if = 3 and dont want to type out the lines of instructions again. Link to comment Share on other sites More sharing options...
Subz Posted November 11, 2018 Share Posted November 11, 2018 Lots of way to do this example: Local $sInput = InputBox("Selection", "Please Enter Number 1 to 3", "") Switch $sInput Case 1 MsgBox(4096, "You typed", $sInput) Case 2 MsgBox(4096, "You typed", $sInput) Case 3 MsgBox(4096, "You typed", $sInput) Case Else MsgBox(4096, "You typed", "You typed an invalid input: " & $sInput) EndSwitch Local $sInput = InputBox("Selection", "Please Enter Number 1 to 3", "") Switch $sInput Case 1 To 3 MsgBox(4096, "You typed", $sInput) Case Else MsgBox(4096, "You typed", "You typed an invalid input: " & $sInput) EndSwitch Link to comment Share on other sites More sharing options...
yasha Posted November 12, 2018 Author Share Posted November 12, 2018 (edited) < $charcnt = 1 while $charcnt < 40 if $selectedflag[$charcnt] = 1 then EndIf sleep(10) if $selectedflag[$charcnt] = 2 then EndIf Sleep(10) if $selectedflag[$charcnt] = 3 then EndIf Sleep(10) if $selectedflag[$charcnt] = 5 then EndIf sleep(10) if $selectedflag[$charcnt] = 6 then EndIf Sleep(10) need help on this i want to run all these without rewriting the content with only one number. Edited November 12, 2018 by yasha Link to comment Share on other sites More sharing options...
Subz Posted November 12, 2018 Share Posted November 12, 2018 I've already shown you how to do this with function and/or switch, however you need to post runable code. Link to comment Share on other sites More sharing options...
Trong Posted November 12, 2018 Share Posted November 12, 2018 The example code of the Subz is quite clear. If you do not want to rewrite the code, put it in the function and call it anywhere! $charcnt = 1 While $charcnt < 40 Local $currenValue = $selectedflag[$charcnt] If $currenValue = 1 Then _Task_1() ElseIf $currenValue = 2 Then _Task_2() ElseIf $currenValue = 3 Then _Task_1() _Task_2() EndIf Sleep(10) WEnd Func _Task_1() ; CODE 1 EndFunc ;==>_Task_1 Func _Task_2() ; CODE 2 EndFunc ;==>_Task_2 Func _Task_3() ; CODE 3 EndFunc ;==>_Task_3 Func _Task_4() ; CODE 4 EndFunc ;==>_Task_4 Regards, Link to comment Share on other sites More sharing options...
yasha Posted November 12, 2018 Author Share Posted November 12, 2018 12 minutes ago, VIP said: The example code of the Subz is quite clear. If you do not want to rewrite the code, put it in the function and call it anywhere! $charcnt = 1 While $charcnt < 40 Local $currenValue = $selectedflag[$charcnt] If $currenValue = 1 Then _Task_1() ElseIf $currenValue = 2 Then _Task_2() ElseIf $currenValue = 3 Then _Task_1() _Task_2() EndIf Sleep(10) WEnd Func _Task_1() ; CODE 1 EndFunc ;==>_Task_1 Func _Task_2() ; CODE 2 EndFunc ;==>_Task_2 Func _Task_3() ; CODE 3 EndFunc ;==>_Task_3 Func _Task_4() ; CODE 4 EndFunc ;==>_Task_4 so here is my code from top expandcollapse popup#include <ClipBoard.au3> #include <ClipBoard.au3> #include <array.au3> #include <Date.au3> #include <Excel.au3> #include <ExcelConstants.au3> #include <MsgBoxConstants.au3> $variable1 = TimerInit AutoItSetOption ( "WinTitleMatchMode",2) AutoItSetOption ( 'MouseCoordMode',0) $reportname = StringSplit(" ","") $reportname[1] = "1 SO" $reportname[2] = "2 Prod" $reportname[3] = "3 Pur" $reportname[4] = "4 Pro" $reportname[5] = "5 Claim" $reportname[6] = "6 Buy" $reportname[7] = "7 PR" $reportname[8= "8 all" $charcnt = 1 $reportname_show = "" while $reportname[$charcnt] <> " " $reportname_show = $reportname_show & @CR & $reportname[$charcnt] $charcnt = $charcnt + 1 WEnd $selection = InputBox("Baan Reports Selection",$reportname_show & @CR & @CR &"Please Enter selection as x y z, with 1 space in-between" & @CR,""," M",350,500,650,450) $charcnt = 1 $selected = "" $selectedflag = StringSplit(" ","") $reportname[0] = "" while $charcnt < 40 if int(Stringmid($selection, $charcnt,1)) >= 0 then if int(Stringmid($selection, $charcnt,2)) < 10 then $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,1))] $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,1)) $charcnt = $charcnt + 2 Else $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,2))] $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,2)) $charcnt = $charcnt + 3 EndIf EndIf WEnd $input = MsgBox(1, "", "Reports Selected -> START ALL RANGE:" & @CR & $selected & @CR & @CR &"Click Ok to proceed, Cancel to End") if $input = 2 Then Exit EndIf $sFolder = "" ; Create a constant variable in Local scope of the message to display in FileSelectFolder. Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. $sFileSelectFolder = FileSelectFolder($sMessage, $sFolder) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) EndIf $Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC $YY=StringFormat("%02i",@YEAR-2000) $MM=StringFormat("%02i",Int(@MON)) $DD=StringFormat("%02i",Int(@MDAY)) $Baan_exist = 0 If WinExists("Menu browser [User: ") then $Baan_exist = 1 EndIf $charcnt = 1 while $charcnt < 40 if $selectedflag[$charcnt] = 8 then if $selectedflag[$charcnt] = 1 then endif if $selectedflag[$charcnt] = 2 then endif if $selectedflag[$charcnt] = 3 then endif if $selectedflag[$charcnt] = 4 then endif if $selectedflag[$charcnt] = 5 then endif if $selectedflag[$charcnt] = 6 then endif if $selectedflag[$charcnt] = 7 then endif endif wend i use msg box and type out the program number. how do i add your func into this program ( this is a watered down version ) Link to comment Share on other sites More sharing options...
Trong Posted November 12, 2018 Share Posted November 12, 2018 I do not understand what you want up I can not edit your code! Can you say what you want to do? The order of execution, expected results. For example: 1. For selection list 2. Choose one of them 3. Select the folder 4. Perform tasks a, b, c 5. The result is X, Y, Z Regards, Link to comment Share on other sites More sharing options...
yasha Posted November 12, 2018 Author Share Posted November 12, 2018 (edited) so normally when i run auto it the selection window pops up there i type in 1 2 3 4 5 6 to run different programs each program can be run in any order. Sorry but $charcnt = $charcnt + 1 is missing from my program i forget to type it above befor wend. so i was looking for a way to only type 7 and run everything from 1 to 6 without me needing to type out the instructions for all 6 programs. the program instructions are confidential so if u want to test it u will need to sub it with your own so sorry about that. Edited November 12, 2018 by yasha Link to comment Share on other sites More sharing options...
Subz Posted November 12, 2018 Share Posted November 12, 2018 Alot comes down to what is between, can that be made into a function if $selectedflag[$charcnt] = 7 then endif yasha 1 Link to comment Share on other sites More sharing options...
yasha Posted November 12, 2018 Author Share Posted November 12, 2018 alright func worked. but it is messy is there a way other than func? thanks Link to comment Share on other sites More sharing options...
Trong Posted November 12, 2018 Share Posted November 12, 2018 Here is a complete GUI example: expandcollapse popup#include <ClipBoard.au3> #include <ClipBoard.au3> #include <array.au3> #include <Date.au3> #include <Excel.au3> #include <ExcelConstants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption('MouseCoordMode', 0) #Region ### START GUI section ### Form= Global $hGUI = GUICreate("Baan Reports", 517, 260, 338, 233) GUICtrlCreateGroup("Reports Selection", 8, 8, 489, 57) Global $Select_Cb1 = GUICtrlCreateCheckbox("1 SO", 24, 32, 55, 17) Global $Select_Cb2 = GUICtrlCreateCheckbox("2 Prod", 80, 32, 55, 17) Global $Select_Cb3 = GUICtrlCreateCheckbox("3 Pur", 136, 32, 55, 17) Global $Select_Cb4 = GUICtrlCreateCheckbox("4 Pro", 192, 32, 55, 17) Global $Select_Cb5 = GUICtrlCreateCheckbox("5 Claim", 248, 32, 55, 17) Global $Select_Cb6 = GUICtrlCreateCheckbox("6 Buy", 304, 32, 55, 17) Global $Select_Cb7 = GUICtrlCreateCheckbox("7 PR", 368, 32, 55, 17) Global $Select_Cb8 = GUICtrlCreateCheckbox("8 all", 432, 32, 55, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Select a Folder:", 8, 80, 78, 17, $SS_RIGHT) Global $Input_Folder = GUICtrlCreateInput(@DesktopDir & "\Report", 96, 76, 361, 21) Global $Button_SelectFolder = GUICtrlCreateButton("...", 464, 72, 27, 25) GUICtrlCreateLabel("Windows Tile:", 8, 112, 84, 17, $SS_RIGHT) Global $Input_WinTile = GUICtrlCreateInput("Menu browser [User: ", 96, 104, 393, 21) Global $Button_Start = GUICtrlCreateButton("START", 8, 136, 227, 49) Global $Button_Stop = GUICtrlCreateButton("STOP (ESC)", 256, 136, 171, 49) GUICtrlSetTip($Button_Stop, "Note: On started need Press Hotkey", "Key: ESC", 1) Global $Label_sStatus = GUICtrlCreateLabel("", 8, 200, 500, 17, -1, $GUI_WS_EX_PARENTDRAG) Global $Label_iStatus = GUICtrlCreateLabel("--- READY ----", 8, 232, 500, 17, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) Global $Button_Exit = GUICtrlCreateButton("EXIT (F4)", 448, 136, 57, 49) GUICtrlSetTip($Button_Exit, "Note: On started need Press Hotkey", "Key: F4", 1) GUISetState(@SW_SHOW) #EndRegion ### START GUI section ### Form= Global $nMsg, $iSelect_1 = 0, $iSelect_2 = 0, $iSelect_3 = 0, $iSelect_4 = 0, $iSelect_5 = 0, $iSelect_6 = 0, $iSelect_7 = 0, $iSelect_ALL = 0 Global $iSelectFolder, $iSelectWinTile, $iSTOP_Request = 0, $iSTARTED = 0 HotKeySet("{Esc}", "_STOP") HotKeySet("{F4}", "_Exit") _MAIN() Func _Task_1() _ShowLog("-Task 1: Woring...." & "", 1) ; CODE _ShowLog("-Task 1: END" & "", 1) Sleep(100) EndFunc ;==>_Task_1 Func _Task_2() _ShowLog("-Task 2: Woring...." & "", 1) ; CODE _ShowLog("-Task 2: END" & "", 1) Sleep(100) EndFunc ;==>_Task_2 Func _Task_3() _ShowLog("-Task 3: Woring...." & "", 1) ; CODE _ShowLog("-Task 3: END" & "", 1) Sleep(100) EndFunc ;==>_Task_3 Func _Task_4() _ShowLog("-Task 4: Woring...." & "", 1) ; CODE _ShowLog("-Task 4: END" & "", 1) Sleep(100) EndFunc ;==>_Task_4 Func _Task_5() _ShowLog("-Task 5: Woring...." & "", 1) ; CODE _ShowLog("-Task 5: END" & "", 1) Sleep(100) EndFunc ;==>_Task_5 Func _Task_6() _ShowLog("-Task 8: Woring...." & "", 1) ; CODE _ShowLog("-Task 8: END" & "", 1) Sleep(100) EndFunc ;==>_Task_6 Func _Task_7() _ShowLog("-Task 7: Woring...." & "", 1) ; CODE _ShowLog("-Task 7: END" & "", 1) Sleep(100) EndFunc ;==>_Task_7 Func _ShowLog($iLog, $OnUI = 0) ConsoleWrite($iLog & @CRLF) If $OnUI Then GUICtrlSetData($Label_iStatus, $iLog) EndFunc ;==>_ShowLog Func _START() If $iSTARTED = 1 Then Return SetError(-1, 0, 0) ; STARTED $iSTARTED = 1 ;~ Local $Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC ;~ Local $YY = StringFormat("%02i", @YEAR - 2000) ;~ Local $MM = StringFormat("%02i", Int(@MON)) ;~ Local $DD = StringFormat("%02i", Int(@MDAY)) Local $ReturnValue, $iError = 0 While _WindowsExist($iSelectWinTile) $ReturnValue = 0 $iError = 0 If $iSelect_ALL Then $ReturnValue = _Task_1() $iError = @error $ReturnValue += _Task_2() $iError = @error $ReturnValue += _Task_3() $iError = @error $ReturnValue += _Task_4() $iError = @error $ReturnValue += _Task_5() $iError = @error $ReturnValue += _Task_6() $iError = @error $ReturnValue += _Task_7() $iError = @error Else If $iSelect_1 Then $ReturnValue = _Task_1() $iError = @error EndIf If $iSelect_2 Then $ReturnValue = _Task_2() $iError = @error EndIf If $iSelect_3 Then $ReturnValue = _Task_3() $iError = @error EndIf If $iSelect_4 Then $ReturnValue = _Task_4() $iError = @error EndIf If $iSelect_5 Then $ReturnValue = _Task_5() $iError = @error EndIf If $iSelect_6 Then $ReturnValue = _Task_6() $iError = @error EndIf If $iSelect_7 Then $ReturnValue = _Task_7() $iError = @error EndIf EndIf ;~ _ShowLog("-$iSelectWinTile : " & $iSelectWinTile &"") ;~ _ShowLog("-$iSelect_1 : " & $iSelect_1 &"") ;~ _ShowLog("-$iSelect_2 : " & $iSelect_2 &"") ;~ _ShowLog("-$iSelect_3 : " & $iSelect_3 &"") ;~ _ShowLog("-$iSelect_4 : " & $iSelect_4 &"") ;~ _ShowLog("-$iSelect_5 : " & $iSelect_5 &"") ;~ _ShowLog("-$iSelect_6 : " & $iSelect_6 &"") ;~ _ShowLog("-$iSelect_7 : " & $iSelect_7 &"") ;~ _ShowLog("-$iSelect_ALL : " & $iSelect_ALL &"") ;~ _ShowLog("-----------------------------------" &"") If (($iError) Or ($ReturnValue = -1) Or ($iSTOP_Request = 1)) Then GUICtrlSetData($Label_iStatus, "--- STOPED ----") $iSTARTED = 0 Return SetError(0, -1, 0) EndIf WEnd $iSTARTED = 0 EndFunc ;==>_START Func _WindowsExist($iSelectWinTile) If Not WinExists($iSelectWinTile) Then MsgBox(48, "Error", 'The Windows "' & $iSelectWinTile & '" is Not Exists !') _ShowLog("! Error: The Windows " & $iSelectWinTile & " is Not Exists !") Return SetError(-1, 0, 0) EndIf Return 1 EndFunc ;==>_WindowsExist Func _STOP() If $iSTARTED = 0 Then MsgBox(64, "Error", "The process not STARTED for STOP !") Return 0 EndIf If $iSTOP_Request = 0 Then Local $ans = MsgBox(1 + 64, "STOP_Request", "Are you sure to STOP ?") If $ans = 1 Then _ShowLog("$iSTOP_Request: 1", 1) $iSTOP_Request = 1 EndIf EndIf EndFunc ;==>_STOP Func _GetInput() $iSelectFolder = "" $iSelectWinTile = "" $iSelect_1 = 0 $iSelect_2 = 0 $iSelect_3 = 0 $iSelect_4 = 0 $iSelect_5 = 0 $iSelect_6 = 0 $iSelect_7 = 0 $iSelect_ALL = 0 _ShowLog("-----------------------------------" & "") $iSelectFolder = GUICtrlRead($Input_Folder) $iSelectWinTile = GUICtrlRead($Input_WinTile) $iSelect_1 = (GUICtrlRead($Select_Cb1) = $GUI_CHECKED) $iSelect_2 = (GUICtrlRead($Select_Cb2) = $GUI_CHECKED) $iSelect_3 = (GUICtrlRead($Select_Cb3) = $GUI_CHECKED) $iSelect_4 = (GUICtrlRead($Select_Cb4) = $GUI_CHECKED) $iSelect_5 = (GUICtrlRead($Select_Cb5) = $GUI_CHECKED) $iSelect_6 = (GUICtrlRead($Select_Cb6) = $GUI_CHECKED) $iSelect_7 = (GUICtrlRead($Select_Cb7) = $GUI_CHECKED) If ($iSelect_1 = 1 And $iSelect_2 = 1 And $iSelect_3 = 1 And $iSelect_4 = 1 And $iSelect_5 = 1 And $iSelect_6 = 1 And $iSelect_7 = 1) Then $iSelect_ALL = 1 _ShowLog("-$iSelectFolder : " & $iSelectFolder & "") _ShowLog("-$iSelectWinTile : " & $iSelectWinTile & "") _ShowLog("-$iSelect_1 : " & $iSelect_1 & "") _ShowLog("-$iSelect_2 : " & $iSelect_2 & "") _ShowLog("-$iSelect_3 : " & $iSelect_3 & "") _ShowLog("-$iSelect_4 : " & $iSelect_4 & "") _ShowLog("-$iSelect_5 : " & $iSelect_5 & "") _ShowLog("-$iSelect_6 : " & $iSelect_6 & "") _ShowLog("-$iSelect_7 : " & $iSelect_7 & "") _ShowLog("-$iSelect_ALL : " & $iSelect_ALL & "") _ShowLog("-----------------------------------" & "") GUICtrlSetData($Label_sStatus, " CB1: " & $iSelect_1 & " CB2: " & $iSelect_2 & " CB3: " & $iSelect_3 & " CB4: " & $iSelect_4 & " CB5: " & $iSelect_5 & " CB6: " & $iSelect_6 & " CB7: " & $iSelect_7 & " SelectALL: " & $iSelect_ALL) EndFunc ;==>_GetInput Func _Exit() If $iSTARTED = 0 Then Exit Else Local $ans = MsgBox(1 + 64, "EXIT_Request", "Are you sure to EXIT ?") If $ans = 1 Then Exit EndIf EndFunc ;==>_Exit Func _MAIN() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Select_Cb8 If (GUICtrlRead($Select_Cb8) = $GUI_CHECKED) Then GUICtrlSetState($Select_Cb1, $GUI_CHECKED) GUICtrlSetState($Select_Cb2, $GUI_CHECKED) GUICtrlSetState($Select_Cb3, $GUI_CHECKED) GUICtrlSetState($Select_Cb4, $GUI_CHECKED) GUICtrlSetState($Select_Cb5, $GUI_CHECKED) GUICtrlSetState($Select_Cb6, $GUI_CHECKED) GUICtrlSetState($Select_Cb7, $GUI_CHECKED) Else GUICtrlSetState($Select_Cb1, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb2, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb3, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb4, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb5, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb6, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb7, $GUI_UNCHECKED) EndIf _GetInput() Case $Select_Cb1, $Select_Cb2, $Select_Cb3, $Select_Cb4, $Select_Cb5, $Select_Cb6, $Select_Cb7 _GetInput() If $iSelect_ALL = 1 Then GUICtrlSetState($Select_Cb8, $GUI_CHECKED) Else GUICtrlSetState($Select_Cb8, $GUI_UNCHECKED) EndIf Case $Button_SelectFolder Local $sFileSelectFolder = FileSelectFolder("Select a folder", @ScriptDir, 7) If @error Then ;~ MsgBox(48, "", "No folder was selected.") Else GUICtrlSetData($Input_Folder, $sFileSelectFolder) EndIf Case $Button_Start _GetInput() If (($iSelect_1 = 0) And ($iSelect_2 = 0) And ($iSelect_3 = 0) And ($iSelect_4 = 0) And ($iSelect_5 = 0) And ($iSelect_6 = 0) And ($iSelect_7 = 0) And ($iSelect_ALL = 0)) Then MsgBox(64, "Error", "You not selected any Option !") ContinueLoop EndIf If ((StringStripWS($iSelectFolder, 7) == "") Or (Not FileExists($iSelectFolder))) Then MsgBox(64, "Error", "The input folder not Selected Or not Exists !") ContinueLoop EndIf If (StringStripWS($iSelectWinTile, 7) == "") Then MsgBox(64, "Error", "The input Windows Tile is empty !") ContinueLoop EndIf GUICtrlSetData($Label_iStatus, "Working........") _START() GUICtrlSetData($Label_iStatus, "--- DONE ----") Case $Button_Stop _STOP() Case $GUI_EVENT_CLOSE, $Button_Exit _Exit() EndSwitch WEnd EndFunc ;==>_MAIN Wish you success! yasha 1 Regards, Link to comment Share on other sites More sharing options...
yasha Posted November 12, 2018 Author Share Posted November 12, 2018 38 minutes ago, VIP said: Here is a complete GUI example: expandcollapse popup#include <ClipBoard.au3> #include <ClipBoard.au3> #include <array.au3> #include <Date.au3> #include <Excel.au3> #include <ExcelConstants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption('MouseCoordMode', 0) #Region ### START GUI section ### Form= Global $hGUI = GUICreate("Baan Reports", 517, 260, 338, 233) GUICtrlCreateGroup("Reports Selection", 8, 8, 489, 57) Global $Select_Cb1 = GUICtrlCreateCheckbox("1 SO", 24, 32, 55, 17) Global $Select_Cb2 = GUICtrlCreateCheckbox("2 Prod", 80, 32, 55, 17) Global $Select_Cb3 = GUICtrlCreateCheckbox("3 Pur", 136, 32, 55, 17) Global $Select_Cb4 = GUICtrlCreateCheckbox("4 Pro", 192, 32, 55, 17) Global $Select_Cb5 = GUICtrlCreateCheckbox("5 Claim", 248, 32, 55, 17) Global $Select_Cb6 = GUICtrlCreateCheckbox("6 Buy", 304, 32, 55, 17) Global $Select_Cb7 = GUICtrlCreateCheckbox("7 PR", 368, 32, 55, 17) Global $Select_Cb8 = GUICtrlCreateCheckbox("8 all", 432, 32, 55, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Select a Folder:", 8, 80, 78, 17, $SS_RIGHT) Global $Input_Folder = GUICtrlCreateInput(@DesktopDir & "\Report", 96, 76, 361, 21) Global $Button_SelectFolder = GUICtrlCreateButton("...", 464, 72, 27, 25) GUICtrlCreateLabel("Windows Tile:", 8, 112, 84, 17, $SS_RIGHT) Global $Input_WinTile = GUICtrlCreateInput("Menu browser [User: ", 96, 104, 393, 21) Global $Button_Start = GUICtrlCreateButton("START", 8, 136, 227, 49) Global $Button_Stop = GUICtrlCreateButton("STOP (ESC)", 256, 136, 171, 49) GUICtrlSetTip($Button_Stop, "Note: On started need Press Hotkey", "Key: ESC", 1) Global $Label_sStatus = GUICtrlCreateLabel("", 8, 200, 500, 17, -1, $GUI_WS_EX_PARENTDRAG) Global $Label_iStatus = GUICtrlCreateLabel("--- READY ----", 8, 232, 500, 17, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) Global $Button_Exit = GUICtrlCreateButton("EXIT (F4)", 448, 136, 57, 49) GUICtrlSetTip($Button_Exit, "Note: On started need Press Hotkey", "Key: F4", 1) GUISetState(@SW_SHOW) #EndRegion ### START GUI section ### Form= Global $nMsg, $iSelect_1 = 0, $iSelect_2 = 0, $iSelect_3 = 0, $iSelect_4 = 0, $iSelect_5 = 0, $iSelect_6 = 0, $iSelect_7 = 0, $iSelect_ALL = 0 Global $iSelectFolder, $iSelectWinTile, $iSTOP_Request = 0, $iSTARTED = 0 HotKeySet("{Esc}", "_STOP") HotKeySet("{F4}", "_Exit") _MAIN() Func _Task_1() _ShowLog("-Task 1: Woring...." & "", 1) ; CODE _ShowLog("-Task 1: END" & "", 1) Sleep(100) EndFunc ;==>_Task_1 Func _Task_2() _ShowLog("-Task 2: Woring...." & "", 1) ; CODE _ShowLog("-Task 2: END" & "", 1) Sleep(100) EndFunc ;==>_Task_2 Func _Task_3() _ShowLog("-Task 3: Woring...." & "", 1) ; CODE _ShowLog("-Task 3: END" & "", 1) Sleep(100) EndFunc ;==>_Task_3 Func _Task_4() _ShowLog("-Task 4: Woring...." & "", 1) ; CODE _ShowLog("-Task 4: END" & "", 1) Sleep(100) EndFunc ;==>_Task_4 Func _Task_5() _ShowLog("-Task 5: Woring...." & "", 1) ; CODE _ShowLog("-Task 5: END" & "", 1) Sleep(100) EndFunc ;==>_Task_5 Func _Task_6() _ShowLog("-Task 8: Woring...." & "", 1) ; CODE _ShowLog("-Task 8: END" & "", 1) Sleep(100) EndFunc ;==>_Task_6 Func _Task_7() _ShowLog("-Task 7: Woring...." & "", 1) ; CODE _ShowLog("-Task 7: END" & "", 1) Sleep(100) EndFunc ;==>_Task_7 Func _ShowLog($iLog, $OnUI = 0) ConsoleWrite($iLog & @CRLF) If $OnUI Then GUICtrlSetData($Label_iStatus, $iLog) EndFunc ;==>_ShowLog Func _START() If $iSTARTED = 1 Then Return SetError(-1, 0, 0) ; STARTED $iSTARTED = 1 ;~ Local $Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC ;~ Local $YY = StringFormat("%02i", @YEAR - 2000) ;~ Local $MM = StringFormat("%02i", Int(@MON)) ;~ Local $DD = StringFormat("%02i", Int(@MDAY)) Local $ReturnValue, $iError = 0 While _WindowsExist($iSelectWinTile) $ReturnValue = 0 $iError = 0 If $iSelect_ALL Then $ReturnValue = _Task_1() $iError = @error $ReturnValue += _Task_2() $iError = @error $ReturnValue += _Task_3() $iError = @error $ReturnValue += _Task_4() $iError = @error $ReturnValue += _Task_5() $iError = @error $ReturnValue += _Task_6() $iError = @error $ReturnValue += _Task_7() $iError = @error Else If $iSelect_1 Then $ReturnValue = _Task_1() $iError = @error EndIf If $iSelect_2 Then $ReturnValue = _Task_2() $iError = @error EndIf If $iSelect_3 Then $ReturnValue = _Task_3() $iError = @error EndIf If $iSelect_4 Then $ReturnValue = _Task_4() $iError = @error EndIf If $iSelect_5 Then $ReturnValue = _Task_5() $iError = @error EndIf If $iSelect_6 Then $ReturnValue = _Task_6() $iError = @error EndIf If $iSelect_7 Then $ReturnValue = _Task_7() $iError = @error EndIf EndIf ;~ _ShowLog("-$iSelectWinTile : " & $iSelectWinTile &"") ;~ _ShowLog("-$iSelect_1 : " & $iSelect_1 &"") ;~ _ShowLog("-$iSelect_2 : " & $iSelect_2 &"") ;~ _ShowLog("-$iSelect_3 : " & $iSelect_3 &"") ;~ _ShowLog("-$iSelect_4 : " & $iSelect_4 &"") ;~ _ShowLog("-$iSelect_5 : " & $iSelect_5 &"") ;~ _ShowLog("-$iSelect_6 : " & $iSelect_6 &"") ;~ _ShowLog("-$iSelect_7 : " & $iSelect_7 &"") ;~ _ShowLog("-$iSelect_ALL : " & $iSelect_ALL &"") ;~ _ShowLog("-----------------------------------" &"") If (($iError) Or ($ReturnValue = -1) Or ($iSTOP_Request = 1)) Then GUICtrlSetData($Label_iStatus, "--- STOPED ----") $iSTARTED = 0 Return SetError(0, -1, 0) EndIf WEnd $iSTARTED = 0 EndFunc ;==>_START Func _WindowsExist($iSelectWinTile) If Not WinExists($iSelectWinTile) Then MsgBox(48, "Error", 'The Windows "' & $iSelectWinTile & '" is Not Exists !') _ShowLog("! Error: The Windows " & $iSelectWinTile & " is Not Exists !") Return SetError(-1, 0, 0) EndIf Return 1 EndFunc ;==>_WindowsExist Func _STOP() If $iSTARTED = 0 Then MsgBox(64, "Error", "The process not STARTED for STOP !") Return 0 EndIf If $iSTOP_Request = 0 Then Local $ans = MsgBox(1 + 64, "STOP_Request", "Are you sure to STOP ?") If $ans = 1 Then _ShowLog("$iSTOP_Request: 1", 1) $iSTOP_Request = 1 EndIf EndIf EndFunc ;==>_STOP Func _GetInput() $iSelectFolder = "" $iSelectWinTile = "" $iSelect_1 = 0 $iSelect_2 = 0 $iSelect_3 = 0 $iSelect_4 = 0 $iSelect_5 = 0 $iSelect_6 = 0 $iSelect_7 = 0 $iSelect_ALL = 0 _ShowLog("-----------------------------------" & "") $iSelectFolder = GUICtrlRead($Input_Folder) $iSelectWinTile = GUICtrlRead($Input_WinTile) $iSelect_1 = (GUICtrlRead($Select_Cb1) = $GUI_CHECKED) $iSelect_2 = (GUICtrlRead($Select_Cb2) = $GUI_CHECKED) $iSelect_3 = (GUICtrlRead($Select_Cb3) = $GUI_CHECKED) $iSelect_4 = (GUICtrlRead($Select_Cb4) = $GUI_CHECKED) $iSelect_5 = (GUICtrlRead($Select_Cb5) = $GUI_CHECKED) $iSelect_6 = (GUICtrlRead($Select_Cb6) = $GUI_CHECKED) $iSelect_7 = (GUICtrlRead($Select_Cb7) = $GUI_CHECKED) If ($iSelect_1 = 1 And $iSelect_2 = 1 And $iSelect_3 = 1 And $iSelect_4 = 1 And $iSelect_5 = 1 And $iSelect_6 = 1 And $iSelect_7 = 1) Then $iSelect_ALL = 1 _ShowLog("-$iSelectFolder : " & $iSelectFolder & "") _ShowLog("-$iSelectWinTile : " & $iSelectWinTile & "") _ShowLog("-$iSelect_1 : " & $iSelect_1 & "") _ShowLog("-$iSelect_2 : " & $iSelect_2 & "") _ShowLog("-$iSelect_3 : " & $iSelect_3 & "") _ShowLog("-$iSelect_4 : " & $iSelect_4 & "") _ShowLog("-$iSelect_5 : " & $iSelect_5 & "") _ShowLog("-$iSelect_6 : " & $iSelect_6 & "") _ShowLog("-$iSelect_7 : " & $iSelect_7 & "") _ShowLog("-$iSelect_ALL : " & $iSelect_ALL & "") _ShowLog("-----------------------------------" & "") GUICtrlSetData($Label_sStatus, " CB1: " & $iSelect_1 & " CB2: " & $iSelect_2 & " CB3: " & $iSelect_3 & " CB4: " & $iSelect_4 & " CB5: " & $iSelect_5 & " CB6: " & $iSelect_6 & " CB7: " & $iSelect_7 & " SelectALL: " & $iSelect_ALL) EndFunc ;==>_GetInput Func _Exit() If $iSTARTED = 0 Then Exit Else Local $ans = MsgBox(1 + 64, "EXIT_Request", "Are you sure to EXIT ?") If $ans = 1 Then Exit EndIf EndFunc ;==>_Exit Func _MAIN() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Select_Cb8 If (GUICtrlRead($Select_Cb8) = $GUI_CHECKED) Then GUICtrlSetState($Select_Cb1, $GUI_CHECKED) GUICtrlSetState($Select_Cb2, $GUI_CHECKED) GUICtrlSetState($Select_Cb3, $GUI_CHECKED) GUICtrlSetState($Select_Cb4, $GUI_CHECKED) GUICtrlSetState($Select_Cb5, $GUI_CHECKED) GUICtrlSetState($Select_Cb6, $GUI_CHECKED) GUICtrlSetState($Select_Cb7, $GUI_CHECKED) Else GUICtrlSetState($Select_Cb1, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb2, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb3, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb4, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb5, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb6, $GUI_UNCHECKED) GUICtrlSetState($Select_Cb7, $GUI_UNCHECKED) EndIf _GetInput() Case $Select_Cb1, $Select_Cb2, $Select_Cb3, $Select_Cb4, $Select_Cb5, $Select_Cb6, $Select_Cb7 _GetInput() If $iSelect_ALL = 1 Then GUICtrlSetState($Select_Cb8, $GUI_CHECKED) Else GUICtrlSetState($Select_Cb8, $GUI_UNCHECKED) EndIf Case $Button_SelectFolder Local $sFileSelectFolder = FileSelectFolder("Select a folder", @ScriptDir, 7) If @error Then ;~ MsgBox(48, "", "No folder was selected.") Else GUICtrlSetData($Input_Folder, $sFileSelectFolder) EndIf Case $Button_Start _GetInput() If (($iSelect_1 = 0) And ($iSelect_2 = 0) And ($iSelect_3 = 0) And ($iSelect_4 = 0) And ($iSelect_5 = 0) And ($iSelect_6 = 0) And ($iSelect_7 = 0) And ($iSelect_ALL = 0)) Then MsgBox(64, "Error", "You not selected any Option !") ContinueLoop EndIf If ((StringStripWS($iSelectFolder, 7) == "") Or (Not FileExists($iSelectFolder))) Then MsgBox(64, "Error", "The input folder not Selected Or not Exists !") ContinueLoop EndIf If (StringStripWS($iSelectWinTile, 7) == "") Then MsgBox(64, "Error", "The input Windows Tile is empty !") ContinueLoop EndIf GUICtrlSetData($Label_iStatus, "Working........") _START() GUICtrlSetData($Label_iStatus, "--- DONE ----") Case $Button_Stop _STOP() Case $GUI_EVENT_CLOSE, $Button_Exit _Exit() EndSwitch WEnd EndFunc ;==>_MAIN Wish you success! thanks a lot i think this looks better than what i was going for. 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