Jump to content

russell

Active Members
  • Posts

    158
  • Joined

  • Last visited

russell's Achievements

Prodigy

Prodigy (4/7)

0

Reputation

  1. Thankyou, ill try that now
  2. I was making a GUI to transfer files from my USB stick in my Raspberry Pi to a HDD hooked up to the Pi. I have that much of the code working but im tring to make a progress bar for the file transfer using the file size and the destionations orginal size comparison. My problem lyes in the progress bar, the example from help wont work inside my script nor do i know how to use my vaules (file sizes) to make the bar move. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\Downloads\Pi.ico #AutoIt3Wrapper_Outfile=Dads File Transfer\Pi Fast File.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Local $lixsource Global $destination Opt("GUIOnEventMode", 1); Change to OnEvent mode GUICreate("Pi Fast File v1.20", 440, 160) ;GUICtrlCreateLabel("This will Run your code", 40, 10) ;GUICtrlCreateLabel("Select the drive", 140, 42) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Sourcetxt = GUICtrlCreateLabel("Thumb Drive", 16, 24, 65, 17) $SourceCombo = GUICtrlCreateCombo("(Source Drive)", 205, 20, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "DAD'S 4GB|DAD'S 29GB|Russells 29GB") $sourcedirtxt = GUICtrlCreateLabel("Thumb Drive Directory", 16, 52, 120, 17) $sourcedirinput = GUICtrlCreateInput("(Source directory)", 130, 48, 220, 20) $browsebutton = GUICtrlCreateButton("Browse", 360, 48, 70, 20) GUICtrlSetOnEvent($browsebutton, "BROWSEButton") $DirorFilestxt = GUICtrlCreateLabel("Copy folder or just it's content?", 16, 80, 150, 17) $DirorFilesCombo = GUICtrlCreateCombo("Content", 215, 76, 135, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Folder+Content") $Destinationdirtxt = GUICtrlCreateLabel("WD MyBook Directory", 16, 107, 120, 17) $Destinationdirinput = GUICtrlCreateInput("(Destination Directory)", 130, 103, 220, 20) $browsebutton2 = GUICtrlCreateButton("Browse", 360, 103, 70, 20) GUICtrlSetOnEvent($browsebutton2, "BROWSEButton2") $okbutton = GUICtrlCreateButton("OK", 140, 130, 70, 20) GUICtrlSetOnEvent($okbutton, "OKButton") $exitbutton = GUICtrlCreateButton("EXIT", 240, 130, 70, 20) GUICtrlSetOnEvent($exitbutton, "EXITButton") While 1 Sleep(1000) WEnd Func BROWSEButton() $searchsource = GUICtrlRead($SourceCombo) If $searchsource = "DAD'S 4GB" Then $winsource = "DADS 4GB" $lixsource = "DADS\ 4GB/" EndIf If $searchsource = "DAD'S 29GB" Then $winsource = "DADS29GB" $lixsource = "DADS29GB/" EndIf If $searchsource = "Russells 29GB" Then $winsource = "CC45-BCB4" $lixsource = "CC45-BCB4/" EndIf global $sourceselFile1 global $sourceselFile1 = FileSelectFolder("","\\RASPBMC\devices\" & $winsource) If Not @error Then GUICtrlSetData($sourcedirinput, $sourceselFile1) EndIf EndFunc ;==>BROWSEButton Func BROWSEButton2() global $desselFiled1 ;$selFile = FileOpenDialog("Browse the exe", "C:\", "(*.exe)") ;\\RASPBMC\devices\CC45-BCB4 global $desselFiled1 = FileSelectFolder("","\\RASPBMC\devices\WD MyBook") If Not @error Then GUICtrlSetData($Destinationdirinput, $desselFiled1) EndIf EndFunc ;==>BROWSEButton Func OKButton() ;If $desselFiled = "\\RASPBMC\devices\WD MyBook\Kids Programs-Movies" Then $destination = "/Kids\ Programs-Movies" ;If $desselFiled = "\\RASPBMC\devices\WD MyBook\Movies" Then $destination = "/Movies" ;If $desselFiled = "\\RASPBMC\devices\WD MyBook\Music" Then $destination = "/Music" ;If $desselFiled = "\\RASPBMC\devices\WD MyBook\TV Shows - Series - Specials" Then $destination = "/TV\ Shows\ -\ Series\ -\ Specials" ;If $desselFiled = "\\RASPBMC\devices\WD MyBook\Offload" Then $destination = "/Offload" $sourceselFile = StringTrimLeft($sourceselFile1,18) ;cuts the //RBPMC/blabla bla out leaving only the select dir $sourceselFile = StringReplace($sourceselFile, "\", "/") ;turns backslashes slashes (windows) into forwardslashes (linux) $sourceselFile = StringReplace($sourceselFile, " ","\ ") ;replaces spaces with \(space) $desselFiled = StringTrimLeft($desselFiled1,18) ;cuts the //RBPMC/blabla bla out leaving only the select dir $desselFiled = StringReplace($desselFiled, "\", "/") ;turns backslashes slashes (windows) into forwardslashes (linux) global $desselFiled = StringReplace($desselFiled, " ","\ ") ;replaces spaces with \(space) global $Action = "cp -R " global $CPFilesorDir = GUICtrlRead ($DirorFilesCombo) ;BlockInput (1) ;disables user input Sleep (1000) ConsoleWrite(_getDOSOutput(Doit()) & @CRLF) EndFunc ;==>OKButton Func EXITButton() Exit EndFunc ;==>EXITButton Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked Func _getDOSOutput($command) Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, '', @SW_HIDE, 2 + 4) While 1 $text &= StdoutRead($Pid, False, False) If @error Then ExitLoop Sleep(10) WEnd Return StringStripWS($text, 7) EndFunc ;==>_getDOSOutpu ;Opt("WinTitleMatchMode", 4) Func Doit() #cs ToolTip ("Establishing Connection") Run("C:\WINDOWS\system32\cmd.exe") Sleep (3000) $handle = WinGetHandle("") $array = WinGetPos ( $handle , "" ) WinMove($handle, "",(@DesktopWidth/2)-($array[2]/2),(@DesktopHeight/2)-($array[3]/2)) Send("cd /putty") Send ("{Enter}") Send ("plink -v -ssh pi@192.168.1.165") Send ("{Enter}") Sleep (1000) Send ("raspberry") Send ("{Enter}") ToolTip ("Allowing Connection to catchup") Sleep(6000) ToolTip ("Issuing Transfer Command") Sleep (2000) Opt("SendKeyDelay", 80) Send ("cd /media/") Send ("{Enter}") Sleep(2000) If $CPFilesorDir = "Folder+Content" Then Send ($Action & $sourceselFile & " "& $desselFiled) ElseIf $CPFilesorDir = "Content" Then Send ("cd " & $sourceselFile) Send ("{Enter}") Sleep (1000) Send ($Action & "*" & " /media/" & $desselFiled) ;Send ($Action & "/media/" & $sourceselFile & "/" & " "& "/media/WD\ MyBook" & $desselFiled) EndIf Send ("{Enter}") BlockInput (0) ;enables user input MsgBox (48,"You have control","Your keyboard and mouse are now enabled. Please wait for the DOS window to complete befor closing the DOS window",5) #ce GUIDelete("Pi Fast File v1.20") Progress() EndFunc Func Progress2() Local $SourceSize = DirGetSize($sourceselFile1) ; this will denote size not size on disk Local $DestSize1st = DirGetSize($desselFiled1) $Progress = GUICreate("Progress", 211, 78, -1, -1) $Progressbar = GUICtrlCreateProgress(24, 32, 150, 16, $PBS_SMOOTH) $TransferStatustxt = GUICtrlCreateLabel("Transfer Status", 64, 8, 76, 17) GUISetState(@SW_SHOW) Local $statusofprogress $DestSize = DirGetSize($desselFiled1) $FullCopy = ($DestSize1st+$SourceSize) If ($DestSize) = $FullCopy Then $statusofprogress = 100 EndFunc Func Progress() GUIDelete("Pi Fast File v1.20") Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m GUICreate("Progress", 220, 100, -1, -1) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20) GUICtrlSetColor(-1, 32250); not working with Windows XP Style $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $wait = 20; wait 20ms for next progressstep $s = 0; progressbar-saveposition Do $msg = GUIGetMsg() If $msg = $button Then GUICtrlSetData($button, "Stop") For $i = $s To 100 If GUICtrlRead($progressbar1) = 50 Then MsgBox(0, "Info", "The half is done...", 1) $m = GUIGetMsg() If $m = -3 Then ExitLoop If $m = $button Then GUICtrlSetData($button, "Next") $s = $i;save the current bar-position to $s ExitLoop Else $s = 0 GUICtrlSetData($progressbar1, $i) GUICtrlSetData($progressbar2, (100 - $i)) Sleep($wait) EndIf Next If $i > 100 Then ; $s=0 GUICtrlSetData($button, "Start") EndIf EndIf Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example
  3. I made this to open notepads.exe and the below code works i just reliazed while playing around that i have a serious problem i cant find a solution to. I wanted to reffrence the "$handle" of the created notepads. I tried "$handle($r)" and serveral other combinations only to fail. The problem lies here: "$handle = WinGetHandle ("Untitled - Notepad" & $r)" becuase its recreating this over and over i cant define a new $handle uniqe to each widows that i can later reffence. If i were to use lets say 3 in the input box. How would i at the end have 3 notepad windows defined like $handle1,$handle2,$handle3? I am either way over thinking this or am truly stumped. If you run something like 14 windows you begin to see the problem #include <Array.au3> #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Input Length=2, Width=20, Height=20 If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer $sInputBoxAnswer = InputBox("Notepad","Enter desiered notepad windows",""," 2","20","20","-1","-1") Select Case @Error = 0 ;OK - The string returned is valid Case @Error = 1 ;The Cancel button was pushed Case @Error = 3 ;The InputBox failed to open EndSelect #EndRegion --- CodeWizard generated code End --- Dim $handle local $arr[$sInputBoxAnswer] $r=0 Do Notepad () $r = $r+1 Until $r = UBound($arr) $r =0 Do WinActivate ("Window " & $r) Send ("I am window number " & $r) Sleep (1000) $r = $r+1 Until $r = UBound($arr) Func Notepad () ShellExecute("Notepad.exe") Sleep(1000) WinActive ("Untitled - Notepad") $handle = WinGetHandle ("Untitled - Notepad" & $r) WinMove ($handle,"" ,0,0) WinSetTitle ($handle,"","Window " & $r) Sleep (1000) EndFunc
  4. found it, numlock on and (-) on numlock pad
  5. I use to presss a key to make the highlighted text as a comment (not code anymore). I cant find what this is called nor the key. When i look at my code it has ;~ next to all the times i did this, anyone remember the key?
  6. UEZ thankyou, i shall study and try to master this. Melba23 thankyou for the guidance where to start my skills. Im using this to make a unique computer id, that string of numbers is bits of data from CPU,hdd etc. Thankyou both so much
  7. update of progress #include <String.au3> #include <Array.au3> $var='A7601000aFBFBEFB33528985' Local $array1 = _StringExplode($var, "", 0) _ArrayDisplay($array1, "StringExplode 0") LettersToNumbers() MsgBox (0,'',$var) ;=============================================================================== Func LettersToNumbers() If $var = 'A' Then $var = 1 If $var = 'B' Then $var = 2 If $var = 'C' Then $var = 3 If $var = 'D' Then $var = 4 If $var = 'E' Then $var = 5 If $var = 'F' Then $var = 6 If $var = 'G' Then $var = 7 If $var = 'H' Then $var = 8 If $var = 'I' Then $var = 9 If $var = 'J' Then $var = 10 If $var = 'K' Then $var = 11 If $var = 'L' Then $var = 12 If $var = 'M' Then $var = 13 If $var = 'N' Then $var = 14 If $var = 'O' Then $var = 15 If $var = 'P' Then $var = 16 If $var = 'Q' Then $var = 17 If $var = 'R' Then $var = 18 If $var = 'S' Then $var = 19 If $var = 'T' Then $var = 20 If $var = 'U' Then $var = 21 If $var = 'V' Then $var = 22 If $var = 'W' Then $var = 23 If $var = 'X' Then $var = 24 If $var = 'Y' Then $var = 25 If $var = 'Z' Then $var = 26 EndFunc ;===============================================================================
  8. I was woundering how i would set this up: I a a varibale that has letters and numbers, the lenght of the variable can change. I was wanting to convert the letters to a number so it is all numbers. I'm pretty sure ill have to make it a string but then im kinda lost. $var='A7601000aFBFBEFB33528985' LettersToNumbers() ;=============================================================================== Func LettersToNumbers() If $var = 'A' Then $var = 1 If $var = 'B' Then $var = 2 If $var = 'C' Then $var = 3 If $var = 'D' Then $var = 4 If $var = 'E' Then $var = 5 If $var = 'F' Then $var = 6 If $var = 'G' Then $var = 7 If $var = 'H' Then $var = 8 If $var = 'I' Then $var = 9 If $var = 'J' Then $var = 10 If $var = 'K' Then $var = 11 If $var = 'L' Then $var = 12 If $var = 'M' Then $var = 13 If $var = 'N' Then $var = 14 If $var = 'O' Then $var = 15 If $var = 'P' Then $var = 16 If $var = 'Q' Then $var = 17 If $var = 'R' Then $var = 18 If $var = 'S' Then $var = 19 If $var = 'T' Then $var = 20 If $var = 'U' Then $var = 21 If $var = 'V' Then $var = 22 If $var = 'W' Then $var = 23 If $var = 'X' Then $var = 24 If $var = 'Y' Then $var = 25 If $var = 'Z' Then $var = 26 MsgBox (0,'',$var) EndFunc ;===============================================================================
  9. Is there a way to update a record?
  10. I wanting to declair a varibale as time from an internet server. I dont know how to really do this but if heard that most use port 13. is what im using as a template but its a lil over my head. Can anyone assist? In aa nut shell i need a command that ask the server what time it is so i can make that a variable.
  11. thank you very much
  12. I wrote a script that makes several GUI's on one i have it set to contuie the script afer 'OK' is pressed. How do i get it to close that GUI and still contiue...i know i cant use exit or the script will terminate.
  13. figured it out, it was server side
  14. im tring to connect to my local SQL server (using wamp) and i get the error "Return $oConnectionobj.execute ($sQuery) Return $oConnectionobj.execute ($sQuery)^ ERROR ->23:10:44 AutoIT3.exe ended.rc:1" I editied the config.php file for the SQL server to use (username:root, pass: 'blank') but i cant see my error in the script. Can anyone help me? #include "MySQL.au3" Dim $NameList Dim $UserName = "root" Dim $Password = "" Dim $Database = "accounts" Dim $MySQLServerName = "localhost" Dim $TableName = "table" Dim $ColumnNames[7] ;Dim $NewGuest[6] Dim $Column = "CusNum" ;Dim $RecordID = "3" $ColumnNames[0]= "CusNum" $ColumnNames[1]= "UsrNm" $ColumnNames[2]= "PsWd" $ColumnNames[3]= "PPID" $ColumnNames[4]= "PayDate" $ColumnNames[5]= "ExpoDate" $ColumnNames[6]= "allCount" $SQLInstance = _MySQLConnect ($UserName, $Password, $Database, $MySQLServerName) DisplayTable() _MySQLEnd ($SQLInstance) #region Functions Func DisplayTable() $NameList = "" $SQLCode = "SELECT * FROM Accounts" $TableContents = _Query ($SQLInstance, $SQLCode) With $TableContents While Not .EOF $NameList &= .Fields ("UsrNm").value & " " & .Fields ("PsWd").value & @CRLF .MoveNext WEnd EndWith ;MsgBox(0,"Guest List",$NameList) EndFunc #endregion
  15. I posted a basic script below, im trying to get the GUICtrlSetTip to instead of showing beside the mouse, show in the window labeled "Info Windows". Folks i'm stumped #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("My title", 460, 440, 189, 129) GUISetCursor (2) GUISetFont(8, 400, 0, "Mufferaw") GUISetBkColor(0xA6CAF0) $Group5 = GUICtrlCreateGroup("Customizable Safteys", 16, 0, 409, 145) $field1 = GUICtrlCreateLabel("Field 1", 24, 24, 100, 18) $input1 = GUICtrlCreateInput("55", 136, 16, 25, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "hint 1") $field2 = GUICtrlCreateLabel("Field 2", 24, 48, 125, 18) $input2 = GUICtrlCreateInput("55", 152, 40, 25, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "hint 2") $field3 = GUICtrlCreateLabel("Field 3", 24, 72, 132, 18) $input3 = GUICtrlCreateInput("15", 160, 72, 25, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "hint 3") $field4 = GUICtrlCreateLabel("Field 4", 208, 16, 93, 18) $input4 = GUICtrlCreateInput("15", 312, 16, 25, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "hint 4") $field5 = GUICtrlCreateLabel("Field 5", 208, 48, 101, 18) $input5 = GUICtrlCreateInput("600", 312, 48, 30, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "input5") $field6 = GUICtrlCreateLabel("Field 6", 208, 72, 103, 18) $input6 = GUICtrlCreateInput("20", 320, 72, 25, 22, BitOR ($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "input6") GUICtrlCreateGroup("", -99, -99, 1, 1) $InfoWindows = GUICtrlCreateGroup("Information Windows", 40, 152, 377, 241) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
×
×
  • Create New...