[AutoHotkey]clickable.ahk

本文介绍了AutoHotkey脚本clickable.ahk,依赖findtext.ahk, exsleep.ahk和exmath.ahk。主要内容包括findtext.ahk的主要接口,以及exsleep.ahk和exmath.ahk的简单封装功能。" 104431300,5608928,使用Kali Linux模拟钓鱼网站进行社会工程学攻击学习,"['网络安全', '渗透测试', '社会工程', 'Kali Linux工具', 'Web安全']
摘要由CSDN通过智能技术生成

此类依赖findtext.ahk,exsleep.ahk,exmath.ahk

声明:

  1. 所贴出的代码纯属个人原创
  2. 所有代码经过测试才贴,但不保证所有功能最终完成,可能后续会有更新,欢迎随时回顾
  3. 所有非原创的代码,会声明,尽量给出引用出处

主要接口

win := new Clickable("ahk_pid 12345", 0.5, true)
win.GetRect()
win.Act()
win.SetPath(exepath)
win.SetSize(width,height)
win.DoClick()
win.DoClick(x:=123,y:=456)
win.FindPic(Text)
win.ClickPic(Text)
win.SimClickPics(0,Text1,Text2...)
win.ClickPics(Text1,Text2...)
;//其中Text由抓图控件(中文版软件某版本自带)自动生成

findtext.ahk

本类由网络下载

exsleep.ahk, exmath.ahk

简单的封装了随机数和随机睡眠

clickable.ahk代码

#Include findtext.ahk
;// #Include exmath.ahk
#Include exSleep.ahk
; @author essdy@csdn
; @version 1.00
CNPID(n)
{
  return "ahk_pid " n
}
Class Clickable
{

  __New(CN, Indent = 0.5, PIDMOD = false, width = 0, height = 0)
  {
    this.CN := CN
    this.PIDMOD := PIDMOD
    if(Indent>0)
    this.Indent := Indent
    this.BackMode := false
    this.Trys := 1
    if(width != 0)
    {
      this.SetSize(width, height)
    }
  }
  SetTrys(n)
  {
    if(n >= 1)
    {
      this.Trys := ceil(n)     
    }
  }
  UnsetTrys()
  {
    this.Trys := 1
  }
  SetBgMode()
  {
    this.BackMode := true
  }
  UnsetBgMode()
  {
    this.BackMode := false
  }
  SetSize(w,h)
  {
    SRSleep(this.Indent)
    t := this.CN
    WinMove,%t%,,,,%w%,%h%
  }
  GetRect()
  {
    RTitle :=
    RWidth :=
    RHeight :=
    RX:=
    RY:=
    WinGetPos, RX, RY, RWidth, RHeight, % this.CN

    ; WinGetActiveStats, RTitle, RWidth, RHeight, RX, RY
    ; SRSleep(this.Indent)
    RRect := {x:RX,y:RY,width:RWidth,height:RHeight}
    return RRect
  }
  SetPath(exepath, reopenindent = 3)
  {
    if(exepath == "")
    {
      this.reopenindent := reopenindent
      return
    }
    if(!FileExist(exepath))
      throw Not Found File %exepath%
    this.exepath :=  exepath
    this.exepath_set :=  true
    this.reopenindent :=  reopenindent
  }
  Act(open = false)
  {
    CN:=this.CN
    SRSleep(this.Indent)
    if(!WinExist(CN))
    {
      if(!open)
        throw Not open %CN%
      if(!this.exepath_set)
        throw Not Exist App %CN%
      RunWait % this.exepath
      SRSleep(this.reopenindent)
    }
    if(WinActive(CN))return true
    WinActivate % CN
    return true
  }
  DoClick(params*)
  {
    l := params.Length()
    x:=
    y:=
     SRSleep(this.Indent)
    if(l == 2)
    {
      x:=params[1]
      y:=params[2]
      
      if(this.BackMode)
      {
         pt=x%x% y%y%
         SetControlDelay -1
          ControlClick, %pt%, % this.CN,,,1,NA Pos
      }
      else 
      {
        Click,%x% %y% 
      }
    }   
  }
  FindPic(Text, sim = 0)
  {
    this.Act()
    RWidth :=
    RHeight :=
    RX:=
    RY:=
    WinGetPos, RX, RY, RWidth, RHeight, % this.CN
    return FindText(RX, RY,RWidth, RHeight, sim, sim, Text)
  }
  ClickPic(Text, sim = 0)
  {
    MsgBox D
    this.Act()
    if( ok:= this.FindPic(Text, sim))
    {      
      CoordMode, Mouse
      X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
      this.DoClick(X,Y)
      return true
    }
  }
  SimClickPics(sim, params*)
  {
    RWidth :=
    RHeight :=
    RX:=
    RY:=
    WinGetPos, RX, RY, RWidth, RHeight, % this.CN
    For index, param in params
    {
      CL := param[1]
      Failed = 0
      if(!(param[1]>0))
        continue
      
      loop, % CL
      {
        TY := this.Trys
        loop, % TY
        if(ok := findtext(RX, RY, RWidth, RHeight,sim,sim, param[2]))
        {
          CoordMode, Mouse
          X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
          this.DoClick(X,Y)
          break
        }
      }      
    }
  }
  ClickPics(params*)
  {
    this.SimClickPics(0, params*)
  }
}
LC(s)
{
  ls := 
  StringLower,ls,s
  return ls
}
UC(s)
{
  us := 
  StringLower,us,s
  return us
}
LoadScript(s)
{
  if(!InStr(s,"#"))
  {
    return
  }
  A_Array := StrSplit(s, "#")
  Exists :=  FileExist(A_Array[1])
  if(Exists)
  { 
    R := 
    IniRead R, % A_Array[1], % A_Array[2]
    RA := {}
    loop,Parse,R,`n,`r
    {
      B_Array := StrSplit(A_LoopField, "=")
      Key := LC(Trim(B_Array[1]))
      Val := LC(Trim(B_Array[2]))
      if(Key == "textx")
      {
        Val := StrSplit(Val, ",")
        for i, v in Val 
        {
          Val[i] := Trim(v)
        }
      }
      RA[Key]:=Val
    }
    return RA
  }  
}
ReadIniKey(f, s, k)
{
  R:=
  IniRead, R, %f%, %s%, %k%
  return R
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值