TuMiM Posted December 10, 2009 Share Posted December 10, 2009 I have the following script which when runbrings up the GUI but won't respond to any button click or program close. Any idea what is wrong with it? expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIConstants.au3> #Include <Date.au3> #include <File.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> $NowDate=(@MON & @MDAY & stringright(@YEAR, 2)) Opt("GUIOnEventMode",1) If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("Miranda SCH Copy", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Button_1 = GuiCtrlCreateButton("Copy Files", 130, 75, 130, 30) ;GUICtrlSetOnEvent($Button_1,"Copy") $Label_2 = GuiCtrlCreateLabel("Please click on the button below to Copy files named with the date below", 50, 15, 300, 25, $SS_CENTER ) ;$Overwrite = GUICtrlCreateCheckbox ("Overwrite", 300, 80, 120, 20) ;GUICtrlSetState(-1, $overwrite) $list1= GUICtrlCreateListView (" Files copied ", 80, 125, 225, 150) $input = GUICtrlCreateinput ($NowDate, 175, 45, 50, 20) $Checktree = GuiCtrlCreateTreeView(320, 125, 75, 150, $TVS_CHECKBOXES) $LA = GuiCtrlCreateTreeViewItem("LA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DV = GuiCtrlCreateTreeViewItem("DV", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PB = GuiCtrlCreateTreeViewItem("PB", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DE = GuiCtrlCreateTreeViewItem("DE", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KB = GuiCtrlCreateTreeViewItem("KB", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $AR = GuiCtrlCreateTreeViewItem("AR", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DM = GuiCtrlCreateTreeViewItem("DM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PM = GuiCtrlCreateTreeViewItem("PM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KA = GuiCtrlCreateTreeViewItem("KA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DK = GuiCtrlCreateTreeViewItem("DK", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $BL = GuiCtrlCreateTreeViewItem("BL", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PA = GuiCtrlCreateTreeViewItem("PA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PN = GuiCtrlCreateTreeViewItem("PN", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KM = GuiCtrlCreateTreeViewItem("KM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) GuiSetState(@SW_SHOW) Global $aAction[$KM + 1] $aAction[$LA] = "MirCopy" $aAction[$DV] = "MirCopy" $aAction[$PB] = "MirCopy" $aAction[$DE] = "MirCopy" $aAction[$KB] = "MirCopy" $aAction[$AR] = "MirCopy" $aAction[$DM] = "MirCopy" $aAction[$PM] = "MirCopy" $aAction[$KA] = "MirCopy" $aAction[$DK] = "MirCopy" $aAction[$BL] = "MirCopy" $aAction[$PA] = "MirCopy" $aAction[$PN] = "MirCopy" $aAction[$KM] = "MirCopy" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button_1 ;SplashTextOn("File Copying", "Copying Files, Please wait", 250, 35) ;FileDelete("c:" & "\Log\MirandaCOPY.txt") ;DriveMapAdd("", "\\172.28.209.144\Playlists", 0, "bservices", "Broadcast01") For $i = $LA To $KM If BitAnd(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then Call($aAction[$i]) Next ;SplashOff() EndSwitch WEnd ;--------------- Functions --------------- Func MirCopy() $UpInput = GUICtrlRead($Input) $source="\\172.28.206.7\Bservices\SCH" $destination="\\172.28.209.144\playlists\Probel Lists\LISTS FOR PARSING" $test=$aAction[$i] MsgBox(4096, "Test", @ComSpec & ' /c xcopy "' & $source & '\' & $test & & $Upinput & '*.SCH" "' & $destination & '" /Y>c:\Log\MirandaCopy.txt', 10) ;Runwait(@ComSpec & ' /c xcopy "' & $source & '\LA' & $Upinput & '*.SCH" "' & $destination & '" /Y>c:\Log\MirandaCopy.txt',"", @SW_Hide) EndFunc Link to comment Share on other sites More sharing options...
martin Posted December 10, 2009 Share Posted December 10, 2009 OnEvent mode stops GuiGetMsg from working, but you aren't using OnEvent mode so remove the Opt line which sets it. 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...
Fire Posted December 10, 2009 Share Posted December 10, 2009 I`m not guru on Autoit but i try help to you.Here is expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #Include <Date.au3> #include <File.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> $NowDate=(@MON & @MDAY & stringright(@YEAR, 2)) Opt("GUIOnEventMode",0) local $SS_CENTER ;If Not IsDeclared($WS_CLIPSIBLINGS) Then $WS_CLIPSIBLINGS GuiCreate("Miranda SCH Copy", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Button_1 = GuiCtrlCreateButton("Copy Files", 130, 75, 130, 30) ;GUICtrlSetOnEvent($Button_1,"Copy") $Label_2 = GuiCtrlCreateLabel("Please click on the button below to Copy files named with the date below", 50, 15, 300, 25, $SS_CENTER ) ;$Overwrite = GUICtrlCreateCheckbox ("Overwrite", 300, 80, 120, 20) ;GUICtrlSetState(-1, $overwrite) $list1= GUICtrlCreateListView (" Files copied ", 80, 125, 225, 150) $input = GUICtrlCreateinput ($NowDate, 175, 45, 50, 20) $Checktree = GuiCtrlCreateTreeView(320, 125, 75, 150, $TVS_CHECKBOXES) $LA = GuiCtrlCreateTreeViewItem("LA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DV = GuiCtrlCreateTreeViewItem("DV", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PB = GuiCtrlCreateTreeViewItem("PB", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DE = GuiCtrlCreateTreeViewItem("DE", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KB = GuiCtrlCreateTreeViewItem("KB", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $AR = GuiCtrlCreateTreeViewItem("AR", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DM = GuiCtrlCreateTreeViewItem("DM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PM = GuiCtrlCreateTreeViewItem("PM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KA = GuiCtrlCreateTreeViewItem("KA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DK = GuiCtrlCreateTreeViewItem("DK", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $BL = GuiCtrlCreateTreeViewItem("BL", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PA = GuiCtrlCreateTreeViewItem("PA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PN = GuiCtrlCreateTreeViewItem("PN", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KM = GuiCtrlCreateTreeViewItem("KM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) GuiSetState(@SW_SHOW) Global $aAction[$KM + 1] $aAction[$LA] = "MirCopy" $aAction[$DV] = "MirCopy" $aAction[$PB] = "MirCopy" $aAction[$DE] = "MirCopy" $aAction[$KB] = "MirCopy" $aAction[$AR] = "MirCopy" $aAction[$DM] = "MirCopy" $aAction[$PM] = "MirCopy" $aAction[$KA] = "MirCopy" $aAction[$DK] = "MirCopy" $aAction[$BL] = "MirCopy" $aAction[$PA] = "MirCopy" $aAction[$PN] = "MirCopy" $aAction[$KM] = "MirCopy" local $nMsg = GUIGetMsg() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 ;SplashTextOn("File Copying", "Copying Files, Please wait", 250, 35) ;FileDelete("c:" & "\Log\MirandaCOPY.txt") ;DriveMapAdd("", "\\172.28.209.144\Playlists", 0, "bservices", "Broadcast01") For $i = $LA To $KM If BitAnd(GUICtrlRead($i), $GUI_CHECKED) Then Call($aAction[$i]) Next ;SplashOff() EndSwitch WEnd ;--------------- Functions --------------- Func MirCopy() $UpInput = GUICtrlRead($Input) $source="\\172.28.206.7\Bservices\SCH" $destination="\\172.28.209.144\playlists\Probel Lists\LISTS FOR PARSING" $test=$aAction[$i] $slash ="\" $filetype ="*.SCH" MsgBox(4096, "Test","Test") $a =Run("cmd.exe /c xcopy.exe" & $source & $slash & $test & $Upinput & $filetype & $destination,"", @SW_ENABLE) FileWrite("aaa.txt",$a) ;Runwait(@ComSpec & ' /c xcopy "' & $source & '\LA' & $Upinput & '*.SCH" "' & $destination & '" /Y>c:\Log\MirandaCopy.txt',"", @SW_Hide) EndFunc [size="5"] [/size] Link to comment Share on other sites More sharing options...
TuMiM Posted December 10, 2009 Author Share Posted December 10, 2009 I`m not guru on Autoit but i try help to you.Here is expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #Include <Date.au3> #include <File.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> $NowDate=(@MON & @MDAY & stringright(@YEAR, 2)) Opt("GUIOnEventMode",0) local $SS_CENTER ;If Not IsDeclared($WS_CLIPSIBLINGS) Then $WS_CLIPSIBLINGS GuiCreate("Miranda SCH Copy", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Button_1 = GuiCtrlCreateButton("Copy Files", 130, 75, 130, 30) ;GUICtrlSetOnEvent($Button_1,"Copy") $Label_2 = GuiCtrlCreateLabel("Please click on the button below to Copy files named with the date below", 50, 15, 300, 25, $SS_CENTER ) ;$Overwrite = GUICtrlCreateCheckbox ("Overwrite", 300, 80, 120, 20) ;GUICtrlSetState(-1, $overwrite) $list1= GUICtrlCreateListView (" Files copied ", 80, 125, 225, 150) $input = GUICtrlCreateinput ($NowDate, 175, 45, 50, 20) $Checktree = GuiCtrlCreateTreeView(320, 125, 75, 150, $TVS_CHECKBOXES) $LA = GuiCtrlCreateTreeViewItem("LA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DV = GuiCtrlCreateTreeViewItem("DV", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PB = GuiCtrlCreateTreeViewItem("PB", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DE = GuiCtrlCreateTreeViewItem("DE", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KB = GuiCtrlCreateTreeViewItem("KB", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $AR = GuiCtrlCreateTreeViewItem("AR", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DM = GuiCtrlCreateTreeViewItem("DM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PM = GuiCtrlCreateTreeViewItem("PM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KA = GuiCtrlCreateTreeViewItem("KA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $DK = GuiCtrlCreateTreeViewItem("DK", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $BL = GuiCtrlCreateTreeViewItem("BL", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PA = GuiCtrlCreateTreeViewItem("PA", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $PN = GuiCtrlCreateTreeViewItem("PN", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) $KM = GuiCtrlCreateTreeViewItem("KM", $Checktree) GuiCtrlSetState(-1, $GUI_CHECKED) GuiSetState(@SW_SHOW) Global $aAction[$KM + 1] $aAction[$LA] = "MirCopy" $aAction[$DV] = "MirCopy" $aAction[$PB] = "MirCopy" $aAction[$DE] = "MirCopy" $aAction[$KB] = "MirCopy" $aAction[$AR] = "MirCopy" $aAction[$DM] = "MirCopy" $aAction[$PM] = "MirCopy" $aAction[$KA] = "MirCopy" $aAction[$DK] = "MirCopy" $aAction[$BL] = "MirCopy" $aAction[$PA] = "MirCopy" $aAction[$PN] = "MirCopy" $aAction[$KM] = "MirCopy" local $nMsg = GUIGetMsg() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 ;SplashTextOn("File Copying", "Copying Files, Please wait", 250, 35) ;FileDelete("c:" & "\Log\MirandaCOPY.txt") ;DriveMapAdd("", "\\172.28.209.144\Playlists", 0, "bservices", "Broadcast01") For $i = $LA To $KM If BitAnd(GUICtrlRead($i), $GUI_CHECKED) Then Call($aAction[$i]) Next ;SplashOff() EndSwitch WEnd ;--------------- Functions --------------- Func MirCopy() $UpInput = GUICtrlRead($Input) $source="\\172.28.206.7\Bservices\SCH" $destination="\\172.28.209.144\playlists\Probel Lists\LISTS FOR PARSING" $test=$aAction[$i] $slash ="\" $filetype ="*.SCH" MsgBox(4096, "Test","Test") $a =Run("cmd.exe /c xcopy.exe" & $source & $slash & $test & $Upinput & $filetype & $destination,"", @SW_ENABLE) FileWrite("aaa.txt",$a) ;Runwait(@ComSpec & ' /c xcopy "' & $source & '\LA' & $Upinput & '*.SCH" "' & $destination & '" /Y>c:\Log\MirandaCopy.txt',"", @SW_Hide) EndFunc Thanks guys, that fixed it but one more question. How do i get the checkbox it's reading into a variable? So basically i was trying to get variable $test to equal the name of the checkbox it was looking at. So if LA was check $test should equal LA, next if DV was checked $test should equal DV etc. Link to comment Share on other sites More sharing options...
Fire Posted December 10, 2009 Share Posted December 10, 2009 May be somethink like this: #Region ### START Koda GUI section ### Form=Form1.kxf\Form1.kxf $Form1 = GUICreate("Form1", 633, 447, 268, 151) $test=GUICtrlCreateInput("", 168, 64, 193, 21) $Checkbox1 = GUICtrlCreateCheckbox("", 408, 64, 185, 17) $LA=100 $Button1 = GUICtrlCreateButton("Button1", 192, 168, 113, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 if BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then $LA=GUICtrlRead($test) ;now $LA IS $TEST MsgBox(64, "Msg", "Now $LA is " & GUICtrlRead($test)) Else MsgBox(64, "MSG2", "$LA IS NOT EQUAL TO $test " & "$LA IS 100") EndIf EndSwitch WEnd [size="5"] [/size] Link to comment Share on other sites More sharing options...
TuMiM Posted December 10, 2009 Author Share Posted December 10, 2009 May be somethink like this: #Region ### START Koda GUI section ### Form=Form1.kxf\Form1.kxf $Form1 = GUICreate("Form1", 633, 447, 268, 151) $test=GUICtrlCreateInput("", 168, 64, 193, 21) $Checkbox1 = GUICtrlCreateCheckbox("", 408, 64, 185, 17) $LA=100 $Button1 = GUICtrlCreateButton("Button1", 192, 168, 113, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 if BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then $LA=GUICtrlRead($test) ;now $LA IS $TEST MsgBox(64, "Msg", "Now $LA is " & GUICtrlRead($test)) Else MsgBox(64, "MSG2", "$LA IS NOT EQUAL TO $test " & "$LA IS 100") EndIf EndSwitch WEnd Nah. That won't work. That will only solve the first 2 not the rest of the list. Link to comment Share on other sites More sharing options...
TuMiM Posted December 21, 2009 Author Share Posted December 21, 2009 So is there any way to get variable $test to equal the name of the checkbox it was looking at. So if LA was check $test should equal LA, next if DV was checked $test should equal DV etc. or do they equal numbers now because of the for statement? 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