Advertisement
Ralle1976

New WINDOWS_SETTINGS Func

Aug 3rd, 2019
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.26 KB | None | 0 0
  1. Func CheckPath($handel = 0)
  2.     Local $__Path = GUICtrlRead($handel)
  3.     IF  Not StringRegExp($__Path, "((?<!.)([a-zA-Z]\:\\)(?!\s)(([\w-+.]*((?<!\s)(\s{1})(?!\\)|(?<!\\)(\\{1})(?!\s))*)*)(\\?)(?!.))", 0) Or _
  4.         Not FileExists($__Path) Then
  5.         GUICtrlSetData($handel, "")
  6.         Return False
  7.     EndIf
  8.     Return True
  9. EndFunc
  10.  
  11. Func CheckX($string = "")
  12.     Local $StringLen = StringLen($string)
  13.     If  Not StringInStr($string, ' ') Then Return 2
  14.     IF $StringLen < 3 Then Return 3
  15.     IF $StringLen > 19 Then Return 4
  16.     Return 1
  17. EndFunc
  18.  
  19. Func CheckCharacterName($handel)
  20.     Local $name = GUICtrlRead($handel)
  21.     $name = StringRegExpReplace($name, "\s$", "")
  22.     Local $State = CheckX($name)
  23.     GUICtrlSetData($handel, $name);Make Sure the User not set aWhite Space at the end of tipping https://regex101.com/r/EiRCTB/1
  24.     Local $_error_array = [4, "Check is tells there is a Space, there is a no lower 3 and not higher len than 19!", "No Space Found", "StringLen is lower 3", "StringLen is higher 19"]
  25.     ConsoleWrite($_error_array[$State] & @CRLF)
  26.     IF $State > 1 Then
  27.         GUICtrlSetData($handel, "")
  28.         Return False
  29.     EndIf
  30.     Local $StringSplit = StringSplit($name, " ")
  31.     If IsArray($StringSplit) Then
  32.         IF $StringSplit[0] > 1 Then
  33.             For $n = 1 To $StringSplit[0]
  34.                 IF $StringSplit[$n] <> "" Then
  35.                     IF Not  StringRegExp($StringSplit[$n], "(^[A-Z])([a-z]+)", 0) Then
  36.                         GUICtrlSetData($handel, "")
  37.                         Return False
  38.                     EndIf
  39.                 EndIf
  40.             Next
  41.         EndIf
  42.     EndIf
  43.     Return True
  44. EndFunc
  45.  
  46. Func CheckStringFromInput($handel, $ClassCheck = 0)
  47.     Local $String = GUICtrlRead($handel)
  48.     If $String = "" Then Return False
  49.     Switch($ClassCheck)
  50.         Case 1
  51.             IF Not StringRegExp($String,"(\[\w+:\w+; \w+:\d+\])", 0) Then
  52.                 GUICtrlSetData($handel ,"")
  53.                 Return False; https://regex101.com/r/auydEg/1
  54.             EndIf
  55.         Case 2
  56.             ;https://de.wikipedia.org/wiki/Dateiname
  57. ;~          $String = StringRegExpReplace($String, '[?*<>,\\+:=\/";\[\]\|]', "")
  58.             IF StringRegExp($String,'[?*<>,\\+:=\/";\[\]\|]+', 0) Then
  59.                 GUICtrlSetData($handel ,"")
  60.                 Return False
  61.             EndIf
  62.         Case 3
  63.             ;https://de.wikipedia.org/wiki/Dateiname
  64.             IF StringRegExp($String,"[\w\`\'\{\}\(\)\%\&\-\@\#\$\~\!\_\^. ]+", 0) Then Return False;
  65.     EndSwitch
  66.     Return True
  67. EndFunc
  68.  
  69. Func ChanceArrayData(byref $Array, $index = 0 , $Handel = 0)
  70. $Array[$index] = GUICtrlRead($Handel)
  71. GUICtrlSetData($Handel, "")
  72. EndFunc
  73.  
  74. Func WINDOWS_SETTINGS($debug = False)
  75.     Local $_array =     [ _
  76.                         [7], _
  77.                         ["CheckPath($GUI_ADD_GW_WAY)", "GW Path is not a Path or dont exists!", "ChanceArrayData($GuiPathToGw, $A, $GUI_ADD_GW_WAY)"], _
  78.                         ["CheckPath($GUI_ADD_NEW_BOT_WAY)", "Bot Path is not a Path or dont exists!", "ChanceArrayData($GuiPathToBot, $A, $GUI_ADD_NEW_BOT_WAY)"], _
  79.                         ["CheckCharacterName($GUI_ADD_NICK_NAME)", "The Charactername not equal with the rules!", "ChanceArrayData($GuiNameOfCharacter, $A, $GUI_ADD_NICK_NAME)"], _
  80.                         ["CheckStringFromInput($GUI_ADD_BOT_NAME, 2)", "No Bot Name is set or" & @CRLF & "it holds Symbolys wich not are allowed!", "ChanceArrayData($GuiNameOfBot, $A, $GUI_ADD_BOT_NAME)"], _
  81.                         ["CheckStringFromInput($GUI_ADD_BOT_NAME_SELECTOR, 1)", "No Classname for NameSelector is set or Format is not allwoed", "ChanceArrayData($GuiAutoClickNameSelector, $A, $GUI_ADD_BOT_NAME_SELECTOR)"], _
  82.                         ["CheckStringFromInput($GUI_ADD_BOT_START_BUTTON, 1)", "No Classname of Start Button is set or Format is not allwoed", "ChanceArrayData($GuiAutoClickStartButton, $A, $GUI_ADD_BOT_START_BUTTON)"], _
  83.                         ["CheckStringFromInput($GUI_ADD_BOT_DISABLE_RENDERING_BUTTON, 1)", "No Classname of Disable Rendering is set or Format is not allwoed", "ChanceArrayData($GUiAutoClickDisableRendering, $A, $GUI_ADD_BOT_DISABLE_RENDERING_BUTTON)"]]
  84.     Local $count = 0, $Info = ""
  85.     For $i = 1 To $_array[0][0]
  86.         Local $State = Execute($_array[$i][0])
  87.         ConsoleWrite($_array[$i][0] & " State = " & $State &  @CRLF)
  88.         IF Not $State Then
  89.             $count += 1
  90.             $Info &= @CRLF & $_array[$i][1] & (($i < $_array[0][0]) ? (@CRLF) : (''))
  91.         EndIf
  92.     Next
  93.     If $count > 0 Then
  94.         MsgBox(0, "Info", $Info, 8, $guiMainWorkingControl)
  95.     Else
  96.         For $i = 1 To $_array[0][0]
  97.             Execute($_array[$i][2])
  98.         Next
  99.         GUISetState(False, $subGuiSettings)
  100.         ADD_NEW_ACCOUNT()
  101.     EndIf
  102.     GUICtrlSetState($GUI_BUTTON_ADD_ACCOUNT, $GUI_ENABLE)
  103. EndFunc   ;==>WINDOWS_SETTINGS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement