Jump to content
Sign in to follow this  
galan2015

Loop and set another data in GUICtrlCreateCombo

Recommended Posts

 

;I'd like to on the end of the function, script changed for another option in the combolist. This will be part of the loop

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 418, 177, 192, 114)
$Combo1 = GUICtrlCreateCombo("exe Files", 16, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GuiCtrlSetData(-1,'ini Files|Txt Files|Cfg files')
$Combo2 = GUICtrlCreateCombo("Find A", 176, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GuiCtrlSetData(-1,'Find B')
$Input1 = GUICtrlCreateInput("Input1", 16, 56, 321, 21)
$Button = GUICTRLCreateButton("check", 10, 10, 20,20)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 80, 97, 25)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 80, 97, 25)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 224, 80, 113, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

 

Edited by galan2015

Share this post


Link to post
Share on other sites

galan2015,

Is your question related to this thread?  If so, does my response help?  If not, see JLogan3o13 above.

kylomas

I would like to take a snapshot of data from text files. No.

1. My first combo [Select file]
2. My second combo [Male | Female]
3. My third combo [Michael | Jordan | Natasha]

I would like to function if it is proven options to choose from in ComboList1, ComboList2, Combolist3. After selecting ComboList3 (CL2 is a sub-CL1 and CL2 CL3 is a sub-category) and then to change to the next available option.

Share this post


Link to post
Share on other sites

galan2015,

Does this help?

#include <GUIConstantsEx.au3>

$sData_1 = "Option 1|Option 2|Option 3"
$sData_2A = "|Option 101|Option 201|Option 301"
$sData_2B = "|Option 402|Option 502|Option 602"
$sData_2C = "|Option 703|Option 803|Option 903"

$hGUI = GUICreate("Test", 500, 500)

$cCombo_1 = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($cCombo_1, $sData_1)

$cCombo_2 = GUICtrlCreateCombo("", 250, 10, 200, 20)
GUICtrlSetState($cCombo_2, $GUI_DISABLE)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cCombo_1
            Switch GUICtrlRead($cCombo_1)
                Case "Option 1"
                    GUICtrlSetData($cCombo_2, $sData_2A)
                    GUICtrlSetState($cCombo_2, $GUI_ENABLE)
                Case "Option 2"
                    GUICtrlSetData($cCombo_2, $sData_2B)
                    GUICtrlSetState($cCombo_2, $GUI_ENABLE)
                Case "Option 3"
                    GUICtrlSetData($cCombo_2, $sData_2C)
                    GUICtrlSetState($cCombo_2, $GUI_ENABLE)
            EndSwitch

    EndSwitch

WEnd

If this is nowhere close, then please try and explain what you are trying to do in more detail as you are not being very clear at present.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I need to change the data in 60,000 files. The function appends a line to each file.
I have three combo list:
1. The first combo A | B | C | .. | Z after selecting a name in the pop Combo 2
2. The names of clients
3. The third combo contains a list of files in a folder on my misfortune number of files to be edited for any user: 8.

After selecting the data manually from the combo letter, after pressing the button that activates the function appends data to a single file.

But I would like to function After adding in the file lines jumped to the next file and performed the function again. The file names in a combo 2 and 3 are variable.

Share this post


Link to post
Share on other sites

galan2015,

That reads nothing like what you described in your earlier posts - and really does not advance us very much further forward. I will try and ask specific questions to see if I can tease out some more details.

- 1. The combo which the user actions first - what does it contain?

- 2. The combo which holds the "names of clients" - from where does it get these? Is its content alphabetically linked to the "A-Z" combo?

- 3. Where does the combo with a file list come in? I really hope you do not intend to put all 60,000 filenames in it!  You say you want to "jump[...] to the next file" - how do you define "the next file" if you can only select one at a time in the combo?

You answer those points clearly and we might be able to make some progress.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Combo1 contains a list from A to Z.
Combo2
contains a list of names from txt file.              ;;;;;;;;;; Made by myself, User1|User2|User4

Combo 3 contains a list of paths to files from txt file ;;;;;;;;;;;; usrini.txt|user.txt|backup.txt|class.txt|forum.txt|log.txt ... and two others

I want to do :
Pick Combo1[A]
Pick Combo2[Andrzej1]
PIck Combo3[1] ; $i = 8, 8 files
Function
Pick Combo3[2]
Function
Pick Combo3[3]
Function

Pick Combo3[4]
Function

Pick Combo3[5]
Function

Pick Combo3[6]
Function

Pick Combo3[7]
Function
Pick Combo3[8]
Function

Pick Combo2[Andrzej2]
Pick Combo3[1]

Function
Pick Combo3[2]
Function
Pick Combo3[3]
Function

Pick Combo3[4]
Function

Pick Combo3[5]
Function

Pick Combo3[6]
Function

Pick Combo3[7]
Function
Pick Combo3[8]
Function


.........

Edited by galan2015

Share this post


Link to post
Share on other sites

galan2015,

Total entries or selected entries?  As I said in the thread that I pointed you to earlier, definition of the relationships of the data in the combo controls is the only difficult task here.  Combo1 is related to combo2...is related to combo2...etc...

Perhaps if you post some real world example data with an explanation of it's use it will become clearer. 

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

galan2015,

Looking at what you want to do, why are you even thinking of using combos? All you do is run through their entries one by one in order - and that is a job for loops, not combos.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 122, 192, 114)
$Combo1 = GUICtrlCreateCombo("ComboA", 0, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUiCtrlSetData(-1,"ComboB")
$Combo2 = GUICtrlCreateCombo("Sex", 152, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("Combo3", 304, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 56, 97, 17)
$Button = GUICtrlCreateButton('write file',280,56,50,30)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

            Exit
        Case $Combo1
        $if1 = GuiCtrlRead($combo1)
IF      $if1 = 'ComboA' then
            GuiCtrlSetData($Combo2,"")
    GuiCtrlSetData($Combo2,"Male")
    EndIf
IF      $if1 = 'ComboB' then
        GuiCtrlSetData($Combo2,"")
    GuiCtrlSetData($Combo2,"Female")
    EndIf
        Case $Combo2
        $if1 = GuiCtrlRead($combo2)
IF      $if1 = 'Female' then
    GuiCtrlSetData($Combo3,"")
    GuiCtrlSetData($Combo3,"Agnieszka|Ania")
    EndIf
IF      $if1 = 'Male' then
    GuiCtrlSetData($Combo3,"")
    GuiCtrlSetData($Combo3,"Andrzej|Adam")
    Endif
        Case $Combo3
IF      $if1 = 'Andrzej' then
EndIf
        Case $Button
              GUICtrlSetState($Checkbox2,1)
              Sleep(150)
            GUICtrlSetState($Checkbox2,1)
            MSgBox(1,'ANd what now script should do','Script should pick Another option from $combo3. That is it')
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

Personally I would do something like this. Of course, if you get into multiple sub choices this is going to be a PITA to support:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 122, 192, 114)
$Combo1 = GUICtrlCreateCombo("Choose Combo", 0, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"ComboA|ComboB", "Choose Combo")
$Combo2 = GUICtrlCreateCombo("Choose Sex", 152, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"Male|Female", "Choose Sex")
$Combo3 = GUICtrlCreateCombo("Choose Name", 304, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
        GUiCtrlSetData(-1,"Fred|Judy", "Choose Name")

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 56, 97, 17)
$Button = GUICtrlCreateButton('write file',280,56,50,30)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            If GUICtrlRead($Combo1) = "Choose Combo" Then
                GUICtrlSetData($Combo2, "Choose Sex")
                GUICtrlSetData($Combo3, "Choose Name")
            Else
                GUICtrlSetData($Combo2, (GUICtrlRead($combo1) = "ComboA") ? "Male" : "Female")
                    If GUICtrlRead($Combo2) <> "Choose Sex" Then GUICtrlSetData($Combo3, (GUICtrlRead($combo2) = "Male") ? "Fred" : "Judy")
            EndIf
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

Personally I would do something like this. Of course, if you get into multiple sub choices this is going to be a PITA to support:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 122, 192, 114)
$Combo1 = GUICtrlCreateCombo("Choose Combo", 0, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"ComboA|ComboB", "Choose Combo")
$Combo2 = GUICtrlCreateCombo("Choose Sex", 152, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"Male|Female", "Choose Sex")
$Combo3 = GUICtrlCreateCombo("Choose Name", 304, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
        GUiCtrlSetData(-1,"Fred|Judy", "Choose Name")

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 56, 97, 17)
$Button = GUICtrlCreateButton('write file',280,56,50,30)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            If GUICtrlRead($Combo1) = "Choose Combo" Then
                GUICtrlSetData($Combo2, "Choose Sex")
                GUICtrlSetData($Combo3, "Choose Name")
            Else
                GUICtrlSetData($Combo2, (GUICtrlRead($combo1) = "ComboA") ? "Male" : "Female")
                    If GUICtrlRead($Combo2) <> "Choose Sex" Then GUICtrlSetData($Combo3, (GUICtrlRead($combo2) = "Male") ? "Fred" : "Judy")
            EndIf
    EndSwitch
WEnd

 

​no that is big fail :P hope i will learn by myself and show u how  how i solve the problem

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By ThePoro
      Hi everyone.
      I want to ask about this : 
      I want it runs from 1 to 100 and It opens 10 firefox profiles then access youtube. After I close a firefox window, the loop runs and wait for another window close until loop ends
      I have a loop like this.
      Func launch() Local $from = Int(GUICtrlRead($input1)) Local $to = Int(GUICtrlRead($input2)) If $to <> "" Then While $from <= $to Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") $to=$to+1 WEnd Else Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") EndIf EndFunc Is there any solution?
      Thank you!
    • By Rhidlor
      First off, the project I'm working on revolves around AS/400 "Client Access software", it's foundation is directly influenced by the thread linked at the bottom of this post. Moving on, to explain the problem I'm facing; my project utilizes an infinite While loop and automatically performs semi-hard coded monotonous tasks to save users time and effort, the problem is, occasionally and unexpectedly "Display Messages" will popup and the core script will continue executing instead of dismissing said message and the script "breaks". As a countermeasure I've added some code to the While loop in an effort to intervene and dismiss these display messages before the core script has a chance to do anything... however it doesn't work. I hope I didn't do too bad of a job explaining that. 
      So I think my question is: How can I temporarily "pause" the core script when these messages spontaneously appear?
      The only other solution I thought of would be to check if a display message has appeared before executing every line of code but that obviously isn't very practical.
      Any and all help is greatly appreciated!
      Thanks
       
      ;Loop to keep script running and handle display messages While 1 dismiss_display_messages() Sleep(50) WEnd ;Function to dismiss display messages Func dismiss_display_messages() If $ps.SearchText("Display Messages") Then $ps.SendKeys("[enter]", 8, 1) ;This while loop waits until the display message has disappeared to resume the core script While $ps.SearchText("Display Messages") Sleep(100) WEnd EndIf EndFunc  
       
    • By UGH
      Autoit team are assbags.    They want to hold out that they are soooo much smarter than everyone else and they really don't want to help anyone with their questions.   In that case then why have a website.   Oh i know, they get their kicks out of laughing at everyone. 
       
       
       
       
       
       
       
    • By XinYoung
      Hello all,
      Preface: Column A is full of courses. Column B is full of usernames. If course (A1) exists, we check to see if username (B1) is enrolled. If user is found, the user is un-enrolled. Then Loop.
      I am working on a script that loops through an Excel file and pastes the content from A1 into a textbox in IE, does some stuff, then pastes the content from B1 into a different textbox. Then it loops around until all used rows in columns A and B have been accounted for.
      For some reason, column A loops properly but column B doesn't. B1 is pasted over and over again. So, as it loops, B1 is constantly being pasted, first accompanying A1's loop, then A2, and so on.
      The OpenExcel() func opens the Excel file the user specifies in an earlier function. It's supposed to gather the entire used range of columns A and B. The SearchCourse() func only uses column A, pasting its content into a Search tool in IE. This seems to be working fine. SearchResult() puts "Course Not Found" into column C if the search fails. If the search is successful, however, we move onto... EnterCourse(). This simply gets us to the place where column B's content comes into play. UnenrollNow(). Here, we paste the variable $_userName into a textbox. I don't know why it's always B1  Func OpenExcel() If Not WinExists($hWnd) Then MsgBox(16, "Window closed", "The Internet Explorer window was closed. Please start over.") _Exit() Else $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, $ChosenFileName, Default, True, True) $oExcel.Sheets("CopyCourses").Activate ;~ Get all used cells in columns A and B $aSearchItems = _Excel_RangeRead($oWorkbook, 1, $oWorkbook.Sheets("CopyCourses").Usedrange.Columns("A:B")) ;~ Create the $aSearchResult array ReDim $aSearchResult[UBound($aSearchItems)] ;~ Loop through the array starting at 0 until the end of the array which is (Ubound($aSearchItems) - 1) For $i = 0 To UBound($aSearchItems) - 1 ;~ Column 0 ConsoleWrite($aSearchItems[$i][0] & @CRLF) ;~ Column 1 ConsoleWrite($aSearchItems[$i][1] & @CRLF) $aSearchResult[$i] = SearchCourse($aSearchItems[$i][0], $aSearchItems[$i][1]) Next _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") ;~ When the loop is complete, run the Finished function. Finished() EndIf EndFunc ;==>OpenExcel Func SearchCourse($_sSearchResult, $_userName) If Not WinExists($hWnd) Then MsgBox(16, "Window closed", "The Internet Explorer window was closed. Please start over.") _Exit() Else _IENavigate($oIE, $urlBBCourseSearch) _IELoadWait($oIE) Local $oForm = _IEGetObjByName($oIE, "courseManagerFormSearch") Local $oSearchString = _IEFormElementGetObjByName($oForm, "courseInfoSearchText") _IEFormElementSetValue($oSearchString, $_sSearchResult) _IEFormSubmit($oForm) _IELoadWait($oIE) Local $oBBTable = _IETableGetCollection($oIE, 2) $aBBTableData = _IETableWriteToArray($oBBTable) Return SearchResult() EndIf EndFunc ;==>SearchCourse Func SearchResult() If Not WinExists($hWnd) Then MsgBox(16, "Window closed", "The Internet Explorer window was closed. Please start over.") _Exit() Else Local $sResult $iSearchIndex = _ArraySearch($aBBTableData, "Course ID", 0, 0, 0, 1, 1, 0) If $iSearchIndex = -1 Then $sResult = "Course Not Found" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") Else EnterCourse() $sResult = "UnEnrolled!" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") EndIf Return $sResult EndIf EndFunc ;==>SearchResult Func EnterCourse() If Not WinExists($hWnd) Then MsgBox(16, "Window closed", "The Internet Explorer window was closed. Please start over.") _Exit() Else Local $clickFail = "DATE CREATED" _IELinkClickByIndex($oIE, 34) _IELoadWait($oIE) $sourceCode = _IEBodyReadHTML($oIE) If StringInStr($sourceCode, $clickFail) <> 0 Then _IELinkClickByIndex($oIE, 35) _IELoadWait($oIE) EndIf $oLink = _IEGetObjById($oIE, "controlpanel.users.and.groups_groupExpanderLink") _IEAction($oLink, "click") Sleep(500) _IELinkClickByText($oIE, "Users") _IELoadWait($oIE) $aSearchResult[$i] = UnenrollNow($aSearchItems[$i][0], $aSearchItems[$i][1]) EndIf EndFunc ;==>EnterCourse Func UnenrollNow($_sourceCourseId, $_userName) If Not WinExists($hWnd) Then MsgBox(16, "Window closed", "The Internet Explorer window was closed. Please start over.") _Exit() Else Local $UserError = "No users found" Local $sResult $criteriaUsername = _IEGetObjById($oIE, "userInfoSearchKeyString") _IEFormElementOptionSelect($criteriaUsername, 0, 1, 'byIndex') $criteriaUsername = _IEGetObjById($oIE, "userInfoSearchOperatorString") _IEFormElementOptionSelect($criteriaUsername, 0, 1, 'byIndex') ;Paste whats copied from column B into the Username text box. Local $oForm = _IEGetObjByName($oIE, "userManagerSearchForm") Local $oSearchString = _IEFormElementGetObjByName($oForm, "userInfoSearchText") ;PROBLEM HERE... _IEFormElementSetValue($oSearchString, $_userName) ;^^^^^^ WHY IS $_userName ALWAYS B1 ??? Sleep(1000) _IEFormSubmit($oForm) _IELoadWait($oIE) $sourceCode = _IEBodyReadHTML($oIE) If StringInStr($sourceCode, $UserError) <> 0 Then $sResult = "User Not Found" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") Return $sResult Else MsgBox(0, "Unenrollment READY!", "We're ready to unenroll foreal") $sResult = "DUN" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") Return $sResult EndIf EndIf EndFunc ;==>UnenrollNow Please let me know if any further information is needed.
      If you see other problems or redundancies in my code, please let me know.
      Thank you!
       
    • By XinYoung
      HI! ... this is a big one (at least for me) 
      You guys previously helped me copy the used range in column A and paste them into a Website one at a time in a loop. Cool! Now, for another function, I have 2 columns, A and B, and two input boxes in the Website. I'm having a hard time replicating the loop for the 2 columns. 
      This is how I'm opening the Excel workbook (copied from the previous function that only had 1 column). I need to also get the used range in column B.
      Func OpenExcelForCopy() Global $aBBTableData Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, $ChosenFileName, Default, True, True) $oExcel.Sheets("CopyCourses").Activate ;~ Get all used cells in column A:A Global $aSearchItems = _Excel_RangeRead($oWorkbook, 1, $oWorkbook.Sheets("CopyCourses").Usedrange.Columns("A:A")) ;~ Duplicate the $aSearchItems Array Global $aSearchResult = $aSearchItems ;~ Loop through the array starting at 0 until the end of the array which is (Ubound($aSearchItems) - 1) For $i = 0 To UBound($aSearchItems) - 1 $aSearchResult[$i] = SearchCourseForCopy($aSearchItems[$i]) Next _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") Finished() EndFunc ;==>OpenExcelForCopy Then we eventually get here. I don't think anything needs to change here but I'm not sure. This is where I paste the data from Column A into an input field (which is a search tool in a website). If the search is good, then we get to the tricky part...
      ;~ OK, we logged in and we searched for a course. Lets COPY it! Func CopyCourseBegin() Local $sResult $iSearchIndex = _ArraySearch($aBBTableData, "Course ID", 0, 0, 0, 1, 1, 0) ;~ If the course was not found, do this. If $iSearchIndex = -1 Then ;~ MsgBox(4096, "Search Error", "Item not found") $sResult = "Source Not Found" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") ;~ Now go back to the Excel sheet and search for the next one. ;~ If the course was found, begin the COPY process. Else For $i = 0 To UBound($aSearchItems) - 1 $aSearchResult[$i] = CopyCourseNow($aSearchItems[$i]) Next $sResult = "Copied" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") EndIf Return $sResult EndFunc ;==>CopyCourseBegin This is the "tricky part" where I'm confused. I can copy and paste what's in column A just fine, but I can't manage to replicate it for column B. I need to paste whats in Column B into "destinationCourseId"
      ;~ The course search was successful. COPY the course now. Func CopyCourseNow($_sSearchResult) ;~ Navigate to the course copy page. _IENavigate($oIE, $urlBBCourseCopy) ;~ Copy the SOURCE course ID from the Excel sheet ;~ Paste whats copied from column A into the Source Course ID text box Local $oForm = _IEGetObjByName($oIE, "selectCourse") Local $oSearchString = _IEFormElementGetObjByName($oForm, "sourceCourseId") _IEFormElementSetValue($oSearchString, $_sSearchResult) ;~ Paste whats copied from column B into the Destination Course ID text box ?!?!?!?! Local $oForm = _IEGetObjByName($oIE, "selectCourse") Local $oSearchString = _IEFormElementGetObjByName($oForm, "destinationCourseId") _IEFormElementSetValue($oSearchString, $_sSearchResult) ;~ Just exit cause im stuck :( _Exit() EndFunc ;==>CopyCourseNow After I paste the data from column A into "sourceCourseId" and column B into "destinationCourseId", I'll make it do some stuff. Then I need it to loop around until the used ranges in column A & B is finished.
      Does the entire code need to change now that there's two columns?
       
       
×
×
  • Create New...