Jeremy76 Posted March 26, 2011 Posted March 26, 2011 What am I missing here I created a function for a command to that I want every time a button is pushed it checks to make sure a window is active. It works but will not continue with the rest of the case. Any help would be appreciated expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIButton.au3> Global Const $Form1_1 = GUICreate("Form1", 365, 360, 188, 114) Global Const $Input[11] = [ _ GUICtrlCreateInput('', 32 , 24 , 77, 21) , _ ; First Name GUICtrlCreateInput('', 110 , 24 , 80, 21) , _ ; Last Name GUICtrlCreateInput('', 32 , 64 , 177, 21, $ES_NUMBER) , _ ; SSN GUICtrlCreateInput('', 32 , 104 , 177, 21) , _ ; Prov_no GUICtrlCreateInput('', 32 , 144 , 177, 21) , _ ; case_no GUICtrlCreateInput('', 32 , 184 , 177, 21) , _ ; Phone GUICtrlCreateInput('', 32 , 224 , 177 , 21) , _ ; Address GUICtrlCreateInput('', 32, 248 , 50 , 21) , _ ; City GUICtrlCreateInput('', 85, 248 , 20 , 21 , $ES_UPPERCASE) , _ ; state GUICtrlCreateInput('', 112 , 248 , 30 , 21 , $ES_NUMBER) , _ ; Zip GUICtrlCreateInput('', 112 , 248 , 30 , 21 , $ES_NUMBER)] ; ZIP +4 GUICtrlSetLimit($Input[1], 9) ; SSN cannot be more than nine characters GUICtrlSetLimit($Input[5], 14) ; Phone cannot be more than fourteen characters (accommodates spaces, dashes, and parenthesis) GUICtrlSetLimit($Input[8], 2) ; State cannot be more than two capital letters GUICtrlSetLimit($Input[9], 5) ; Zip cannot be more than five digits Global Const $Radio[7] = [ _ GUICtrlCreateRadio('', 8, 24 , 17, 17), _ ; Name GUICtrlCreateRadio('', 8, 24 , 17, 17), _ ; Name GUICtrlCreateRadio('', 8, 64 , 17, 17), _ ; SSN GUICtrlCreateRadio('', 8, 104, 17, 17), _ ; Prov_no GUICtrlCreateRadio('', 8, 157, 17, 17), _ ; case_no GUICtrlCreateRadio('', 8, 208, 17, 17), _ ; prov no GUICtrlCreateRadio('', 8, 248, 17, 17)] ; case no GUICtrlSetState($Radio[1], $gui_hide) GUICtrlSetState($Radio[1], $gui_disable) Global Const $Prov_Name = GUICtrlCreateLabel("Provider_Name_(First Last)", 33, 10 , 73, 11) Global Const $SSN = GUICtrlCreateLabel("SSN" , 33, 50 , 21, 11) Global Const $Prov_No = GUICtrlCreateLabel("Provider_Number" , 33, 90 , 30, 11) Global Const $Case_No = GUICtrlCreateLabel("Case_Number" , 33, 130, 37, 11) Global Const $phone = GUICtrlCreateLabel("Phone" , 33, 170, 41, 11) Global Const $Address = GUICtrlCreateLabel("Address" , 33, 234, 43, 11) Global Const $Webm = GUICtrlCreateButton("Webm" , 216, 32 , 50, 20, $WS_GROUP) Global Const $DPPM = GUICtrlCreateButton("DPPM" , 216, 64 , 50, 20, $WS_GROUP) Global Const $DPPL = GUICtrlCreateButton("DPPL" , 216, 96 , 50, 20, $WS_GROUP) Global Const $DPCS = GUICtrlCreateButton("DPCS" , 216, 128, 50, 20, $WS_GROUP) Global Const $CCB = GUICtrlCreateButton("CCB" , 216, 160, 50, 20, $WS_GROUP) Global Const $JCCB = GUICtrlCreateButton("JCCB" , 216, 196, 50, 20, $WS_GROUP) Global Const $Adjustment = GUICtrlCreateButton("Adjustment", 288, 32 , 50, 20, $WS_GROUP) Global Const $CNM = GUICtrlCreateButton("CNM" , 288, 64 , 50, 20, $WS_GROUP) Global Const $Tracs = GUICtrlCreateButton("Tracs" , 288, 96 , 50, 20, $WS_GROUP) Global Const $UCMS = GUICtrlCreateButton("UCMS" , 288, 128, 50, 20, $WS_GROUP) Global Const $Clear = GUICtrlCreateButton("Button2" , 288, 160, 50, 20, $WS_GROUP) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Webm For $r = 0 To 5 _Exist() If GUICtrlRead($Radio[$r], $gui_checked) Then send("{f3 3} & {pause}") sleep(200) send("{home}") Send("Webm Find " & GUICtrlRead($Input[$r]) & "{enter}") EndIf Next Case $DPPM Case $DPPL Case $UCMS EndSwitch WEnd Func _Exist() If WinExists("GUITEST.wps - Microsoft Works Word Processor") Then WinActivate("GUITEST.wps - Microsoft Works Word Processor") Else Msgbox(4096, "Error", "GUITEST.wps - Microsoft Works Word Processor is not found") EndIf EndFunc
TeamRocket Posted March 27, 2011 Posted March 27, 2011 I'm a little fuzzy on this purpose... Basically when the user clicks the "Webm" button, you want to activate the MS Works Word Processor, then find out if $Radio[$r] is checked, and if it is, then send the contents of $input[$r] to the window, right? If so...... check your arrays. They don't appear to match up quite right. You have the limit for $Input[1] set to 9, since it's your SSN field, but according to "Global Const $Input[11] =" your SSN input is actually $input[2] if the array is 0-based, $input[3] if it's 1-based. That'll clean up your code a bit and prevent future issues. But to answer your question: If BitAnd(GUICtrlRead($Radio[$r]),$GUI_CHECKED) Then ;GUICtrlRead($Radio[$r], $GUI_CHECKED) Then send("{f3 3} & {pause}") sleep(200) send("{home}") Send("Webm Find " & GUICtrlRead($Input[$r]) & "{enter}") EndIf If you scroll down in the help file to where the remarks are, it says "For Checkbox, Radio control several states can be returned as $GUI_FOCUS and $GUI_CHECKED,. So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the control is checked." Therein was your problem. Happy trails!
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