Bert Posted January 1, 2008 Share Posted January 1, 2008 Example script that works fine: expandcollapse popup$warning_size = 1000 $final_size = 800 if $warning_size > $finalTH_size Then MsgBox(0, $warning_size, $finalTH_size&" color") EndIf if $warning_size < $finalTH_size Then MsgBox(0, $warning_size, $finalTH_size) EndIfoÝ÷ غ(«mçîËb¢táë!¢WEv¥Jx⦶ũ©ë®*m~º&Öîµú+²æ¬¢{az^«h®+'ßÛp¢¹"§¶ºw-âØ^¨§±Êâ¦Ò'¶º.nW¬-x¦VyÙ¬º1zȧ¶¡×¢·©¢»p«pjÈZ¦§x¢çǶ¯j[ºÈ§Ø^±ë[ºÛh^»§)ඬr¸©µhZ´Z½æ¥²è¶'v+"~Ø^½©nzôߧÞ"²ÈhÂ)àqÜ(®Kw¢~+l,s¶§Öëy©,ZǺȧØb°hm±ç¢´ ë-mè§ØbrAn[®*mjëh×6;; Script will have includes from the original design. Opt("PixelCoordMode", 0) #include<Date.au3> #Include<GuiConstants.au3> #Include<File.au3> #include<Array.au3> #include<Process.au3> #include<Misc.au3> DIM $gui1 DIM $savepath DIM $ini = @ScriptDir & "/PCT_tool.ini" DIM $PCT_Template Global $LETTER ;----------------------------------------------------------------------------------------------------------- ;creates letter list for filter $LETTER = StringSplit('ABCDEFGHIJKLMNOPQRSTUVWXYZ', '') ;----------------------------------------------------------------------------------------------------------- $gui1 = GuiCreate("PC Transplant Automation Tool", 785, 326,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $lable_1 = GUICtrlCreateLabel("PC Transplant Template file: ", 10,9, 220, 20) $lable_2 = GUICtrlCreateLabel("Final Backup Location: ", 10,60, 220, 20) $lable_3 = GUICtrlCreateLabel("Final Backup Location Free Space Available For Use: ", 10,110, 77, 60) $lable_4 = GUICtrlCreateLabel("Free Space on C: ",10,200, 130, 20) $lable_5 = GUICtrlCreateLabel("Selected Profile Size: ",10,250, 90, 40) $lable_5 = GUICtrlCreateLabel("Size Warning for Final Backup Location: ",110,110, 75, 50) $button_1 = GUICtrlCreateButton("Change", 315, 74, 50, 22);template select: $button_2 = GUICtrlCreateButton("Change", 315, 24, 50, 22);Final Backup Location: $button_3 = GUICtrlCreateButton("DLF select", 500, 24, 70, 22) ;Folder filter $button_4 = GUICtrlCreateButton("Set", 157, 165, 23, 20) ;Folder filter $Edit_1 = GUICtrlCreateList("", 590, 70, 180, 230);list the profiles $Edit_2 = GUICtrlCreateInput("", 10, 25, 300, 20, $ES_READONLY) ;Final backup location display $Edit_3 = GUICtrlCreateInput("", 10, 76, 300, 20, $ES_READONLY) ;PC Transplant Template file display $Edit_4 = GUICtrlCreateInput("", 10, 165, 80, 20, $ES_READONLY) ;drive space on Final bacup location $Edit_5 = GUICtrlCreateInput("", 10, 215, 80, 20, $ES_READONLY) ;drive space on C: $Edit_6 = GUICtrlCreateInput("", 10, 280, 80, 20, $ES_READONLY) ;selected profile: $Edit_7 = GUICtrlCreateInput("",110, 165, 40, 20, $ES_READONLY) ;Final backup Warning size GUICtrlSetData($edit_2,IniRead($ini, @UserName, '2','')) GUICtrlSetData($edit_3,IniRead($ini, @UserName, '1','')) GUICtrlSetData($edit_7,IniRead($ini, @UserName, '3','1000')) $group_1 = GUICtrlCreateGroup("", 3, 0, 370, 51) $group_2 = GUICtrlCreateGroup("", 3, 50, 370, 52) $group_3 = GUICtrlCreateGroup("", 3, 100, 187, 91) $group_4 = GUICtrlCreateGroup("", 3, 190, 95, 51) $group_5 = GUICtrlCreateGroup("", 3, 240, 95, 68) _DriveFreeSpace(IniRead($ini, @UserName, '1',''), $Edit_4) _DriveFreeSpace("C:", $Edit_5) _profile() GUICtrlSetTip($button_2,"You can change what drives are allowed"&@CR&"to receive backups." ) GuiSetState() _ThresholdFinalSpace() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button_2 _TemplateSelect() Case $msg = $button_1 _FinalBackupDestinationselect() Case $msg = $button_3 _DriveLetterFilter() Case $msg = $button_4 _Set_Threshold_final_space() Case $msg = $Edit_1 $read_list = GUICtrlRead($Edit_1) _ProfileSizeCheck($read_list) Case Else ;;; EndSelect WEnd Exit Func _Set_Threshold_final_space() $input_size = InputBox("Set Drive Space Warning", "Enter in the minumn amount of space required in the Final" _ & " Backup location. If you leave this blank, the value will" _ & " set to default.") if @error = 1 then GUICtrlSetData($edit_7, "500") IniWrite($ini, @UserName, "3","500") _ThresholdFinalSpace() endif $digit = StringIsDigit($input_size) if $digit = 0 then Return Else GUICtrlSetData($edit_7, $input_size) IniWrite($ini, @UserName, "3",$input_size) _ThresholdFinalSpace() endif EndFunc func _ThresholdFinalSpace() local $final_size $Final_Dest_size = GUICtrlRead($Edit_4) $warning_size = GUICtrlRead($Edit_7) $String_GB = StringInStr($Final_Dest_size, "GB") $String_MB = StringInStr($Final_Dest_size, "MB") if $String_GB > 0 Then $Trim_GB = StringTrimRight($Final_Dest_size, 3) $finalTH_size = ($Trim_GB * 1024) EndIf if $String_MB > 0 Then $Trim_MB = StringTrimRight($Final_Dest_size, 3) $final_size = $Trim_MB EndIf $chkstring = StringIsDigit($warning_size) if $warning_size > $final_size Then GUICtrlSetBkColor($Edit_4, 0xff0000) MsgBox(0, $warning_size, $final_size&" red") EndIf if $warning_size < $final_size Then GUICtrlSetBkColor($Edit_4, PixelGetColor(90,254)) MsgBox(0, "","$warning_size is: "&$warning_size& @CRLF _ &"Final_size is: "&$final_size& @CRLF _ &"Formula to test: $warning_size < $final_size"&@CRLF _ &""&@CRLF _ &"If warning is larger than size, how can I see this message?") EndIf EndFunc func _ProfileSizeCheck($profile) $dir = DirGetSize("C:\Documents and Settings\"&$profile) $roundKB = Round($dir/ 1024 , 2) $profile_sizecheckF = $roundKB GUICtrlSetData($edit_6,$roundKB&" KB") if $roundKB > 1024 then $roundMB = Round($dir/ 1024 / 1024, 2) GUICtrlSetData($edit_6,$roundMB&" MB") if $roundMB > 2048 then $roundGB = Round($roundMB/ 1024, 2) GUICtrlSetData($edit_6,$roundGB&" GB") EndIf EndIf EndFunc func _FinalBackupDestinationselect() While 1 $savepath = FileSelectFolder("Select the final location the PC Transplant backups " _ &"will be placed", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 7) $filter1 = IniRead($ini, "3", "1", "") $ccc = StringInStr($filter1, StringStripWS(StringLeft($savepath, 3), 8)) Select case $savepath = "" ExitLoop case $ccc > 0 And DriveGetType(StringLeft($savepath, 3)) <> 'CDROM' IniWrite($ini, @UserName, "1", $savepath) GUICtrlSetData($edit_3, $savepath) ExitLoop Case Else if StringLeft($savepath, 2) = "\\" then $qst = MsgBox(16, 'Error', "You can not select """ & $savepath & """. If you " _ &"wish to use this location, you will need to map a drive."&@CRLF&""&@CRLF&"Do you wish to map a drive?") if $qst = 6 then MsgBox(0, "", "add tool to map drive here") Else MsgBox(16, 'Error', "The Final PCT backup location you select: "&@CRLF _ &""&@CRLF&" """&$savepath&""""&@CRLF&""&@CRLF&"is not authorized to store backup files. Please select again.") EndIf EndSelect WEnd _DriveFreeSpace($savepath,$Edit_4 ) EndFunc func _DriveLetterFilter() GuiSetState(@SW_HIDE, $gui1) Dim $Checkbox_[UBound($LETTER)] $gui2 = GuiCreate("Drive Letter Filter", 190, 320,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $iniD = IniReadSection($ini, "2") if @error = 1 Then $Data = 1 For $x = 1 To 26 If $x = 4 Then $Data = 4 IniWrite($ini, '2', $x, $Data) Next $iniD = IniReadSection($ini, "2") EndIf $x1 = 20 $x2 = 5 For $x = 1 To $LETTER[0] if $x = 14 then $x1 = 130 $x2 = 5 endif $Checkbox_[$x] = GuiCtrlCreateCheckbox($LETTER[$x] & ":\", $x1, $x2, 50, 20) if $iniD[$x][1] = 1 then GUICtrlSetState($Checkbox_[$x], $GUI_CHECKED) $x2 += 20 Next $button_D1 = GUICtrlCreateButton("OK", 20, 280, 70, 30) $button_D2 = GUICtrlCreateButton("Cancel", 100, 280, 70, 30) GuiSetState(@SW_SHOW, $gui2) MsgBox(0, "Information", "Any drive letter ckecked will not be permitted to store backup data", 10) While 1 $msgD = GuiGetMsg() Select Case $msgD = $GUI_EVENT_CLOSE or $msgD = $button_D2 ExitLoop Case $msgD = $Checkbox_[3] if GUICtrlRead($Checkbox_[3]) = 4 then $warning = MsgBox(20, "WARNING!", "Allowing Drive C: to receive backups is not recommended." _ &"It can contribute to a loss of the backup file."&@CRLF _ &""&@CRLF _ &"Are you sure you want to do this?") If $warning = 7 then GUICtrlSetState($Checkbox_[3], $GUI_CHECKED) EndIf Case $msgD = $button_D1 local $h = '' For $x = 1 To UBound($Checkbox_) - 1 IniWrite($ini, '2', $x, GUICtrlRead($Checkbox_[$x])) if GUICtrlRead($Checkbox_[$x]) = 4 then $h &= $LETTER[$x] & ":\" Next IniWrite($ini, "3", "1", $h) exitloop Case Else ;;; EndSelect WEnd GUIDelete($gui2) GuiSetState(@SW_SHOW, $gui1) IniWrite($ini, @UserName, "1", "Not set") GUICtrlSetData($edit_3, "Not set") _FinalBackupDestinationselect() EndFunc Func _TemplateSelect() $PCT_Template = FileOpenDialog("Select the PCT file you wish to use.", @ScriptDir&"\bin\", "'PC Transplant template'(*.pbt)", 1 + 2) If @error Then MsgBox(4096 + 262144, $PCT_Template, "No File(s) chosen") Else $cutstring = stringinstr($PCT_Template, "\", 0, -1) ;17 $cut = StringTrimleft($PCT_Template, $cutstring) $FC = FileCopy($PCT_Template, @ScriptDir&"\bin\",9) IniWrite($ini, @UserName, "2", $cut) GUICtrlSetData($Edit_2, $cut) EndIf EndFunc Func _DriveFreeSpace($drive, $control) $drivecheck = DriveSpaceFree($drive) $roundit = Round($drivecheck,0) if $roundit >2048 then $GB = ($roundit/1024) $GB_rounded = Round($GB,2) GUICtrlSetData($control, $GB_rounded&" GB") Else GUICtrlSetData($control, $roundit&" MB") EndIf EndFunc ;If $drsc2 < $ini7 Then MsgBox(16 + 262144, "WARNING!", "FDL is less than 500 MB in ;space available. You run the risk of losing the backup.") ;use $drsc2 for return ;~ EndFunc ;==>_Drivespacecheckfinal func _profile() $Profile_path = 'c:\documents and settings\' $Profile_first = FileFindFirstFile($Profile_path & '*.*') $Profile_filter = 'AdminAdministratorAllUsersdefaultuserLocalServiceNetworkService_admini$!$!svcAdmin' $Profile_return = '' While 1 $Profile_found = FileFindNextFile($Profile_first) If @error Then ExitLoop If StringInStr($Profile_filter, StringStripWS($Profile_found, 8)) Or _ Not StringInStr(FileGetAttrib($Profile_path & $Profile_found), 'D') Then ContinueLoop $Profile_return &= $Profile_found & '|' WEnd $Profile_return = StringTrimRight($Profile_return, 1) GUICtrlSetData($Edit_1, $Profile_return) EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
martin Posted January 1, 2008 Share Posted January 1, 2008 (edited) I haven't tried your code but my guess is that you are using the > and < operators on strings believing they are numbers. I suspect that if you change to If Number($string1) > Number($string2) then etc, then the problem will go away. Edited January 1, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Bert Posted January 1, 2008 Author Share Posted January 1, 2008 ok, I'll try that. I wonder why the code thinks it isn't numbers. Would this have something to do with the variable having "MB in it at first, then stripping it out? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
martin Posted January 1, 2008 Share Posted January 1, 2008 (edited) ok, I'll try that. I wonder why the code thinks it isn't numbers. Would this have something to do with the variable having "MB in it at first, then stripping it out?I think it's because you read it from an edit which returns a string. Edited January 1, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Bert Posted January 1, 2008 Author Share Posted January 1, 2008 did what you suggested. problem solved. Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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