Sign in to follow this  
Followers 0
Lachee

ControlClick a checkbox inside a listbox

2 posts in this topic

Hello there,

I have recently downloaded BOLOPatch v4.00 for Just Cause 2 and decided to make a hotkey application for it so I can use key combinations with my gamepad in Just Cause 2 to activate certain cheats. 

The joystick reading is going well, however I have come to a road block. I cannot for the life of me get ControlClick to work on the checkboxes for the cheats!

The main problem is that the checkboxes seem to be inside a ListBox element, and I cannot get the controlID of individual items. I tried using AutoIt Window Info and  Winspector Spy, but neither were a help.

How can I get it to work? Here is the screen shots and my current code:

 

1u1tqcr07vgo0azfg.jpg

;#RequireAdmin

Local $joy,$coor,$h,$s,$msg
$joy    = _JoyInit()

;___________________________ KOWN COMBOS ____________________________________
; TRIANGLE + L1 = 24 (Set to detach multi hooks)
; START + L1 = 144 (Open Steam Window)
; START + R1 = 160 (Take screen shot [del] )
; L1 + R1 = 48 (go into slow motion [q] )
; Select + Start = 192 (close this program)

if(WinExists("[CLASS:Just Cause 2]")) Then
    ;Run("C:\Users\Lachee\Desktop\BOLOPatch4.00.exe")
    ;Run("C:\Users\Lachee\Desktop\SLOMOv2.exe") 

    $lastCode = 0
    while 1
        
        ;Gets the button flag of the buttons from joystick 0 (buttons are index 7)
        $coords = _GetJoy($joy,0)
        $bFlag = $coords[7]
        
        if($bFlag <> $lastCode AND $bFlag <> 0) Then
            ConsoleWrite("Input: " & $bFlag & @CRLF)

                Switch($bFlag)
                Case 24     

                    ConsoleWrite("Output: TRIANGLE + L1 (Multihook Toggle)" & @CRLF)
                    
                    ;This does not seem to work, no matter the coords or the controlID's I stick in!
                    $var = ControlClick("BOLOPatch v4.00","","[CLASS:WindowsForms10.LISTBOX.app.0.378734a; INSTANCE:1]","left",1,8,52)
                    ConsoleWrite("Output: " & $var & @CRLF)
                                        
                Case 144        
                    ConsoleWrite("Output: START + L1 [Shift+Tab] (steam overlay)" & @CRLF)
                Case 160        
                    ConsoleWrite("Output: START + R1 [del] (steam screenshot)" & @CRLF)
                Case 48     
                    ConsoleWrite("Output: R1 + L1 [q] (slow motion)" & @CRLF)
                EndSwitch
        
                $lastCode = $bFlag
            EndIf
            
        if($bFlag == 192) Then
            ConsoleWrite("Output: START + SELECT (exit this application)" & @CRLF)
            Exit
        EndIf


        
    WEnd

Else    
    ConsoleWriteError("Just Cause 2 is not running!" & @CRLF)
EndIf

$lpJoy=0 ; Joyclose


;======================================
;   _JoyInit()
;======================================
Func _JoyInit()
    Local $joy
    Global $JOYINFOEX_struct    = "dword[13]"
    $joy=DllStructCreate($JOYINFOEX_struct)
    if @error Then Return 0
    DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct)
    DllStructSetData($joy, 1, 255, 2)             ;dwFlags = GetAll
    return $joy
EndFunc
;======================================
;   _GetJoy($lpJoy,$iJoy)
;   $lpJoy  Return from _JoyInit()
;   $iJoy   Joystick # 0-15
;   Return  Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
;          Buttons down
;
;          *POV This is a digital game pad, not analog joystick
;          65535   = Not pressed
;          0       = U
;          4500 = UR
;          9000 = R
;          Goes around clockwise increasing 4500 for each position
;======================================
Func _GetJoy($lpJoy,$iJoy)
    Local $coor,$ret
    Dim $coor[8]
    DllCall("Winmm.dll","int","joyGetPosEx", _
            "int",$iJoy, _
            "ptr",DllStructGetPtr($lpJoy))
    if Not @error Then
        $coor[0]    = DllStructGetData($lpJoy,1,3)
        $coor[1]    = DllStructGetData($lpJoy,1,4)
        $coor[2]    = DllStructGetData($lpJoy,1,5)
        $coor[3]    = DllStructGetData($lpJoy,1,6)
        $coor[4]    = DllStructGetData($lpJoy,1,7)
        $coor[5]    = DllStructGetData($lpJoy,1,8)
        $coor[6]    = DllStructGetData($lpJoy,1,11)
        $coor[7]    = DllStructGetData($lpJoy,1,9)
    EndIf
    return $coor
EndFunc

Share this post


Link to post
Share on other sites



Lachee,

Please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game automation - before you post again. Thread locked. :naughty:

But welcome to the AutoIt forum - and see you soon with a legitimate question I hope. :)

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
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0