Ghost21 Posted April 26, 2007 Share Posted April 26, 2007 All I want is to wait so when the button is pushed then run the commands... its driving me nuts help would be great... CODE: $Button_1 = GUICtrlCreateButton("Submit", 72, 80, 209, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) ;GUISetState() #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Select Case $Button_1 <> GUIGetMsg() $a = _ReplaceStringInFile($file, $szSearchString1, $szReplaceString1, $fCaseness = 0, $fOccurance = 1) $b = _ReplaceStringInFile($file, $szSearchString2, $szReplaceString2, $fCaseness = 0, $fOccurance = 1) $c = _ReplaceStringInFile($file, $szSearchString3, $szReplaceString3, $fCaseness = 0, $fOccurance = 1) $d = _ReplaceStringInFile($file, $szSearchString4, $szReplaceString4, $fCaseness = 0, $fOccurance = 1) $e = _ReplaceStringInFile($file, $szSearchString5, $szReplaceString5, $fCaseness = 0, $fOccurance = 1) $f = _ReplaceStringInFile($file, $szSearchString6, $szReplaceString6, $fCaseness = 0, $fOccurance = 1) $g = _ReplaceStringInFile($file, $szSearchString7, $szReplaceString7, $fCaseness = 0, $fOccurance = 1) FileCopy($file, "\\server\" & @UserName & "$" & "\mail\", 9) Sleep(1000) FileDelete($file) call("install") Exit EndSelect WEnd HELP PLEASE!!!!! Link to comment Share on other sites More sharing options...
Gabburd Posted April 26, 2007 Share Posted April 26, 2007 There's no reason you need to have both a switch and a select Try changing these lines: EndSwitch Select Case $Button_1 <> GUIGetMsg() And change your EndSelect to an EndSwitch Link to comment Share on other sites More sharing options...
Ghost21 Posted April 26, 2007 Author Share Posted April 26, 2007 There's no reason you need to have both a switch and a select Try changing these lines: EndSwitch Select Case $Button_1 <> GUIGetMsg() And change your EndSelect to an EndSwitch Nope still just sits there $Button_1 = GUICtrlCreateButton("Submit", 72, 80, 209, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 $a = _ReplaceStringInFile($file, $szSearchString1, $szReplaceString1, $fCaseness = 0, $fOccurance = 1) $b = _ReplaceStringInFile($file, $szSearchString2, $szReplaceString2, $fCaseness = 0, $fOccurance = 1) $c = _ReplaceStringInFile($file, $szSearchString3, $szReplaceString3, $fCaseness = 0, $fOccurance = 1) $d = _ReplaceStringInFile($file, $szSearchString4, $szReplaceString4, $fCaseness = 0, $fOccurance = 1) $e = _ReplaceStringInFile($file, $szSearchString5, $szReplaceString5, $fCaseness = 0, $fOccurance = 1) $f = _ReplaceStringInFile($file, $szSearchString6, $szReplaceString6, $fCaseness = 0, $fOccurance = 1) $g = _ReplaceStringInFile($file, $szSearchString7, $szReplaceString7, $fCaseness = 0, $fOccurance = 1) FileCopy($file, "\\purcell\" & @UserName & "$" & "\mail\", 9) Sleep(1000) FileDelete($file) call("install") Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Gabburd Posted April 26, 2007 Share Posted April 26, 2007 You also need to call GUICreate at the beginning, I assumed that you already had one farther up in your code. Link to comment Share on other sites More sharing options...
Ghost21 Posted April 26, 2007 Author Share Posted April 26, 2007 yeap... Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 26, 2007 Share Posted April 26, 2007 This makes it a runnable example, at least: 1. You don't name the input variables of the function when setting them, just pass the values you want for them. 2. Call isn't need to run a function unless you have a highly unusual need to name it by a variable string. 3. Need a GuiCreate(). 4. Arrays are your friends. Say it with me: "Arrays are my friends..." expandcollapse popup#include <guiconstants.au3> #include <array.au3> #include <file.au3> ; Create arrays of search and replace strings Global $avSearch[1] = [0], $avReplace[1] = [0] _ArrayAdd($avSearch, "SearchString1") _ArrayAdd($avReplace, "ReplaceString1") _ArrayAdd($avSearch, "SearchString2") _ArrayAdd($avReplace, "ReplaceString2") _ArrayAdd($avSearch, "SearchString3") _ArrayAdd($avReplace, "ReplaceString3") _ArrayAdd($avSearch, "SearchString4") _ArrayAdd($avReplace, "ReplaceString4") _ArrayAdd($avSearch, "SearchString5") _ArrayAdd($avReplace, "ReplaceString5") _ArrayAdd($avSearch, "SearchString6") _ArrayAdd($avReplace, "ReplaceString6") _ArrayAdd($avSearch, "SearchString7") _ArrayAdd($avReplace, "ReplaceString7") $avSearch[0] = UBound($avSearch) - 1 $avReplace[0] = UBound($avReplace) - 1 $file = "C:\Temp\Whatever.txt" ; Create GUI $hGUI = GUICreate("Unknown title", 400, 200) $Button_1 = GUICtrlCreateButton("Submit", 72, 80, 209, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) ; Message loop for GUI While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 For $a = 1 To $avSearch[0] _ReplaceStringInFile($file, $avSearch[$a], $avReplace[$a], 0, 1) Next FileCopy($file, "\\purcell\" & @UserName & "$" & "\mail\", 9) Sleep(1000) FileDelete($file) _Install() Exit EndSwitch WEnd Func _Install() MsgBox(64, "Debug", "Called _Install()", 5) EndFunc ;==>_Install Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Ghost21 Posted April 26, 2007 Author Share Posted April 26, 2007 This makes it a runnable example, at least: 1. You don't name the input variables of the function when setting them, just pass the values you want for them. 2. Call isn't need to run a function unless you have a highly unusual need to name it by a variable string. 3. Need a GuiCreate(). 4. Arrays are your friends. Say it with me: "Arrays are my friends..." expandcollapse popup#include <guiconstants.au3> #include <array.au3> #include <file.au3> ; Create arrays of search and replace strings Global $avSearch[1] = [0], $avReplace[1] = [0] _ArrayAdd($avSearch, "SearchString1") _ArrayAdd($avReplace, "ReplaceString1") _ArrayAdd($avSearch, "SearchString2") _ArrayAdd($avReplace, "ReplaceString2") _ArrayAdd($avSearch, "SearchString3") _ArrayAdd($avReplace, "ReplaceString3") _ArrayAdd($avSearch, "SearchString4") _ArrayAdd($avReplace, "ReplaceString4") _ArrayAdd($avSearch, "SearchString5") _ArrayAdd($avReplace, "ReplaceString5") _ArrayAdd($avSearch, "SearchString6") _ArrayAdd($avReplace, "ReplaceString6") _ArrayAdd($avSearch, "SearchString7") _ArrayAdd($avReplace, "ReplaceString7") $avSearch[0] = UBound($avSearch) - 1 $avReplace[0] = UBound($avReplace) - 1 $file = "C:\Temp\Whatever.txt" ; Create GUI $hGUI = GUICreate("Unknown title", 400, 200) $Button_1 = GUICtrlCreateButton("Submit", 72, 80, 209, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) ; Message loop for GUI While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_1 For $a = 1 To $avSearch[0] _ReplaceStringInFile($file, $avSearch[$a], $avReplace[$a], 0, 1) Next FileCopy($file, "\\purcell\" & @UserName & "$" & "\mail\", 9) Sleep(1000) FileDelete($file) _Install() Exit EndSwitch WEnd Func _Install() MsgBox(64, "Debug", "Called _Install()", 5) EndFunc ;==>_Install WOW thankyou very much. But I would like to understand at what point does this reconize that the button is pushed down ??? Because between my code and yours it seems to look like it does the same thing except yours is fancy... What am I missing that mine doesn't see that the button is pushed ???? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 26, 2007 Share Posted April 26, 2007 I would like to understand at what point does this reconize that the button is pushed down ???Inside the While/WEnd loop, the current GUI message is read by '$nMsg = $GUIGetMsg()'. Most cycles, $nMsg = 0, because 0 means nothing happened. If the GUI close button (X at top right corner) was clicked then $nMsg = $GUI_EVENT_CLOSE. When a control is clicked, the control ID number is returned. You saved the control ID when you created the button as $Button_1. So when $nMsg = $Button_1 then the button was clicked. In this particular script, a Switch/Case/EndSwitch is used to test the possible values of $nMsg.Hope that helps! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Ghost21 Posted April 26, 2007 Author Share Posted April 26, 2007 Inside the While/WEnd loop, the current GUI message is read by '$nMsg = $GUIGetMsg()'. Most cycles, $nMsg = 0, because 0 means nothing happened. If the GUI close button (X at top right corner) was clicked then $nMsg = $GUI_EVENT_CLOSE. When a control is clicked, the control ID number is returned. You saved the control ID when you created the button as $Button_1. So when $nMsg = $Button_1 then the button was clicked. In this particular script, a Switch/Case/EndSwitch is used to test the possible values of $nMsg.Hope that helps! OH YES... Finally thankyou so much.. I wish the help file was as good as that explaination... thanks again .. It works... Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 26, 2007 Share Posted April 26, 2007 ...between my code and yours it seems to look like it does the same thing except yours is fancy...P.S. On the "fancy" part: Are you using SciTE to write and Tidy your scripts? If not, you are doing it the hard way! I copied your code to SciTE, edited it, hit Ctrl-T to run Tidy on it, then copy/pasted it back to the forum. While editing the reply, I highlighted the code and clicked the "Wrap in AutoIt tags" button on the forum editor. You should be doing yours "fancy" too! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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