Sign in to follow this  
Followers 0
JayFran

Working with Arrays!

17 posts in this topic

1. I have a script already finished, I want to be able to put in, say 10 different numbers (101, 102, 103, etc.) store them in an array, let my script for #101 once thats done, it'll start from the begining of my script using 102 and so on. I don't have and idea of how to go about it so I'm asking for help.

2. I have written a few lines of code, basically its suppose to search for the window handle/title and then activate that window, depending on the return value it finds it will either activate that window then attach on to the url or activate the window press alt+r and then attach to the url. here's what have so far for that one:

#include <IE.au3>
#include<Debug.au3>
Opt("WinTitleMatchMode", 2) 

Global $oIE
Local $handle0[2] = ["Changes", "Activities"]

For $h = 0 To UBound($handle0) -1
    $resume = WinGetHandle($handle0[$h])
    If $resume = $handle0[0] Then WinActivate($resume)
    If $resume = $handle0[1] Then WinActivate($resume)
        WinActive($resume)
        Send("!r")
    If @error Then ConsoleWrite("There was an error " & $h & @CRLF)
    ;EndIf
Next

$oIE = _IEAttach("https://199.255.234.153/", "url")

Share this post


Link to post
Share on other sites



So do you need to loop through the array once (which is what your script does) or multiple times (could be achieved through nested for-next loops) or an infinite number of times, like this?

dim $Array[5] = ["One","Two","Three","Four","Five"]
Run("notepad.exe")
Sleep(2000)
For $ArrayKey=0 to UBound($Array)-1
    Send($Array[$ArrayKey] & " ")
    If $ArrayKey = UBound($Array)-1 Then
        Send("{ENTER}")
        $ArrayKey = -1
    EndIf
Next

I think I don't really get what the problem is.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

So do you need to loop through the array once (which is what your script does) or multiple times (could be achieved through nested for-next loops) or an infinite number of times, like this?

dim $Array[5] = ["One","Two","Three","Four","Five"]
Run("notepad.exe")
Sleep(2000)
For $ArrayKey=0 to UBound($Array)-1
    Send($Array[$ArrayKey] & " ")
    If $ArrayKey = UBound($Array)-1 Then
        Send("{ENTER}")
        $ArrayKey = -1
    EndIf
Next

I think I don't really get what the problem is.

Nope Just one time. I'm using an inputbox to feed the numbers into the array. the numbers are going to always be different so I dont wont to hardcode them into the script.

My logic for the first question would be

The 2nd question is entirely different. Btw, I managed to work thru the my issue which is now Resolved.

But I still NEED help with my 1ST question.

$t_number = InputBox("Ticket Number", "Enter Ticket Number:" & @CRLF & "Example:1234") <--Get the Ticket #'s--->
Local $arr[10] = ? <---Store the #'s in a 1x1 array--->

<----1st # inputs --->
<----Script Runs---->
<----Script Finishes---->
<----Script Returns to begininning--->
<----2nd # inputs ---->
<----Script Runs---->
<----Script Finishes---->
<----Script Returns to begininning--->
etc. etc.
Edited by JayFran

Share this post


Link to post
Share on other sites

JayFran,

The code structure you need is something like this:

Global $aTickets[1] = [0]

; Enter tickets
While 1

    ; Get ticket value
    $sTicket = InputBox("Ticket", "Please enter a ticket number")

    ; Exit loop with empty ticket or Cancel
    If $sTicket = "" Then ExitLoop

    ; Store ticket number in array
    $aTickets[0] += 1
    ReDim $aTickets[$aTickets[0] + 1]
    $aTickets[$aTickets[0]] = $sTicket

WEnd

; Run script for each ticket in turn
For $i = 1 To $aTickets[0]
    
    MsgBox(0, "Running", "Script running for Ticket " & $aTickets[$i])
    
Next

I hope this helps. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

#5 ·  Posted (edited)

JayFran,

The code structure you need is something like this:

Global $aTickets[1] = [0]

; Enter tickets
While 1

    ; Get ticket value
    $sTicket = InputBox("Ticket", "Please enter a ticket number")

    ; Exit loop with empty ticket or Cancel
    If $sTicket = "" Then ExitLoop

    ; Store ticket number in array
    $aTickets[0] += 1
    ReDim $aTickets[$aTickets[0] + 1]
    $aTickets[$aTickets[0]] = $sTicket

WEnd

; Run script for each ticket in turn
For $i = 1 To $aTickets[0]
    
    MsgBox(0, "Running", "Script running for Ticket " & $aTickets[$i])
    
Next

I hope this helps. ;)

M23

This Definitely help!

How would I make it return back to the beginning though. I tried to create a function and have it call on it. but that was a fail. Here What I did

#include <IE.au3>
#include<Debug.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 2) 


$user = ""
$pass = ""

; Enter tickets
While 1

    ; Get ticket value
    $a_number = InputBox("Ticket", "Please enter a ticket number")

    ; Exit loop with empty ticket or Cancel
    If $a_number = "" Then ExitLoop

    ; Store ticket number in array
    $t_number[0] += 1
    ReDim $t_number[$t_number[0] + 1]
    $t_number[$t_number[0]] = $a_number

WEnd

; Run script for each ticket in turn
For $z = 1 To $t_number[0]
    
    MsgBox(0, "Running", "Script running for Ticket " & $t_number[$z])
    
Next

 
Global $oIE
Func windows() <----------I Want it to return HERE!----------->
Local $handle0[2] = ["Changes", "Activities and Tasks"]

For $h = 0 To UBound($handle0) -1
$resume = WinGetHandle($handle0[$h])
    
If $resume = "Changes" Then _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)

If $resume = "Activities and Tasks" Then _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume);_IEAttach("https://129.39.231.133/maximo/ui/maximo.jsp?event=gotoapp&value=activity", "url")
    ;$goback = ActivitiesReturn()
If @error Then ConsoleWrite("There was an error " & $h & @CRLF)
    ;EndIf

Next
EndFunc

;<------------MY MAIN CODE HERE---------->
Func top_return()
    $gb = windows ()
EndFunc
Edited by JayFran

Share this post


Link to post
Share on other sites

JayFran,

Where in your function do you use the tickets you have stored in the array? Why do you do you need to return to the beginning? ;)

Without a little more info I cannot help any more. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

#7 ·  Posted (edited)

JayFran,

Where in your function do you use the tickets you have stored in the array? Why do you do you need to return to the beginning? ;)

Without a little more info I cannot help any more. :)

M23

I need to return to the beginning because the script runs thru IE. After the ticket/# is filed thru IE I return back to the page where I can input the next number. Here is the full code and where I want to return and where the input of the ticket number is:

#include <IE.au3>
#include<Debug.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 2) 

$user = ""
$pass = ""

;Do
;$t_number = InputBox("Ticket Number", "Enter Ticket Number:" & @CRLF & "Example:1234")
;If @error = 1 Then Exit
;If $t_number = "" Then MsgBox(16, "ISM Login", "Enter Ticket Number:")
;Until $t_number <> ""

;$t_string = StringRegExp($t_number, "[0-9]", 1);[C](?i){1}
; If @error = 1 Then 
;    MsgBox(5, "ISM Login", "Error in Ticket number")
;    Exit
; EndIf
Global $t_number[1] = [0]

; Enter tickets
While 1

    ; Get ticket value
    $a_number = InputBox("Ticket", "Please enter a ticket number")

    ; Exit loop with empty ticket or Cancel
    If $a_number = "" Then ExitLoop

    ; Store ticket number in array
    $t_number[0] += 1
    ReDim $t_number[$t_number[0] + 1]
    $t_number[$t_number[0]] = $a_number

WEnd

; Run script for each ticket in turn
For $z = 1 To $t_number[0]
    
    MsgBox(0, "Running", "Script running for Ticket " & $t_number[$z])
    
Next
 
Global $oIE
Func windows ($gb) <--------I Want to Return Here and Let this function reset the whole script--------->
Local $handle0[2] = ["Changes", "Activities and Tasks"]

For $h = 0 To UBound($handle0) -1
$resume = WinGetHandle($handle0[$h])
    
If $resume = "Changes" Then _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)

If $resume = "Activities and Tasks" Then _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume);_IEAttach("https://129.39.231.133/maximo/ui/maximo.jsp?event=gotoapp&value=activity", "url")
    ;$goback = ActivitiesReturn()
If @error Then ConsoleWrite("There was an error " & $h & @CRLF)
    ;EndIf

Next
EndFunc
#cs
$oIE = _IEAttach("https://129.39.231.133/", "url")
WinActive("Start Center - Windows Internet Explorer")
sleep(2000)
$c_click = "mx46"
$changes = _IEGetObjById($oIE, $c_click)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(1250)
$c_click2 = "menu0_CHANGE_MODULE_middle_anchor"
$changes2 = _IEGetObjById($oIE, $c_click2)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes2, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
;sleep(1250)
$c_click3 = "menu7_CHANGE_APP_middle_anchor"
$changes3 = _IEGetObjById($oIE, $c_click3)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes3, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
;sleep(1250)


; =================================================================================================
;                                           #ISM Ticket Field Fill & Lookup# 
; =================================================================================================
;Insert Ticket info
WinWait("Changes - Windows Internet Explorer")
Sleep(2000)
$ticketfill = _IETagNameGetCollection($oIE, "input")
$tid_0 = "mx398"
$tid_1 = "mx404"
For $Oticketfill In $ticketfill
Global $t_post = _IEPropertyGet($oIE, "innerhtml")
If $t_post = $tid_0 Then $Oticketfill = $tid_0
If $t_post = $tid_1 Then $0ticketfill = $tid_1
Next
$t_submit = _IEGetObjById($oIE, $t_post)
_IEAction($t_submit, "focus")
Send($t_number[1]) <-----------------This is  where the TICKET # will go------------->
Send("{Enter}")
Sleep(3500)
$changetab = "Change"
$c_links = _IELinkGetCollection($oIE)
For $c_link in $c_links
    $cLinkText = _IEPropertyGet($c_link, "innerText")
    If StringInStr($cLinkText, $changetab) Then
        _IEAction($c_link, "click")
        ExitLoop
    EndIf
Next
_IELoadWait($oIE, 5000)
_IELoadWait($c_Link, 5000)
; =================================================================================================
;                                           #View Attachments# 
; =================================================================================================

;Sleep(15000)
_IEAttach("Attachments", "html")
$u_imageid0 = "mx847"
$u_imageid1 = "mx853"
$u_imageid2 = "Attachments"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerhtml")
    If StringInStr($sLinkText, $u_imageid0) Then
        _IEAction($oLink, "click")
          ExitLoop
    EndIf
     If StringInStr($sLinkText, $u_imageid1) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
    $uimg = _IEImgGetCollection($oIE)
        If $uimg = $u_imageid2 Then $oLink = $u_imageid2
        _IEImgClick($oIE, $u_imageid2, "alt", 0)
            ExitLoop
            
Next

Sleep(550)
$view_attach = "view_middle_anchor"
$v_a = _IEGetObjById($oIE, $view_attach)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($v_a, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(5000)
; =================================================================================================
;                               #Open & Print Attachment Pt.1# 
; =================================================================================================
$db = _IEGetObjById($oIE, "viewattachments_bodydiv")
If IsObj($db) Then $ok_but = _IETagNameGetCollection($db, "A", 9)
$return = _IEAction($ok_but, "focus")
$ib = "Information Bar"
;If $ib = WinActive("Information Bar") Then ControlClick($ib, "", "CLASS:Button; INSTANCE:1]")
Sleep(1500)
Send("{Enter}")
;Exit
;If $ib <> WinActive("Information Bar") Then Exit
;_IEAttach("https://129.39.231.133/attachments/", "windowtitle")
Sleep(2500)
$fd = WinWaitActive("File Download")
Sleep(2500)
Send("!o")
Send("{TAB}")
;ControlClick($fd, "", "[CLASS:Button; INSTANCE:1]")
Sleep(2000)
WinActivate("", "PC REPLACEMENT")
$ie2 = WinActive("", "PC REPLACEMENT")
Sleep(1500)
Send("^p")
$print0 = WinActive("Print")
Sleep(1000)
Send("{Enter}")
Sleep(1500)
$handle = WinGetHandle("https://129.39.231.133/attachments", "")
WinClose($handle)
WinWaitActive("Changes - Windows Internet Explorer")
Send("!n")
Sleep(2000)
$db = _IEGetObjById($oIE, "viewattachments-dialog_dialog_content1")
If IsObj($db) Then $ok_but = _IETagNameGetCollection($db, "button", 0)
$return = _IEAction($ok_but, "click")
Sleep(2500)
; =================================================================================================
;                               #Open & Print Attachment Pt.2# 
; =================================================================================================
$long_d = "mx902"
$ldimg = _IEImgClick($oIE, "Long Description", "alt", 0)
Sleep(2500)
Send("^p")
$print1 = WinWaitActive("Print")
;ControlClick($print1, "", "[CLASS:Button; INSTANCE:13]")
Sleep(3000)
Send("{Enter}")
WinWaitActive("Changes - Windows Internet Explorer")
$db2 = _IEGetObjById($oIE, "longdesc_dialog-dialog_dialog_inner")
If IsObj($db2) Then $ok_but2 = _IETagNameGetCollection($db2, "button", 3)
$return2 = _IEAction($ok_but2, "click")
Sleep(3500)

; =================================================================================================
;                                           #Navigate to Ownership# 
; =================================================================================================
$plantab0 = "Plans"
$plantab1 = "mx209_anchor"
$p_links = _IELinkGetCollection($oIE)
For $p_link in $p_links
    $pLinkText = _IEPropertyGet($p_link, "innerText")
        If StringInStr($pLinkText, $plantab0) Then
        _IEAction($p_link, "click")
        ExitLoop
    EndIf
    $pLinkstr = _IEGetObjById($p_link, $plantab1)
    If $pLinkstr = $plantab1 Then $p_link = $plantab1
    
Next
_IEAction($p_link, "focus")
$hwnd = _IEPropertyGet($oIE, "hwnd")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(3000)
_IELoadWait($oIE)
Sleep(1250)
$dm1 = "Detail Menu"
$dm2 = "mx5692[R:0]"
$dm3 = "mx3057[R:0]"
$detailmenu = _IEImgGetCollection($oIE)
For $detailmenu0 in $detailmenu
    $dmimg = _IEPropertyGet($detailmenu0, "innerText")
     If $dmimg = $dm1 Then
        _IEImgClick($detailmenu0, $dm1, "alt", 9)
        ExitLoop
    EndIf   
    $dmstr = _IEGetObjById($detailmenu0, $dm2)
    $dmstr = _IEGetObjById($detailmenu0, $dm3)
    If $dmstr = $dm2 Then $detailmenu0 = $dm2
    If $dmstr = $dm3 Then $detailmenu0 = $dm3
Next
$hwnd = _IEPropertyGet($oIE, "hwnd")
;_IEAction($dmstr, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(1000)
;<---------------------------------#Details Sub Menu#-------------------------------->
$aat = _IELinkClickByText($oIE, "Go To Activities and Tasks")
Sleep(250)
_IELoadWait($oIE)


;<---------------------------------#Activities & Tasks (Plans Tab)-------------------->
Sleep(250)
_IEAttach("Activities and Tasks", "windowtitle", 0)
$plan2_click0 = "Plans"
$plan2_click1 = "mx206_anchor"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $plan2_click0) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
    $sLinkStr = _IEGetObjById($oLink, $plan2_click1)
    If StringInStr($sLinkStr, $plan2_click1) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next
Sleep(2050)

; =================================================================================================
;                                           #Assign Ownership# 
; =================================================================================================
$ownerfill = _IETagNameGetCollection($oIE, "input")
$oid = "mx5686[R:0]"
For $ownerfill0 In $ownerfill
Global $o_post = _IEPropertyGet($oIE, "innerhtml")
If $o_post = $oid Then $ownerfill0 = $oid
Next
$o_submit = _IEGetObjById($oIE, $oid)
_IEAction($o_submit, "focus")
Sleep(1000)
Send("namex")
Sleep(500)
Send("{TAB}")
Sleep(4000)
Send("!r")
Sleep(3000)
Send("{Enter}")

Func top_return() <-----------------When its finished Return back to the top and use the 2nd stored #
    $gb = windows ()
EndFunc

I figure why not send it to the top function (windows) then let it run to where the ticket input is, since they are on different pages. Then it'll just pull the 2nd, 3rd, 4th, etc. #'s down from the array list until its complete

Edited by JayFran

Share this post


Link to post
Share on other sites

JayFran,

It would really help if you would clearly state what you want when you first post - it would save us all a lot of time and wasted effort.

As I do not have access to the IE pages, I cannot really help further. However, what you want to do is this:

Run the little loop to get all the ticket numbers into an array

Run your IE code until you get to the pont where you can access the "array list" where the ticket numbers are used.

Then you start a loop like this

For $i = 1 To $t_number[0]

    Now Send $t_number[$i] to start the process for this ticket


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
            




  
  
    

    Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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
        
    



     


  


        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
Melba23   

    
        
    
             2,518
    
        
    

        
            
                Soy viejo, ¿cuál es tu excusa?
            
            

            
                

    
        
    

            
            Moderators
            
                
            
            
                

    
        
    
             2,518
    
        
    

                27,849 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #9 · 
            Posted 
            
            
            
        
    

    


            
        
            
JayFran,

It would really help if you would clearly state what you want when you first post - it would save us all a lot of time and wasted effort. 

As I do not have access to the IE pages, I cannot really help further.  However, what you want to do is this:
Run the little loop to get all the ticket numbers into an array

Run your IE code until you get to the point where you can access the "array list" where the ticket numbers are used.

Then you start a loop like this

For $i = 1 To $t_number[0]

    Now Send $t_number[$i] to start the process for this ticket

    When you are done with whatever you are doing, navigate back to the same point as we started (point where you can access the "array list" where the ticket numbers are used).

Next

Exit

I hope this helps - I am off to bed. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

M23, My apologies. Will do from now on. Thanks for your help.

I got the script to to store the numbers and merge it into my code. The only issue now is when it goes to send the first ticket number i put in the inputbox, it sends all of them at once. (See Attachment). I've been trying to play around with it to only send one at a time until the loop is finished and comes back around to it, but no luck.

#include <IE.au3>
#include<Debug.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 2) 


Global $t_number[1] = [0]

; Enter tickets
While 1

    ; Get ticket value
    $a_number = InputBox("Ticket", "Please enter a ticket number")

    ; Exit loop with empty ticket or Cancel
    If $a_number = "" Then ExitLoop

    ; Store ticket number in array
    $t_number[0] += 1
    ReDim $t_number[$t_number[0] + 1]
    $t_number[$t_number[0]] = $a_number

WEnd


Global $oIE

Local $handle0[3] = ["Changes", "Activities and Tasks", "Start Center"]

For $h = 0 To UBound($handle0) -1
$resume = WinGetHandle($handle0[$h])
    
If $resume = "Changes" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)

If $resume = "Activities and Tasks" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume);_IEAttach("https://129.39.231.133/maximo/ui/maximo.jsp?event=gotoapp&value=activity", "url")
    ;$goback = ActivitiesReturn()
If $resume = "Start Center" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)
If @error Then ConsoleWrite("There was an error " & $h & @CRLF)
    ;EndIf

Next


Do
$oIE = _IEAttach("https://129.39.231.133/", "url")
$tid_0 = "mx398"
$tid_1 = "mx404"
If IsObj($oIE) Then $ticketfill = _IETagNameGetCollection($oIE, "input")
For $Oticketfill In $ticketfill
Global $t_post = _IEPropertyGet($oIE, "innerhtml")
If $t_post = $tid_0 Then $Oticketfill = $tid_0
If $t_post = $tid_1 Then $0ticketfill = $tid_1
Next
$t_submit = _IEGetObjById($oIE, $t_post)
_IEAction($t_submit, "focus")
Sleep(1000)
For $z = 1 To $t_number[0]
Send($t_number[$z])
Next
;=========================================================================
;                      My Main Code After T.# is sent.
;=========================================================================
Until $t_number[0]

post-59549-12847342349599_thumb.jpg

Share this post


Link to post
Share on other sites

I still need some help. I rewrote the code and nothing is sending. But Now I can store the array, see the last ticket # entered and the ticket count. Any help is appreciated.

#include <IE.au3>
#include<Debug.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 2) 
Local $arr[10000]
Global $t_number[10000], $a_number[9999]
$totaltickets = 0
$z = 0
; Enter tickets
 $a_number = InputBox($totaltickets, "Please enter a ticket number")
;While 1
    
    ; Get ticket value
    If ($a_number = "file") Then
    _DebugOut("Error code:" & @error)
    
    While @error = 0
        $a_number = StringRegExp($a_number, '[0-9]', 1)


        If @error = 1 Then ExitLoop
    ; Exit loop with empty ticket or Cancel
    If $a_number = "" Then ExitLoop

        _DebugOut($totaltickets & "->" & $a_number[0])
        $arr[$totaltickets] = $a_number[0]
        $totaltickets += 1
    WEnd

    
Else

    while ($a_number > 0)
        $arr[$totaltickets] = $a_number
        if ($a_number > 0) Then $totaltickets = $totaltickets + 1
        $a_number = InputBox($totaltickets, "Last ticket: " & $a_number & @CR & "Enter Ticket Number:")
    WEnd
EndIf
;WEnd



Global $oIE

Local $handle0[3] = ["Changes", "Activities and Tasks", "Start Center"]

For $h = 0 To UBound($handle0) -1
$resume = WinGetHandle($handle0[$h])
    
If $resume = "Changes" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)

If $resume = "Activities and Tasks" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume);_IEAttach("https://129.39.231.133/maximo/ui/maximo.jsp?event=gotoapp&value=activity", "url")
    ;$goback = ActivitiesReturn()
If $resume = "Start Center" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)
If @error Then ConsoleWrite("There was an error " & $h & @CRLF)
    ;EndIf

Next


Do
$oIE = _IEAttach("https://129.39.231.133/", "url")
$tid_0 = "mx398"
$tid_1 = "mx404"
If IsObj($oIE) Then $ticketfill = _IETagNameGetCollection($oIE, "input")
For $Oticketfill In $ticketfill
Global $t_post = _IEPropertyGet($oIE, "innerhtml")
If $t_post = $tid_0 Then $Oticketfill = $tid_0
If $t_post = $tid_1 Then $0ticketfill = $tid_1
Next
$t_submit = _IEGetObjById($oIE, $t_post)
_IEAction($t_submit, "focus")
Sleep(1000)
For $z = 1 To $arr[$totaltickets]
Send($a_number)
;Send($t_number[$z])
Next
Until Sleep(1000);$t_number[0]

Share this post


Link to post
Share on other sites

JayFran,

This is based on your 17 Sep code:

Correct, it does send them all at once - because you tell it to! :) You need to run your main code within the loop, not after it.

Try changing this part: ;)

Do
    $oIE = _IEAttach("https://129.39.231.133/", "url")
    $tid_0 = "mx398"
    $tid_1 = "mx404"
    If IsObj($oIE) Then $ticketfill = _IETagNameGetCollection($oIE, "input")
    For $Oticketfill In $ticketfill
        Global $t_post = _IEPropertyGet($oIE, "innerhtml")
        If $t_post = $tid_0 Then $Oticketfill = $tid_0
        If $t_post = $tid_1 Then $0ticketfill = $tid_1
    Next
    $t_submit = _IEGetObjById($oIE, $t_post)
    _IEAction($t_submit, "focus")
    Sleep(1000)
    For $z = 1 To $t_number[0]
        Send($t_number[$z])
    ; Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Not here !
    ;=========================================================================
    ;                      My Main Code After T.# is sent.
    ;=========================================================================
    Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< But here !

Until $t_number[0]

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

JayFran,

This is based on your 17 Sep code:

Correct, it does send them all at once - because you tell it to! o:) You need to run your main code within the loop, not after it.

Try changing this part: :P

Do
    $oIE = _IEAttach("https://129.39.231.133/", "url")
    $tid_0 = "mx398"
    $tid_1 = "mx404"
    If IsObj($oIE) Then $ticketfill = _IETagNameGetCollection($oIE, "input")
    For $Oticketfill In $ticketfill
        Global $t_post = _IEPropertyGet($oIE, "innerhtml")
        If $t_post = $tid_0 Then $Oticketfill = $tid_0
        If $t_post = $tid_1 Then $0ticketfill = $tid_1
    Next
    $t_submit = _IEGetObjById($oIE, $t_post)
    _IEAction($t_submit, "focus")
    Sleep(1000)
    For $z = 1 To $t_number[0]
        Send($t_number[$z])
    ; Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Not here !
    ;=========================================================================
    ;                      My Main Code After T.# is sent.
    ;=========================================================================
    Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< But here !

Until $t_number[0]

M23

YES!! Thanks that works! o:) My code stores the numbers, send one at a time and runs thru flawlessly, and I can make it go back to the ticket input screen :) . but its not sending the next ticket number ;) , its like its hiting enter or the submit button ;) . I posted the code, to show what I have

#include <IE.au3>
#include<Debug.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 2) 


Global $t_number[1] = [0]

; Enter tickets
While 1

    ; Get ticket value
    $a_number = InputBox("Ticket", "Please enter a ticket number")

    ; Exit loop with empty ticket or Cancel
    If $a_number = "" Then ExitLoop

    ; Store ticket number in array
    $t_number[0] += 1
    ReDim $t_number[$t_number[0] + 1]
    $t_number[$t_number[0]] = $a_number

WEnd


Global $oIE

Local $handle0[3] = ["Changes", "Activities and Tasks", "Start Center"]

For $h = 0 To UBound($handle0) -1
$resume = WinGetHandle($handle0[$h])
    
If $resume = "Changes" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)

If $resume = "Activities and Tasks" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume);_IEAttach("https://129.39.231.133/maximo/ui/maximo.jsp?event=gotoapp&value=activity", "url")
    ;$goback = ActivitiesReturn()
If $resume = "Start Center" Then $oIE = _IEAttach("https://129.39.231.133/", "url")
    WinActivate($resume)
If @error Then ConsoleWrite("There was an error " & $h & @CRLF)
    ;EndIf

Next


Do
Sleep(1000)
$oIE = _IEAttach("https://129.39.231.133/", "url")
$tid_0 = "mx398"
$tid_1 = "mx404"
If IsObj($oIE) Then $ticketfill = _IETagNameGetCollection($oIE, "input")
For $Oticketfill In $ticketfill
Global $t_post = _IEPropertyGet($oIE, "innerhtml")
If $t_post = $tid_0 Then $Oticketfill = $tid_0
If $t_post = $tid_1 Then $0ticketfill = $tid_1
Next
$t_submit = _IEGetObjById($oIE, $t_post)
_IEAction($t_submit, "focus")
Sleep(1000)
For $z = 1 To $t_number[0]
Send($t_number[$z])
Sleep(2500)
$changetab = "Change"
$c_links = _IELinkGetCollection($oIE)
For $c_link in $c_links
    $cLinkText = _IEPropertyGet($c_link, "innerText")
    If StringInStr($cLinkText, $changetab) Then
        _IEAction($c_link, "click")
        ExitLoop
    EndIf
Next
_IELoadWait($oIE, 7000)
; =================================================================================================
;                                           #View Attachments# 
; =================================================================================================

;Sleep(15000)
_IEAttach("Attachments", "html")
$u_imageid0 = "mx847"
$u_imageid1 = "mx853"
$u_imageid2 = "Attachments"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerhtml")
    If StringInStr($sLinkText, $u_imageid0) Then
        _IEAction($oLink, "click")
          ExitLoop
    EndIf
     If StringInStr($sLinkText, $u_imageid1) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
    $uimg = _IEImgGetCollection($oIE)
        If $uimg = $u_imageid2 Then $oLink = $u_imageid2
        _IEImgClick($oIE, $u_imageid2, "alt", 0)
            ExitLoop
            
Next

Sleep(550)
$view_attach = "view_middle_anchor"
$v_a = _IEGetObjById($oIE, $view_attach)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($v_a, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(5000)
; =================================================================================================
;                               #Open & Print Attachment Pt.1# 
; =================================================================================================
$db = _IEGetObjById($oIE, "viewattachments_bodydiv")
If IsObj($db) Then $ok_but = _IETagNameGetCollection($db, "A", 9)
$return = _IEAction($ok_but, "focus")
$ib = "Information Bar"
;If $ib = WinActive("Information Bar") Then ControlClick($ib, "", "CLASS:Button; INSTANCE:1]")
Sleep(1500)
Send("{Enter}")
;Exit
;If $ib <> WinActive("Information Bar") Then Exit
;_IEAttach("https://129.39.231.133/attachments/", "windowtitle")
Sleep(2500)
$fd = WinWaitActive("File Download")
Sleep(2500)
Send("!o")
Send("{TAB}")
;ControlClick($fd, "", "[CLASS:Button; INSTANCE:1]")
Sleep(2000)
$handle = WinGetHandle("https://129.39.231.133/attachments", "PC REPLACEMENT")
WinActivate($handle)
Sleep(1950)
Send("^p")
$print0 = WinActive("Print")
Sleep(1000)
Send("{Enter}")
Sleep(1500)
WinClose($handle)
$hWin = WinGetHandle("https://129.39.231.133/attachments", "This document has been modified. Do you want to save changes?")
WinActivate($hWin)
Sleep(1500)
ControlClick($hWin, "", "[CLASS:Button; INSTANCE:2]")
;WinClose($handle)
Sleep(800)
WinActivate("Changes - Windows Internet Explorer")
Sleep(2000)
$db = _IEGetObjById($oIE, "viewattachments-dialog_dialog_content1")
If IsObj($db) Then $ok_but = _IETagNameGetCollection($db, "button", 0)
$return = _IEAction($ok_but, "click")
Sleep(2500)
; =================================================================================================
;                               #Open & Print Attachment Pt.2# 
; =================================================================================================
$long_d = "mx902"
$ldimg = _IEImgClick($oIE, "Long Description", "alt", 0)
Sleep(2500)
Send("^p")
$print1 = WinWaitActive("Print")
;ControlClick($print1, "", "[CLASS:Button; INSTANCE:13]")
Sleep(2000)
Send("{Enter}")
WinWaitActive("Changes - Windows Internet Explorer")
$db2 = _IEGetObjById($oIE, "longdesc_dialog-dialog_dialog_inner")
If IsObj($db2) Then $ok_but2 = _IETagNameGetCollection($db2, "button", 3)
$return2 = _IEAction($ok_but2, "click")
Sleep(3500)

; =================================================================================================
;                                           #Navigate to Ownership# 
; =================================================================================================
$plantab0 = "Plans"
$plantab1 = "mx209_anchor"
$p_links = _IELinkGetCollection($oIE)
For $p_link in $p_links
    $pLinkText = _IEPropertyGet($p_link, "innerText")
        If StringInStr($pLinkText, $plantab0) Then
        _IEAction($p_link, "click")
        ExitLoop
    EndIf
    $pLinkstr = _IEGetObjById($p_link, $plantab1)
    If $pLinkstr = $plantab1 Then $p_link = $plantab1
    
Next
_IEAction($p_link, "focus")
$hwnd = _IEPropertyGet($oIE, "hwnd")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(3000)
_IELoadWait($oIE)
Sleep(1250)
$dm1 = "Detail Menu"
$dm2 = "mx5692[R:0]"
$dm3 = "mx3057[R:0]"
$detailmenu = _IEImgGetCollection($oIE)
For $detailmenu0 in $detailmenu
    $dmimg = _IEPropertyGet($detailmenu0, "innerText")
     If $dmimg = $dm1 Then
        _IEImgClick($detailmenu0, $dm1, "alt", 9)
        ExitLoop
    EndIf   
    $dmstr = _IEGetObjById($detailmenu0, $dm2)
    $dmstr = _IEGetObjById($detailmenu0, $dm3)
    If $dmstr = $dm2 Then $detailmenu0 = $dm2
    If $dmstr = $dm3 Then $detailmenu0 = $dm3
Next
$hwnd = _IEPropertyGet($oIE, "hwnd")
;_IEAction($dmstr, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(1000)
;<---------------------------------#Details Sub Menu#-------------------------------->
$aat = _IELinkClickByText($oIE, "Go To Activities and Tasks")
Sleep(250)
_IELoadWait($oIE)


;<---------------------------------#Activities & Tasks (Plans Tab)-------------------->
Sleep(250)
_IEAttach("Activities and Tasks", "windowtitle", 0)
$plan2_click0 = "Plans"
$plan2_click1 = "mx206_anchor"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $plan2_click0) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
    $sLinkStr = _IEGetObjById($oLink, $plan2_click1)
    If StringInStr($sLinkStr, $plan2_click1) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next
Sleep(2050)

; =================================================================================================
;                                           #Assign Ownership# 
; =================================================================================================
$ownerfill = _IETagNameGetCollection($oIE, "input")
$oid = "mx5686[R:0]"
For $ownerfill0 In $ownerfill
Global $o_post = _IEPropertyGet($oIE, "innerhtml")
If $o_post = $oid Then $ownerfill0 = $oid
Next
$o_submit = _IEGetObjById($oIE, $oid)
_IEAction($o_submit, "focus")
Sleep(1000)
Send("jimf")
Sleep(500)
Send("{TAB}")
Sleep(4000)
Send("!r")
Sleep(3000)
Send("{Enter}")
Sleep(2000)
; =================================================================================================
;                                           #Go Back to Ticket input# 
; =================================================================================================
$c_click = "mx46"
$changes = _IEGetObjById($oIE, $c_click)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
Sleep(1250)
$c_click2 = "menu0_CHANGE_MODULE_middle_anchor"
$changes2 = _IEGetObjById($oIE, $c_click2)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes2, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
sleep(1250)
$c_click3 = "menu7_CHANGE_APP_middle_anchor"
$changes3 = _IEGetObjById($oIE, $c_click3)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($changes3, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
_IELoadWait($oIE)
Next
Until $t_number[0]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I was thinking can I use a return function or command at the end of my script, to go/return where the code searches for the inputbox and then sends the ticket #?

Edited by JayFran

Share this post


Link to post
Share on other sites

JayFran,

Perhaps you need to move this line:

_IEAction($t_submit, "focus")

within the For...Next loop so that you refocus each time before Sending the next ticket number. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

JayFran,

Perhaps you need to move this line:

_IEAction($t_submit, "focus")

within the For...Next loop so that you refocus each time before Sending the next ticket number. ;)

M23

BRILLLANT!!! :) Thank you! Works perfectly with a sleep timer.

Share this post


Link to post
Share on other sites

JayFran,

Does that mean we have finally got there and your script is working as you want it to? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

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  
Followers 0