ijourneaux Posted December 14, 2011 Share Posted December 14, 2011 Based on other forum posts, I created a WM_Command handler that monitors if $SampleTypeCombi has been modified. Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _WinAPI_HiWord($wParam) Local $nID = _WinAPI_LoWord($wParam) Local $hCtrl = $lParam Switch $nID Case $SampleTypeCombo Switch $nNotifyCode Case $CBN_EDITUPDATE, $CBN_EDITCHANGE; when user types in new data $iStatusFlag = True Case $CBN_SELCHANGE; item from drop down selected $iStatusFlag = True EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND The while loop looks like While 1 Sleep(500) ; Idle around if($IStatusFlag) Then $IStatusFlag = False consoleWrite("Test"& @CRLF) consoleWrite("Test2 - " & GUICtrlRead($SampleTypeCombo)&@crlf) ReadOriginSize(@scriptdir & "\PickoutDetection.ini", GUICtrlRead($SampleTypeCombo)) UpdateOriginSize() if(SetScanner (GUICtrlRead($SampleTypeCombo))) Then msgbox(0, "Status", "Scanner profile successfully changed to " & GUICtrlRead($SampleTypeCombo)) else msgbox(0, "Error", "Possible problem changing scanner profile to " & GUICtrlRead($SampleTypeCombo)) endif Endif WEnd Unfortuantely when I edit $sampletypecombo, the event associated with one of my buttons "Start Scanning" is also fired before the code in the while loop is processed. ; BUTTON $startscanningbutton = GuiCtrlCreateButton("Start Scanning Process", 70, 140, 150, 30) GUICtrlSetOnEvent($startscanningbutton, "StartScanning") Where is the mistake I am making. Take Care. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2011 Moderators Share Posted December 14, 2011 ijourneaux,When I add enough code to let me run your snippets (TOP TIP: post running code - it greatly increases the chances of getting a useful answer ) I get no problems at all:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> Opt("GUIOnEventMode", 1) Global $IStatusFlag = False $hGUI = GUICreate("Test", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_On_Exit") $SampleTypeCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData(-1, "Fred|Tom|Dick|Harry") $startscanningbutton = GuiCtrlCreateButton("Start Scanning Process", 70, 140, 150, 30) GUICtrlSetOnEvent($startscanningbutton, "StartScanning") GUISetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 Sleep(500) ; Idle around If ($IStatusFlag) Then $IStatusFlag = False ConsoleWrite("Test" & @CRLF) ConsoleWrite("Test2 - " & GUICtrlRead($SampleTypeCombo) & @CRLF) #cs ReadOriginSize(@ScriptDir & "PickoutDetection.ini", GUICtrlRead($SampleTypeCombo)) UpdateOriginSize() If (SetScanner(GUICtrlRead($SampleTypeCombo))) Then MsgBox(0, "Status", "Scanner profile successfully changed to " & GUICtrlRead($SampleTypeCombo)) Else MsgBox(0, "Error", "Possible problem changing scanner profile to " & GUICtrlRead($SampleTypeCombo)) EndIf #ce EndIf WEnd Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _WinAPI_HiWord($wParam) Local $nID = _WinAPI_LoWord($wParam) Local $hCtrl = $lParam Switch $nID Case $SampleTypeCombo Switch $nNotifyCode Case $CBN_EDITUPDATE, $CBN_EDITCHANGE; when user types in new data $IStatusFlag = True Case $CBN_SELCHANGE; item from drop down selected $IStatusFlag = True EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func StartScanning() ConsoleWrite("Scanning" & @CRLF) EndFunc Func _On_Exit() Exit EndFuncI cannot look inside your ReadOriginSize, UpdateOriginSize and SetScanner functions - are you sure nothing in there is firing the scanning process? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ijourneaux Posted December 14, 2011 Author Share Posted December 14, 2011 (edited) Thanks for pointing me in the correct direction. I should have done what you did as a first step. SImplify the code and determine if the problem existed. In my case, the code in SetScanner was accidentally triggering StartScanning. SetScanner brings up the scanners control page, where I select the scaner parameters using ControlCommand and I exit the scanner control page by pressing the Ok button. Unfortunately the scanners control page window doesn't have a name so I am using ControlCommand("", "", "[CLASS:ComboBox; INSTANCE:1]", "SelectString", $ScannerProfile) and ControlClick("", "", "[CLASS:Button; INSTANCE:1]") On my development computer I don't have the scanner application install so the ControlClick command merrily clicks on the StartScanning Button. <KICK pants in self> Trying to come up with a way to trap the condition where the scanner app is not installed. Thanks for the help. Edited December 14, 2011 by ijourneaux Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2011 Moderators Share Posted December 14, 2011 ijourneaux, Do not kick too hard! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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