Advertisement
Guest User

ftlwin2.ahk

a guest
Aug 14th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if not A_IsAdmin
  2. {
  3.   Run *RunAs "%A_ScriptFullPath%"
  4.   ExitApp
  5. }
  6. ; ========================
  7. #SingleInstance, force
  8. #InstallKeybdHook
  9. #InstallMouseHook
  10. DetectHiddenWindows, On
  11. ;CoordMode, Mouse, Relative ; needed for mouseclickdrag
  12. CoordMode, Tooltip, Screen
  13. SetTitleMatchMode, 2
  14. SetKeyDelay, 200,200
  15. SetWinDelay, 300
  16. SetControlDelay, 300
  17. SetBatchLines, 300ms
  18. Version := "v4.1"
  19. RunHotkey := 0 ; Hotkeys disabled until run button pressed.
  20. ; ========================================================================================
  21. Gui, Main:Add, Tab2, x5  y5 w510 h520, Info | Config
  22. ; Info Tab
  23. Gui, Main:Add, Text, x170 y35  w180 h20, Send And Click Test Tool %Version%
  24. Gui, Main:Add, Text, x25  y67  w400 h20, Make sure that Click and Send Tool is running as Administrator or it will NOT work!
  25. Gui, Main:Add, Text, x25  y97  w470 h20, Also make sure that the game or program is running in Window mode to get the best results.
  26. Gui, Main:Add, Text, x25  y127 w470 h20, Around 2000 and 4000 is recommended for Time delay between the commands.
  27. Gui, Main:Add, Text, x25  y157 w470 h20, Note that F1 or F3 can NOT be used as test keys.
  28. Gui, Main:Add, Text, x15  y447 w180 h20, Autohtokey Forum Links:
  29. Gui, Main:Add, Link, x15  y467      h20, <a href="http://www.autohotkey.com/board/topic/95653--/">Send and Click Tool %Version%</a>
  30. Gui, Main:Add, Link, x15  y487      h20, <a href="http://www.autohotkey.com/board/user/21149--/">SnowFlake Profile Page</a>
  31. Gui, Main:Add, Text, x380 y427 h20, AHK Version %A_AhkVersion%
  32. Gui, Main:Add, Text, x380 y447 h20, System: %A_OSVersion%
  33. Gui, Main:Add, Text, x380 y467 h20, Version: %Version%
  34. Gui, Main:Add, Text, x380 y487 h20, Date: %A_DD%/%A_MM%/%A_YYYY%
  35. ; ========================================================================================
  36. Gui, Main:Tab,2
  37. ; Config Tab
  38. Gui, Main:Add, Button, x15  y37  w100 h30 gStart            , Select a Window
  39. Gui, Main:Add,   Text, x20  y77  w90  h20                   , Selected Window :
  40. Gui, Main:Add,   Edit, x115 yp-2 w250 h20 vwinid
  41. Gui, Main:Add,   Text, x50  y117 w60  h20                   , Time Delay :
  42. Gui, Main:Add,   Edit, x115 yp-2 w70  h20 vWaitTime Number  , 2000
  43. Gui, Main:Add,   Text, x30  y157 w80  h20                   , Enter Test Key :
  44. Gui, Main:Add, Hotkey, x115 yp-2 w20  h20 vkex              , Q
  45. Gui, Main:Add, Button, x15  y187 w100 h30 gCord             , Select Mouse Coordinates
  46. Gui, Main:Add,   Text, x60  y227 w50  h20                   , Mouse X :
  47. Gui, Main:Add,   Edit, x115 yp-2 w50  h20 Vxx Number
  48. Gui, Main:Add,   Text, x60  y257 w50  h20                   , Mouse Y :
  49. Gui, Main:Add,   Edit, x115 yp-2 w50  h20 Vyy Number
  50. Gui, Main:Add,  Radio, x15  y300 w110 h30 Checked vRadio_all, Test all send/click commands
  51. Gui, Main:Add,  Radio, x136 y300 w110 h30 gRadio_advanced   , Select Commands (Advanced Mode)
  52. Gui, Main:Add, Button, x15  y350 w100 h30 gsave             , Run
  53. ; ========================================================================================
  54. Gui, AdvanceClick:Add, Text,     x165  y10  w170 h20     , Click Advanced Mode Settings
  55. Gui, AdvanceClick:Add, GroupBox, x5   y35  w470 h515     , Click Commands
  56. Gui, AdvanceClick:Add, CheckBox, x15  y67  w100 h30      , Test click
  57. Gui, AdvanceClick:Add, CheckBox, x15  y107 w100 h30 vMC1 , Test MouseClick
  58. Gui, AdvanceClick:Add, CheckBox, x15  y147 w150 h30 vMC2 , Test MouseClickDrag Fast
  59. Gui, AdvanceClick:Add, CheckBox, x15  y187 w170 h30 vMC3 , Test MouseClickDrag Slow
  60. Gui, AdvanceClick:Add, CheckBox, x15  y227 w130 h30 vMC4 , Test ControlClick
  61. Gui, AdvanceClick:Add, CheckBox, x15  y267 w130 h30 vMC5 , Test Send Click
  62. Gui, AdvanceClick:Add, CheckBox, x15  y307 w130 h30 vMC6 , Test SendRaw Click
  63. Gui, AdvanceClick:Add, CheckBox, x15  y347 w130 h30 vMC7 , Test SendPlay Click
  64. Gui, AdvanceClick:Add, CheckBox, x15  y387 w130 h30 vMC8 , Test SendEvent Click
  65. Gui, AdvanceClick:Add, CheckBox, x15  y427 w130 h30 vMC9 , Test SendInput Click
  66. Gui, AdvanceClick:Add, CheckBox, x15  y467 w130 h30 vMC10, Test ControlSend Click
  67. Gui, AdvanceClick:Add, CheckBox, x15  y507 w160 h30 vMC12, Test ControlSendRaw Click
  68. Gui, AdvanceClick:Add, CheckBox, x235 y67  w160 h30 vMC13, Test ControlClick v2
  69. Gui, AdvanceClick:Add, CheckBox, x235 y107 w160 h30 vMC14, Test PostMessage Click
  70. Gui, AdvanceClick:Add, CheckBox, x235 y147 w160 h30 vMC15, Test SendMessage Click
  71. Gui, AdvanceClick:Add, CheckBox, x235 y187 w160 h30 vMC16, Test DllCall Mouse_event
  72. ; ========================================================================================
  73. Gui, AdvanceSend:Add, Text,     x95 y10  w170 h20     , Send Advanced Mode Settings
  74. Gui, AdvanceSend:Add, GroupBox, x5  y35  w330 h400    , Send Commands
  75. Gui, AdvanceSend:Add, Checkbox, x15 y65  w100 h30 vKS1, Test Send
  76. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w100 h30 vKS2, Test SendRaw
  77. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w150 h30 vKS3, Test SendInput
  78. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w170 h30 vKS4, Test SendPlay
  79. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w130 h30 vKS5, Test SendEvent
  80. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w130 h30 vKS6, Test ControlSend
  81. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w130 h30 vKS7, Test ControlSendRaw
  82. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w260 h30 vKS8, Test Dllcall keybd_event
  83. Gui, AdvanceSend:Add, Checkbox, x15 y+10 w160 h30 vKS9, Test Send Wscript(COM)
  84. ; ========================================================================================
  85. Gui, Main:Show, w520 h530 Center, Send And Click Tool %Version%
  86. return
  87.  
  88. Radio_advanced:
  89.  MsgBox, 4160, Select a the Commands, Select the Commands you want Send and Click Tool %Version% to test.
  90.   IfMsgBox OK
  91.   {
  92.    Gui, AdvanceClick:Show, w480 h555, Click Advanced Mode
  93.    Gui, AdvanceSend:Show, w340 h440, Send Advanced Mode
  94.   }
  95.   RunHotkey := 0    ; Reset to prevent hotkey use until Run Button pressed.
  96. return
  97.  
  98. Start:
  99.  gui,hide
  100.   MsgBox, 4160, Select a Window, To start Press OK then`nPlace your cursor over the window you want to select. then press Space key to get the Title.
  101.   IfMsgBox No
  102.    goto, Start  
  103.   keywait, Space, D
  104.   keywait, Space
  105.   WinGetActiveTitle, winidX
  106.   MsgBox, 4132, A Window have been selected, You have selected the following Window: `n`n %winidX% `n`nAre you satisfied with it?
  107.   IfMsgBox No
  108.    goto, Start  
  109.   GuiControl,, winid, %winidX%
  110.   Gui, Submit  
  111.   Gui,Show, w520 h530 Center, Send and Click Tool %Version%
  112.   RunHotkey := 0    ; Reset to prevent hotkey use until Run Button pressed.
  113. return
  114.  
  115. Cord:
  116.  gui,hide
  117.   MsgBox, 4160, Select Coordination, Press OK then`nPress Space key to select the mouse X and Y coordination you want the test the Clicks on.
  118.   keywait, Space, D
  119.   keywait, Space
  120.   mousegetpos, XXX, YYY
  121.   MsgBox, 4132,Coordination have been set, You have set the following X and Y Coordinations`n`nX = %XXX%`n`nY = %YYY%`n`nAre you satisfied with it?
  122.   IfMsgBox No
  123.    goto, Cord
  124.   GuiControl,, xx, %XXX%
  125.   GuiControl,, yy, %YYY%
  126.   Gui, Submit  
  127.   Gui, Show, w520 h530 Center, Send and Click Tool %Version%
  128.   RunHotkey := 0    ; Reset to prevent hotkey use until Run Button pressed.
  129. return
  130.  
  131. save:   ; Run Button, Do all Checks here since we have hotkeys disabled until Run is clicked.
  132.   Gui, Submit
  133.   Gui, AdvanceSend:Submit
  134.   Gui, AdvanceClick:Submit
  135.   if (winid = "")            ; Check Window
  136.   {
  137.    MsgBox, 16, A Window is not selected!, Please select a window to use Send and Click Tool.
  138.    Gui, Main:Show, w520 h530 Center, Send and Click Tool %Version%
  139.    return
  140.   }
  141.   if (xx = "")               ; Check Coords
  142.   {
  143.    MsgBox, 16, Coords not selected!, Please select Mouse Coords to use Click Test.
  144.    Gui, Main:Show, w520 h530 Center, Send and Click Tool %Version%
  145.    return
  146.   }
  147.   if (radio_all)             ; Check Radio Button
  148.   {
  149.    MC1 := MC2 := MC3 := MC4 := MC5 := MC6 := MC7 := MC8 := MC9 := MC10 := MC11 := MC12 := MC13 := MC14 := MC15 := MC16 := MC17 := 1
  150.    KS1 := KS2 := KS3 := KS4 := KS5 := KS6 := KS7 := KS8 := KS9 := 1
  151.   }
  152.   if !(WaitTime >= 10)       ; Check Delay
  153.   {
  154.    GuiControl,, WaitTime, 10
  155.    Gui, Submit
  156.   }
  157.   if (Kex = "")  ; Check kex value because using backspace will set hotkey to nothing!
  158.   {
  159.    GuiControl,, Kex, Q    ;set to default
  160.    Gui, Submit
  161.   }
  162.   MsgBox, 4148, Final Information, Window Selected = %winid%`n`n Key to send = %kex% `n`nWait time between send commands = %WaitTime%`n`nMouse X coordinate = %XXX%`n`nMouse Y coordinate = %YYY%
  163.   IfMsgBox No
  164.   {
  165.    Gui,Show, w520 h530 Center, Send and Click Tool %Version%
  166.    return
  167.   }
  168.   MsgBox, 4160, Select option, Select if you want to send the key or click the coordinates`n`nF1 = Tests the mouse click commands`n`nF3 = Tests the Send commands`n`nEscape will exit/quit Send and Click Tool %Version%
  169.   RunHotkey := 1
  170. return
  171.  
  172. $F1::             ; Press F1 to run Click test.
  173.   KeyWait, F1
  174.   if !RunHotkey
  175.    return
  176.   RunHotkey := 0
  177.   SoundBeep
  178. ClickTest: ; ========================================================================================
  179.   sleep, 100
  180.   ToolTip, Running Click Test,0,0
  181.   WinActivate, %winid%
  182. WinSet, AlwaysOnTop, ON, %winid%
  183.  
  184.   IF (MC2)
  185.   {
  186. winCount =: 0
  187. Loop, 100000
  188. {
  189.  
  190.  
  191.  
  192. Send, {1}
  193. Sleep, 10
  194. MouseClick, Left, 550, 670 ; w3
  195. MouseClick, Left, 1025,350 ; weapon room
  196.  
  197. MouseClick, Left, 450, 670 ; w2
  198. MouseClick, Left, 1025,350 ; weapon room
  199.  
  200. MouseClick, Left, 350, 670 ; w1 halberd beam
  201. MouseClick, Left, 1055,325 ; point 1 weapons room
  202. MouseClick, Left, 1125,310 ; point 2 O2 room 1
  203.  
  204. targetcolor := 0xe5f5eb
  205. shieldtargetcolor := 0x64ff64
  206. time := 0
  207. PixelGetColor, color, 348,183 ;checking if the battle is over
  208. while color != targetcolor
  209. {
  210.     PixelGetColor, color, 348,183
  211.     sleep 50
  212.     PixelGetColor, shieldcolor, 60,136
  213.     time++
  214.     if (time > 6 ) ;use cloak
  215.     {
  216.     Send, c ;stealth
  217.     }
  218.     if (shieldcolor != shieldtargetcolor) ;zoltan shield down
  219.         {
  220.         Send, {Space}
  221.         sleep 914748364
  222.         }
  223. }
  224.  
  225. Send, {1}
  226. sleep 10
  227. MouseClick, Left, 570,75 ; jump
  228. Send, j
  229. sleep 10
  230. MouseClick, Left, 587,420 ; location 1
  231. MouseClick, Left, 630,504 ; location 2
  232. ;PixelGetColor, color, 270,320
  233. ;while color != targetcolor
  234. ;{
  235. ;   PixelGetColor, color, 270,320
  236. ;   sleep 50
  237. ;   WinCount++
  238. ;}
  239. sleep 1000
  240.  
  241.  
  242. winCount++
  243. ToolTip, %winCount%,0,0
  244. }
  245.   }
  246.  
  247.   ToolTip, Click Test Done,0,0
  248.   ToolTip
  249.   WinSet, AlwaysOnTop, OFF, %winid%
  250.   MsgBox, 4160, Select option, Select if you want to send the key or click the coordinates`n`nF1 = Tests the mouse clicks`n`nF3 = Tests the Send commands`n`nCtrl + Escape will show the Send And Click Tool %Version% Gui`n`n
  251.   RunHotkey := 1
  252. return
  253. ; ========================================================================================
  254. $F3::              ; Press F3 to run Send test.
  255.   KeyWait, F3
  256.   if !RunHotkey
  257.    return
  258.   RunHotkey := 0
  259.   SoundBeep
  260. SendTest:
  261.  sleep, WaitTime
  262.   ToolTip, Running Send Test,0,0
  263.   WinActivate, %winid%
  264.   WinSet, AlwaysOnTop, ON, %winid%
  265.   IF (KS1)
  266.   {
  267.    ToolTip, Testing %Kex% With Send,0,0
  268.    sleep, WaitTime
  269.    Send, %Kex%
  270.   }
  271.   IF (KS2)
  272.   {
  273.    ToolTip, Testing %Kex% With SendRaw,0,0
  274.    sleep, WaitTime
  275.    SendRaw, %Kex%
  276.   }
  277.   IF (KS3)
  278.   {
  279.    ToolTip, Testing %Kex% With SendInput,0,0
  280.    sleep, WaitTime
  281.    SendInput, %Kex%
  282.   }
  283.   IF (KS4)
  284.   {
  285.    ToolTip, Testing %Kex% With SendPlay,0,0
  286.    sleep, WaitTime
  287.    SendPlay, %Kex%
  288.   }
  289.   IF (KS5)
  290.   {
  291.    ToolTip, Testing %Kex% With SendEvent,0,0
  292.    sleep, WaitTime
  293.    SendEvent, %Kex%
  294.   }
  295.   IF (KS6)
  296.   {
  297.    ToolTip, Testing %Kex% With ControlSend,0,0
  298.    sleep, WaitTime
  299.    ControlSend,,%Kex%, %winid%
  300.   }
  301.   IF (KS7)
  302.   {
  303.    ToolTip, Testing %Kex% With ControlSendRaw,0,0
  304.    sleep, WaitTime
  305.    ControlSendRaw,,%Kex%, %winid%
  306.   }
  307.   IF (KS8)
  308.   {
  309.    ToolTip, Testing %Kex% With Dllcall keybd_event,0,0
  310.    VK := Format("0x{:02X}", GetKeyVK(Kex))
  311.    SC := Format("0x{:03X}", GetKeySC(Kex))
  312.    sleep, WaitTime
  313.    dllcall("keybd_event", UChar, VK, UChar, SC, Uint, 0, UPtr, 0) ; Down
  314.    sleep, 500
  315.    dllcall("keybd_event", UChar, VK, UChar, SC, Uint, 2, UPtr, 0) ; UP
  316.   }
  317.   IF (KS9)
  318.   {
  319.    ToolTip, Testing %Kex% With Wscript will send 1,0,0
  320.    sleep, WaitTime
  321.    ComObjCreate("wscript.shell").SendKeys(Chr(49))
  322.   }
  323.  
  324.   ToolTip, Send Test Done
  325.   sleep, WaitTime
  326.   SoundBeep
  327.   ToolTip
  328.   WinSet, AlwaysOnTop, OFF, %winid%
  329.   MsgBox, 4160, Select option, Select if you want to send the key or click the coordinates`n`nF1 = Tests the mouse clicks`n`nF3 = Tests the Send commands`n`nCtrl + Escape will show the Send And Click Tool %Version% Gui`n`n
  330.   RunHotkey := 1
  331. return
  332.  
  333. AFK_Click(X, Y, WinTitle="", WinText="", ExcludeTitle="", ExcludeText=""){
  334.   SetControlDelay -1
  335.   hwnd:=ControlFromPoint(X, Y, WinTitle, WinText, cX, cY, ExcludeTitle, ExcludeText)
  336.   PostMessage, 0x201, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDOWN
  337.   PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
  338.   PostMessage, 0x203, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDBLCLCK
  339.   PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
  340. }
  341.  
  342. ControlFromPoint(X, Y, WinTitle="", WinText="", ByRef cX="", ByRef cY="", ExcludeTitle="", ExcludeText=""){
  343.   static EnumChildFindPointProc=0
  344.   if !EnumChildFindPointProc
  345.    EnumChildFindPointProc := RegisterCallback("EnumChildFindPoint","Fast")
  346.  
  347.   if !(target_window := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText))
  348.    return false
  349.  
  350.   VarSetCapacity(rect, 16)
  351.   DllCall("GetWindowRect","uint",target_window,"uint",&rect)
  352.   VarSetCapacity(pah, 36, 0)
  353.   NumPut(X + NumGet(rect,0,"int"), pah,0,"int")
  354.   NumPut(Y + NumGet(rect,4,"int"), pah,4,"int")
  355.   DllCall("EnumChildWindows","uint",target_window,"uint",EnumChildFindPointProc,"uint",&pah)
  356.   control_window := NumGet(pah,24) ? NumGet(pah,24) : target_window
  357.   DllCall("ScreenToClient","uint",control_window,"uint",&pah)
  358.   cX:=NumGet(pah,0,"int"), cY:=NumGet(pah,4,"int")
  359.   return control_window
  360. }
  361.  
  362. ^Esc::Gui, Main:Show, w520 h530 Center, Send and Click Tool %Version%
  363.  
  364. Esc::
  365. MainGuiClose:
  366.  if (winid !="")   ; Turn off AllwaysOnTop in case script is closed while test is running.
  367.    WinSet, AlwaysOnTop, OFF, %winid%
  368.   ExitApp
  369.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement