LetsAuto Posted November 14, 2012 Posted November 14, 2012 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> ; Force close with CTRL-Q HotKeySet("^q", "stop") Func stop() Exit EndFunc ;==>stop #Region ### START Koda GUI section ### Form= $automationWizardStep2 = GUICreate("Automation Wizard Step 2", 744, 642, -1402, 151) $optionsListBox = GUICtrlCreateList("",112, 224, 177, 206, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $addButton = GUICtrlCreateButton("--->", 344, 248, 65, 41) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $rmvButton = GUICtrlCreateButton("<---", 344, 304, 65, 41) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $nextButton = GUICtrlCreateButton("Next", 192, 440, 97, 49) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("Please Select the functions that you want to run", 128, 152, 356, 25) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $addedBox = GUICtrlCreateList("", 464, 224, 177, 206, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) GUICtrlSetData(-1, "DoAddFunctions1()|DoAddFunction2()|DoAddFunction3()") GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $backButton = GUICtrlCreateButton("&Back", 464, 440, 97, 49) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ _GUICtrlListBox_InsertString($optionsListBox, "DoAddFunctions1()") $stringX = _GUICtrlListBox_FindString($addedBox, "DoAddFunction1()|",False) $stringXx = _GUICtrlListBox_FindString($optionsListBox, "DoAddFunction1()|", False) $stringY = _GUICtrlListBox_FindString($addedBox, "DoAddFunction2()|", False) $stringZ = _GUICtrlListBox_FindString($addedBox, "DoAddFunction3()", False) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $addButton _LeftToRight($optionsListBox, $addedBox) Case $rmvButton delete($addedBox, $optionsListBox) Case $nextButton if $stringX = true Then MsgBox("lame","duck","stuff") FileDelete("C:\IanLogTest\function1Log.log") $logdir = "C:\IanLogTest\" $logfile = $logdir & "function1Log.log" $screenshot = 0 $module = "Initial" $file = FileOpen($logfile, 9) ;;;;works and saves variable to log;;;; FileWriteLine($file, "DoAddFunction1()") FileWriteLine($file, @CRLF) FileClose($file) ElseIf $stringX = False Then MsgBox("lame","elephant","things") FileDelete("C:\IanLogTest\function1Log.log") EndIf ;~ If $stringY = true Then ;~ FileDelete("C:\IanLogTest\function2Log.log") ;~ $logdir = "C:\IanLogTest\" ;~ $logfile = $logdir & "function2Log.log" ;~ $screenshot = 0 ;~ $module = "Initial" ;~ $file = FileOpen($logfile, 9) ;~ ;;;;works and saves variable to log;;;; ;~ FileWriteLine($file, "DoAddFunction2()") ;~ FileWriteLine($file, @CRLF) ;~ FileClose($file) ;~ EndIf ;~ If $stringZ = true Then ;~ FileDelete("C:\IanLogTest\function3Log.log") ;~ $logdir = "C:\IanLogTest\" ;~ $logfile = $logdir & "function3Log.log" ;~ $screenshot = 0 ;~ $module = "Initial" ;~ $file = FileOpen($logfile, 9) ;~ ;;;;works and saves variable to log;;;; ;~ FileWriteLine($file, "DoAddFunction3()") ;~ FileWriteLine($file, @CRLF) ;~ FileClose($file) ;~ EndIf Run("C:\Program Files\AutoIt3\AutoIt3.exe F:\AutoIt3\testings\autoWizard\step3.au3") $handle = WinGetHandle("Untitled - AutoIt", "") WinClose($handle) Case $backButton Run("C:\Program Files\AutoIt3\AutoIt3.exe F:\AutoIt3\testings\autoWizard\step1.au3") $handle = WinGetHandle("Untitled - AutoIt", "") WinClose($handle) EndSwitch WEnd Func _LeftToRight(Const $list, Const $addlist) Local $sRead $sRead = GUICtrlRead($list) ConsoleWrite($sRead & @CR) If $sRead = "" Then msgbox(16+262144, @ScriptName, "No value selected!") Else ConsoleWrite(_GUICtrlListBox_DeleteString($list, _GUICtrlListBox_FindString($list, $sRead, True)) & @CR) ConsoleWrite(_GUICtrlListBox_AddString($addlist, $sRead) & @CR) EndIf EndFunc Func delete(Const $list, Const $rmvlist) local $sRead $sRead = GUICtrlRead($list) ConsoleWrite($sRead & @CR) If $sRead = "" Then msgbox(16+262144, @ScriptName, "No value selected!") Else ConsoleWrite(_GUICtrlListBox_DeleteString($list, _GUICtrlListBox_FindString($list, $sRead, True)) & @CR) ConsoleWrite(_GUICtrlListBox_AddString($rmvlist, $sRead) & @CR) EndIf EndFunc very confused as to why my CASE $NEXTBUTTON is only evaluating one of the 2 cases of whether or not $stringX is true or false... its always saying its true... and then if you substitute the original code with... Case $nextButton ;~ if $stringX = true Then ;~ MsgBox("lame","duck","stuff") ;~ FileDelete("C:\IanLogTest\function1Log.log") ;~ $logdir = "C:\IanLogTest\" ;~ $logfile = $logdir & "function1Log.log" ;~ $screenshot = 0 ;~ $module = "Initial" ;~ $file = FileOpen($logfile, 9) ;~ ;;;;works and saves variable to log;;;; ;~ FileWriteLine($file, "DoAddFunction1()") ;~ FileWriteLine($file, @CRLF) ;~ FileClose($file) ;~ Else If $stringX = False Then MsgBox("lame","elephant","things") FileDelete("C:\IanLogTest\function1Log.log") EndIf ... you get no output...
JohnOne Posted November 14, 2012 Posted November 14, 2012 What makes you think that $stringX will be true or false? Does _GUICtrlListBox_FindString return true or false? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
BrewManNH Posted November 15, 2012 Posted November 15, 2012 BTW, this line isn't necessary. ElseIf $stringX = False Then You achieve the same results with just an Else statement because if $stringX isn't true, it's got to be false, so testing for a false condition is overkill. Saves you some typing when you have only 2 possible results in an If comparison. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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