Jump to content

need help with control send


royco
 Share

Recommended Posts

i combining my prog with program i find in this forum

this program should show me few windows of game i play (silkroad online)

and the clicker i made need to send key to the window i choosed

the problem is that

after i renamed the window i want to start looping the key on the selected window

* i want to continue what im doing while the key is sent

here is the script

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

;Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

Global $Client[1][1], $Array[1], $fStop_Flag = False, $fTimer_Flag = False, $iTimer

$Form1 = GUICreate("Silkroad Client Manager", 280, 440, 193, 90)
GUISetBkColor(0xE0F0FE)
$listview = GUICtrlCreateListView("Client Name", 5, 75, 270, 150, BitOR($LVS_SORTDESCENDING, $LVS_LIST, $LVS_SHOWSELALWAYS));The right way to have multiple styles is with BitOr()
$Button1 = GUICtrlCreateButton("Min", 5, 8, 60, 25);setting the style to 0 doesn't do anything so removed all of them
GUICtrlSetBkColor(-1,0X88dddd)
$Button2 = GUICtrlCreateButton("Max", 75, 8, 60, 25)
GUICtrlSetBkColor(-1,0X88dddd)
$Button3 = GUICtrlCreateButton("Hide", 145, 8, 60, 25)
GUICtrlSetBkColor(-1,0X88dddd)
$Button4 = GUICtrlCreateButton("Show", 215, 8, 60, 25)
GUICtrlSetBkColor(-1,0X88dddd)
$Button5 = GUICtrlCreateButton("Exit", 215, 40, 60, 25)
GUICtrlSetBkColor(-1,0X88dddd)
$Button6 = GUICtrlCreateButton("Refresh", 145, 40, 60, 25)
GUICtrlSetBkColor(-1,0X88dddd)
$Button7 = GUICtrlCreateButton("Rename", 75, 40, 60, 25)
GUICtrlSetBkColor(-1,0X88dddd)
$inputNewName = GUICtrlCreateInput("Sro_1",5,40,60,25)

$countdown = GUICtrlCreateInput("Time_Left?", 130, 310, 60, 25)
$go = GUICtrlCreateButton("Set", 215, 310, 60,25)
GUICtrlSetTip(-1 ,"set the time, press this button, then Buff")
GUICtrlSetBkColor(-1,0Xff9900)
$Buff = GUICtrlCreateButton("Buff (F8)",130,345,60, 25) ;"{F8}", "Buff"
GUICtrlSetTip(-1 ,"Choose keys to press and start Buff")
GUICtrlSetBkColor(-1,0X00dd00)
$Stop = GUICtrlCreateButton("Stop (F11)",215 ,345,60,25) ;"{F11}", "HK_STOP"
GUICtrlSetTip(-1 ,"Stop all action")
GUICtrlSetBkColor(-1,0Xff1177)

GUICtrlCreateLabel("Made by Royco" & @CRLF & "Thanks to M23",195,410,150, 25)
GUICtrlSetBkColor(-1,0X44bbcc)

GUICtrlCreateGroup("Choose",130, 230, 140, 70)
GUICtrlCreateLabel("* Start Buff = F8", 140, 252, 85)
GUICtrlCreateLabel("* Stop All actions = F11", 140, 272)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group

; check box to select what key to press
$item0 = GUICtrlCreateCheckbox("0", 5, 410, 40, 20)
$item1 = GUICtrlCreateCheckbox("1", 5, 230, 40, 20)
$item2 = GUICtrlCreateCheckbox("2", 5, 250, 40, 20)
$item3 = GUICtrlCreateCheckbox("3", 5, 270, 40, 20)
$item4 = GUICtrlCreateCheckbox("4", 5, 290, 40, 20)
$item5 = GUICtrlCreateCheckbox("5", 5, 310, 40, 20)
$item6 = GUICtrlCreateCheckbox("6", 5, 330, 40, 20)
$item7 = GUICtrlCreateCheckbox("7", 5, 350, 40, 20)
$item8 = GUICtrlCreateCheckbox("8", 5, 370, 40, 20)
$item9 = GUICtrlCreateCheckbox("9", 5, 390, 40, 20)

$input0 = GUICtrlCreateInput("1000", 45, 410, 40, 20)
$input1 = GUICtrlCreateInput("1000", 45, 230, 40, 20)
$input2 = GUICtrlCreateInput("1000", 45, 250, 40, 20)
$input3 = GUICtrlCreateInput("1000", 45, 270, 40, 20)
$input4 = GUICtrlCreateInput("1000", 45, 290, 40, 20)
$input5 = GUICtrlCreateInput("1000", 45, 310, 40, 20)
$input6 = GUICtrlCreateInput("1000", 45, 330, 40, 20)
$input7 = GUICtrlCreateInput("1000", 45, 350, 40, 20)
$input8 = GUICtrlCreateInput("1000", 45, 370, 40, 20)
$input9 = GUICtrlCreateInput("1000", 45, 390, 40, 20)

GUICtrlCreateLabel("mSec", 90, 410, 40, 20)
GUICtrlCreateLabel("mSec", 90, 230, 40, 20)
GUICtrlCreateLabel("mSec", 90, 250, 40, 20)
GUICtrlCreateLabel("mSec", 90, 270, 40, 20)
GUICtrlCreateLabel("mSec", 90, 290, 40, 20)
GUICtrlCreateLabel("mSec", 90, 310, 40, 20)
GUICtrlCreateLabel("mSec", 90, 330, 40, 20)
GUICtrlCreateLabel("mSec", 90, 350, 40, 20)
GUICtrlCreateLabel("mSec", 90, 370, 40, 20)
GUICtrlCreateLabel("mSec", 90, 390, 40, 20)


HotKeySet("{f8}","Buff")
HotKeySet("{f11}","HK_STOP")


_Refresh()
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button5
            Exit
        Case $Button1
            _SetState(@SW_MINIMIZE)
        Case $Button2
            _SetState(@SW_MAXIMIZE)
        Case $Button3
           _SetState(@SW_HIDE)
        Case $Button4
            _SetState(@SW_SHOW)
        Case $Button6
            _Refresh()
        Case $Button7
            Rename()
        Case $Stop
            HK_STOP()
        Case $buff
            Buff()
        Case $go
            on_go()
    EndSwitch
WEnd

Func _SetState($State)
    $Array = _GUICtrlListView_GetSelectedIndices($listview, True)
    For $Y = 1 To $Array[0]
        WinSetState($Client[$Array[$Y]][1], "", $State)
    Next
EndFunc

Func _Refresh()
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    $Client = WinList("[CLASS:CLIENT]")
    If $Client[0][0] > 0 Then
        For $X = 1 To $Client[0][0]
            GUICtrlCreateListViewItem($Client[$X][0], $listview)
        Next
    Else
        GUICtrlCreateListViewItem("No Clients Found", $listview)
    EndIf
    _GUICtrlListView_EndUpdate($listview)
EndFunc  ;==>_Refresh

Func Rename()

    If  GUICtrlRead("[CLASS:CLIENT]") = "Default Name" Then
        WinSetTitle("[CLASS:CLIENT]","",GUICtrlRead($inputNewName))
        ;GUICtrlSetData($inputNewName, WinGetTitle($inputNewName))
        _Refresh()
    ;Else
     ;   WinSetTitle(GUICtrlRead("[CLASS:CLIENT]"), "", GUICtrlRead($inputNewName))
    EndIf
EndFunc

Func Buff()

    ; Create array to hold key/timer data
    Local $aKeys[10][3]

    ; Check required keys and delays
    For $i = 0 To 9
        If BitAND(GUICtrlRead($i + $item0), $GUI_CHECKED) = $GUI_CHECKED Then
            $aKeys[$i][0] = True
            $aKeys[$i][1] = GUICtrlRead($i + $input0)
        EndIf
    Next

    ; Set start time
    $iBegin = TimerInit()
    For $i = 0 To 9
        $aKeys[$i][2] = $iBegin
    Next

    ; Set timer countdown value
    $iCurr_Left = 0

    While 1
        ; Check if key press to be sent
        For $i = 0 To 9
            ; Send this key?
            If $aKeys[$i][0] = True Then
                ; Is it time to send this key?
                If TimerDiff($aKeys[$i][2]) > $aKeys[$i][1] Then
                    ; Send key
                    ControlSend("","","",$i) ;  need to add value of what window to ControlSend
                    ; Reset timer for this key
                    $aKeys[$i][2] = TimerInit()
                EndIf
            EndIf
        Next

        ; Check if Stop flag set
        If $fStop_Flag = True Then
            ; reset flag and exit loop
            $fStop_Flag = False
            ExitLoop
        EndIf

        ; Check if timer flag set
        If $fTimer_Flag = True Then
            ; have we timed out?
            If TimerDiff($iBegin) > $iTimer Then
                ; Reset timer, window title and tooltip and exit loop
                $fTimer_Flag = False
                WinSetTitle($Form1, "", "Silkroad Client Manager")
                ToolTip("")
                ExitLoop
            Else
                ; calculate time left
                $iLeft = Int(($iTimer - TimerDiff($iBegin)) / 1000)
                ; do we need to change title and tooltip (if we change every time they flicker!)
                If $iLeft <> $iCurr_Left Then
                    ; So change them
                    WinSetTitle($Form1, "", $iLeft & " seconds left")
                    ToolTip($iLeft, 800, 0, "seconds left")
                    $iCurr_Left = $iLeft
                EndIf
            EndIf
        EndIf

    WEnd

EndFunc   ;==>Buff

Func on_go()
    ;Set timer and timer flag
    $iTimer = GUICtrlRead($countdown)
    $fTimer_Flag = True
EndFunc

Func CLOSEClicked()
    Exit
EndFunc   ;==>CLOSEClicked

; Stops the program
Func HK_STOP()
    ; Set the stop flag
    $fStop_Flag = True
EndFunc   ;==>HK_STOP
Link to comment
Share on other sites

I'm not sure what you want after a quick look at your code, but maybe instead of calling buf() and sending the keys there, you could change buf to set up the times for each key as you do already, but use AdlibRegister to send them. (You will have to use the Beta version for that.) Then having set up the Adlibs you can exit the function and continue with something else while the keys are sent.

I hope that makes sense but tell me if not.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I'm not sure what you want after a quick look at your code, but maybe instead of calling buf() and sending the keys there, you could change buf to set up the times for each key as you do already, but use AdlibRegister to send them. (You will have to use the Beta version for that.) Then having set up the Adlibs you can exit the function and continue with something else while the keys are sent.

I hope that makes sense but tell me if not.

the script is ready

i just need to make it work with minimized window with control send or somthing else

in my script in buff function there is controlsend but i cant make it to send to game called silkroad online (no game guard)

thanks

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...