Jump to content

ANYGUI problem deleting pictures created on target


Recommended Posts

The code below creates pictures on the current window in the loop by a method of inireading and so forth. What is important and what I'm having trouble with is at the beginning of my function I want to delete all of the pictures created by _TargetAddPic().

For example, I have two external windows running and I "embed" and create a picture on each external window using _TargetAddPic(). So far everything is perfect. Well after it has finished running through the loop it goes back to the beginning of the function. What I want to do is when it starts over again I want to delete ALL pictures on the external windows before continuing in the function and I dont know how to do this. I attempted as you will see below but failed >_<

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MY GOAL AND WHAT I NEED HELP WITH IS TO CREATE LITTLE
; PICTURES ON EXTERNAL WINDOWS USING ANYGUI. THE REASON I
; WANT TO USE ANYGUI IS BECAUSE IT "EMBEDS" THE PICTURES
; INTO THE TARGET WINDOW SO THEY WILL MOVE WITH AND
; MINIMIZE WITH THE TARGET WINDOW


; MY PROBLEM IS AT THE BEGINNING OF THIS FUNCTION I WANT
; TO --DELETE-- ALL EXISTING PICTURES CREATED BY ANYGUI
; USING THE _TARGETADDPIC(). I TRY TO DO THIS ON LINE
; 18 BUT IT'S NOT COMPLETELY WORKING. PLEASE HELP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func Test()
    If ProcessExists("Application.exe") Then

        ;-------------------------------------------------
        For $i = 1 To $ahInput[0][0]
                GUIDelete($ahInput[$i][0])  ; delete all little pictures created by _TargetAddPic() (NOT WORKING)
        Next
        ;-------------------------------------------------

        $string = "Test" & StringReplace(StringTrimRight(_NowCalc(),8), "/","") 

        $ftpname = IniRead(@ScriptDir & "\data\Config.dat", "Section", "Logging", "")
        $array = StringSplit($ftpname, "\")
        $i = $array[0]  
        $ftpname = $array[$i]

        If $ftpname = "" Then   ; either the user hasn't set Logging location yet or has done it incorrectly
            MsgBox(0, "", "Configure your Logging location in the settings window.")
        EndIf

        $hhf_dir = IniRead(@ScriptDir & "\data\Config.dat", "Section", "Logging", "")

        $list = WinList("[CLASS:QWidget]")  ; list all windows with classname QWidget
        For $n = 1 To $list[0][0]
            If $list[$n][0] <> "" AND IsVisible($list[$n][1]) Then  ; if window is visible and has a title
                If $list[$n][0] = "Window Name Test Window " & $ftpname Then        ; skip this window
                Else
                    ; store the path of the file
                    $path = $hhf_dir & "\" & $string & "" & StringTrimRight(StringReplace($list[$n][0], "/", "-"), StringLen($ftpname) + 16) & ".txt"

                    ; open for reading
                    $hh = FileOpen($hhf_dir & "\" & $string & "" & StringTrimRight(StringReplace($list[$n][0], "/", "-"), StringLen($ftpname) + 16) & ".txt", 0)
                    If $hh = -1  Then
                        ContinueLoop
                    EndIf
                    
                    ; close file
                    FileClose($hh)

                    $target = _GUITarget($list[$n][0]   ; HERE'S THE ANYGUI CODE --- I WANT TO TARGET THE CURRENT WINDOW IN THE LOOP

                    $count = _FileCountLines($path)

                    For $s=10 To 0 Step -1
                        $line = FileReadLine($path, $count - $s)
                        FileWrite(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt", $line & @CRLF)
                    Next
                    $readtemp = FileRead(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt")

                    ; read temp data into array
                    _FileReadToArray(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt", $asArray)

                    $sectionNAMES=IniReadSectionNames($datfile)
                    For $t=1 To $sectionNAMES[0]    
                        $section = IniReadSection($datfile, "Section" & $t)
                        For $i=1 To $section[0][0]  
                            If StringInStr($readtemp, $section[$i][0]) Then
                                $split = StringSplit($section[$i][1], ",")  
                                For $x = 1 To $split[0]
                                    If $split[$x] = "Info/data" Then
                                        For $q = 1 To $asArray[0]
                                            If StringInStr($asArray[$q],$section[$i][0]) > 0 Then   
                                                If StringLeft($asArray[$q],5) = "Seat " Then
                                                    $Seat = StringMid($asArray[$q],6,1)
                                                    IniWrite(@ScriptDir & "\data\test.ini", $list[$n][0], $section[$i][0] & "*Seat" & $Seat, "Info/data")
                                                EndIf
                                            EndIf
                                        Next
                                    EndIf
                                Next
                            EndIf
                        Next
                    Next
                    FileDelete(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt")

                    $names = IniReadSectionNames(@ScriptDir & "\data\test.ini")
                    If IsArray($names) Then
                    For $e=1 To $names[0]   ; for each section name
                        $dumpsection = IniReadSection(@ScriptDir & "\data\test.ini", $names[$e])
                        For $a=1 To $dumpsection[0][0]  ; for each key/value in section
                            $secondsplit = StringSplit($dumpsection[$a][0], "*")
                            For $g=1 To $secondsplit[0]
                                If $secondsplit[$g] = "Seat1" Then
                                    $current_tilt_win = WinGetPos($names[$e])
                                    $ahInput[0][0] += 1
                                    ReDim $ahInput[$ahInput[0][0] + 1][6]
                                    
                                    ; HERE'S WHERE I ADD A PIC ONTO THE WINDOW
                                    $ahInput[$ahInput[0][0]][0] = _TargetAddPic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 100, 100, 26, 26, -1, -1, $target)

                                    
                                    #cs -- HERE'S THE OLD METHOD I USED TO CREATE WINDOWS ON AN EXTERNAL APP --
                                    
                                    $ahInput[$ahInput[0][0]][0] = GUICreate(StringTrimRight($dumpsection[$a][0], 6), 26, 26, $current_tilt_win[0] + 454, $current_tilt_win[1] + 139, _
                                    $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
                                    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 0, 0, 26, 26, -1)
                                    
                                    #ce
                                ElseIf $secondsplit[$g] = "Seat2" Then
                                    $current_tilt_win = WinGetPos($names[$e])
                                    $ahInput[0][0] += 1
                                    ReDim $ahInput[$ahInput[0][0] + 1][6]
                                    
                                    ; HERE'S WHERE I ADD A PIC ONTO THE WINDOW
                                    $ahInput[$ahInput[0][0]][0] = _TargetAddPic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 204, 141, 26, 26, -1, -1, $target)


                                    #cs -- HERE'S THE OLD METHOD I USED TO CREATE WINDOWS ON AN EXTERNAL APP --
                                    
                                    $ahInput[$ahInput[0][0]][0] = GUICreate(StringTrimRight($dumpsection[$a][0], 6), 26, 26, $current_tilt_win[0] + 628, $current_tilt_win[1] + 219, _
                                    $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
                                    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 0, 0, 26, 26, -1)
                                    
                                    #ce 
                            Next
                        Next
                    Next
                    EndIf
                    FileDelete(@ScriptDir & "\data\test.ini")
                EndIf
            EndIf
        Next
    EndIf
EndFunc
Edited by Hypertrophy
Link to comment
Share on other sites

  • 3 weeks later...

Yeah its not working. I am creating multiple pictures using _TargetAddPic() and I want to be able to delete them all.

Im creating them like this

$target = _GuiTarget($list[$n][0], 1)
$ahInput[$ahInput[0][0]][0] = _TargetAddPic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 454, 139, 26, 26, -1, -1, $target)

And at the beginning of my function I do

_EndTarget()

but I dont see them disappear...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...