TC官方合作论坛

标题: 学习多开自己写了个东西老出错,求解决 [打印本页]

作者: killeven    时间: 2013-7-7 15:11
标题: 学习多开自己写了个东西老出错,求解决
就是向记事本发送字串符,比如开两个记事本,这个运行了,刚才开那个就不运行了,下面是代码

namespace 多开
//默认空间

ts=array[]
hwnd=array[]
thhwnd=array[]

function sendstr(handle)
    var index
    index=arraysp.find(hwnd,handle)
    ret=ts[index].bindwindow(hwnd[index],"gdi","windows","windows",1)
    ts[index].lockinput(1)
    while(ret)
        ts[index].sendstring(hwnd[index],"I love you \n")       
        help.sleep(500)
    endwhile
    return 0
   
endfunction



function hotkey1_onhotkey()
    //这里添加你要执行的代码
    handle=window.getmousemovewndhand()
    天使对象=com("ts.tssoft")
    arraysp.add(ts,天使对象)
    arraysp.add(hwnd,handle)
    ctthread=thread.beginthread("多开.sendstr",handle)
    arraysp.add(thhwnd,ctthread)
   
   
endfunction



function hotkey0_onhotkey()
    //这里添加你要执行的代码
    var index
    handle=window.getmousemovewndhand()
    index=arraysp.find(hwnd,handle)
    ts[index].unbindwindow()
    thread.closethread(thhwnd[index])
    arraysp.deleteat(ts,index)
    arraysp.deleteat(hwnd,index)
    arraysp.deleteat(thhwnd,index)
endfunction




endnamespace
//空间结束
作者: killeven    时间: 2013-7-7 15:14
也就是随便写的测试的东西,判断没加,勿喷
作者: 今非    时间: 2013-7-7 15:49
不知道 是哪儿不行了
作者: killeven    时间: 2013-7-7 16:14
回复 3楼今非的帖子

求解决啊,亲
作者: 今非    时间: 2013-7-7 16:41
标题: 错误之处
[attach]10076[/attach]

这里面的index是不会改变的,因为你每次传进去的 index=0
因此无论你多少开,每个线程里面的 index都等于0
所以 你前面开的都没效果了,然后越开得多,最后个的传字符速度越快
你的数组是从头部开始添加的



作者: 今非    时间: 2013-7-7 16:43
回复 3楼今非的帖子

求解决啊,亲
killeven 发表于 2013-7-7 16:14:07

亲 记得采纳噢
作者: killeven    时间: 2013-7-7 18:09
回复 5楼今非的帖子

貌似真的是,该咋解决啊
作者: killeven    时间: 2013-7-7 18:26
回复 5楼今非的帖子

我试了试尾部添加,可以了。谢啦
作者: 今非    时间: 2013-7-7 19:02
标题: 建议
回复 5楼今非的帖子

我试了试尾部添加,可以了。谢啦
killeven 发表于 2013-7-7 18:26:23

1.建议不在头部添加,因为处理index会比较麻烦,开多了也容易出现暂时的错乱
2.建议关闭时不要从头部或中间删除数组,其实把线程关闭了就可以了,否则处理index也会很麻烦,开多了也容易错乱,从尾部是可以的





欢迎光临 TC官方合作论坛 (http://bbs.52tc.co/) Powered by Discuz! X3.1