Click Speed/delay/sleep Topic is solved
-
- Posts: 9
- Joined: 30 Jan 2019, 10:49
Click Speed/delay/sleep
....
Last edited by SilentThunder on 12 Jan 2022, 17:06, edited 3 times in total.
Re: Click Speed/delay/sleep Topic is solved
Put this function at the bottom of your script:
Then when you want to click with the default 350ms delay, in place of this, for example:
...you would put this:
If you wanted to delay a different amount, then you specify it like this:
Similarly for MouseMoves with a delay, add this function:
Then you would call it like this:
Code: Select all
ClickDelay(x, y, delay:=350) {
Sleep, delay
Click, %x%, %y%
}
Code: Select all
Click,%FX%,%FY%
Code: Select all
ClickDelay(FX, FY)
Code: Select all
ClickDelay(FX, FY, 200)
Similarly for MouseMoves with a delay, add this function:
Code: Select all
MouseMoveDelay(x, y, delay:=350) {
Sleep, delay
MouseMove, x, y
}
Code: Select all
MouseMoveDelay(FX, FY)
-
- Posts: 9
- Joined: 30 Jan 2019, 10:49
Re: Click Speed/delay/sleep
....
Last edited by SilentThunder on 12 Jan 2022, 17:07, edited 1 time in total.
Re: Click Speed/delay/sleep
Can you show your script with the functions implemented and how you're calling them?
-
- Posts: 9
- Joined: 30 Jan 2019, 10:49
Re: Click Speed/delay/sleep
....
Last edited by SilentThunder on 12 Jan 2022, 17:07, edited 1 time in total.
Re: Click Speed/delay/sleep
Typo:
Code: Select all
ClickDelay,(FX, FY) ;<---- Remove the ","
Code: Select all
#SingleInstance,Force
SetBatchLines,-1
CoordMode, Mouse,Screen
CoordMode,Pixel, Screen
Gui,1:+AlwaysOnTop
Gui,1:Color,0E0A1B
Gui,1:Font,cWhite
Loop, 5 {
Gui,1:Add,CheckBox,xm vEnable%A_Index% gSubmit_All, Enable
Gui,1:Add,Progress,x+10 w20 h20 BackGroundF00626 vColor%A_Index%
Gui,1:Add,Button,x+10 vButt%A_Index% gSetColor, Set Color
}
Gui,1:Add,Button,xm gSetArea, Set Search Area
Gui,1:Add,Button,x+10 gViewArea, View Search Area
Gui,1:Add,Radio,xm y+10 Group Checked vClickOrMove gSubmit_All, Move
Gui,1:Add,Radio,x+10 gSubmit_All, Click
Gui,1:Add,Button,xm y+10 gStartSearch, Start
Gui,1:Add,Button,x+10 gStopSearch, Stop
Gui,1:Show,x1100 y100,Pixel Search Script
return
GuiClose:
GuiContextMenu:
*Esc::
ExitApp
Submit_All:
Stop := 1
Gui,1:Submit,NoHide
return
SetColor:
Stop := 1
ActiveControl := SubStr(A_GuiControl,5)
while(!GetKeyState("ctrl")){
ToolTip, hover over color then press "ctrl" to lock it.
MouseGetPos, tx, ty
PixelGetColor,OutColor,tx,ty,RGB
GuiControl,1: +Background%OutColor%, % "Color" ActiveControl
}
ToolTip,
Color%ActiveControl% := OutColor
return
SetArea:
SoundBeep,500
Active := 1
gosub, BuildDisplayGui
return
DrawSearchArea:
MouseGetPos,X2,Y2
(x2<x1)?(gx:=x2,gw:=x1-x2):(gx:=x1,gw:=x2-x1)
(y2<y1)?(gy:=y2,gh:=y1-y2):(gy:=y1,gh:=y2-y1)
gosub, ShowGui
return
#If (Active)
LButton::
MouseGetPos,X1,Y1
SetTimer,DrawSearchArea,30
return
LButton Up::
SetTimer,DrawSearchArea,Off
Active := 0
SoundBeep, 500
Sleep, 1000
Gui,2:Destroy
return
RButton::
SetTimer,DrawSearchArea,Off
Active := 0
Gui,2:Destroy
return
#If
ViewArea:
Stop := 1
if(!gw){
MsgBox, must set search area b4 u can view it! `nDumbAss!!!
return
}
gosub, BuildDisplayGui
gosub, ShowGui
Sleep, 1000
Gui,2:Destroy
return
BuildDisplayGui:
Gui,2:Destroy
Gui,2:+Owner1 -Caption -DPIScale +LastFound
Gui,2:Color,Lime
WinSet,TransParent, 120
return
ShowGui:
Gui,2:Show,% "x" gx " y" gy " w" gw " h" gh
return
StartSearch:
^!p::
Stop := 0
while(!Stop){
Loop, 5 {
if(Enable%A_Index% = 1){
if(!Color%A_Index%){
MsgBox, hey DumbAss u need to set a color
return
}
PixelSearch,Fx,Fy,X1,Y1,X2,Y2,Color%A_Index%,5,Fast RGB
if(!ErrorLevel){
if(ClickOrMove=1){
MouseMove,fx,fy
}else if(ClickOrMove=2){
ClickDelay(FX, FY)
}
}
}
}
}
return
StopSearch:
^!o::
Stop := 1
return
ClickDelay(x, y, delay:=350){
Sleep, delay
Click, %x%, %y%
}
Last edited by Hellbent on 15 Apr 2021, 20:42, edited 1 time in total.
Re: Click Speed/delay/sleep
No, this is not how you call a function:
It's like this (no comma):
Edit: What Hellbent said.
Code: Select all
ClickDelay,(FX, FY)
Code: Select all
ClickDelay(FX, FY)
-
- Posts: 9
- Joined: 30 Jan 2019, 10:49
Re: Click Speed/delay/sleep
....
Last edited by SilentThunder on 12 Jan 2022, 17:07, edited 1 time in total.
Re: Click Speed/delay/sleep
NP.SilentThunder wrote: ↑15 Apr 2021, 20:47@Hellbent @boiler
Ty guyz so much.. Running just as i need it now
Here are a couple of other things that you can add.
At the top of the script add these two lines to adjust the click timing
Code: Select all
SetMouseDelay , -1 ;( -1 = fastest , 10 = good speed Most apps will register the clicks, 30+ = for apps that require a click to be held longer for them to register )
SetDefaultMouseSpeed, 0 ;The speed to move the mouse in the range 0 (fastest) to 100 (slowest).
Code: Select all
Loop 5 {
if(Stop)
return
}
-
- Posts: 61
- Joined: 04 Jan 2022, 05:02
Re: Click Speed/delay/sleep
Hello.. How can i add keybind section near the set color section that can send binded keystrokes when pixel found for the box? @boilerHellbent wrote: ↑15 Apr 2021, 21:02NP.SilentThunder wrote: ↑15 Apr 2021, 20:47@Hellbent @boiler
Ty guyz so much.. Running just as i need it now
Here are a couple of other things that you can add.
At the top of the script add these two lines to adjust the click timing
In the search routine, inside the second loop ( the 5 loop )Code: Select all
SetMouseDelay , -1 ;( -1 = fastest , 10 = good speed Most apps will register the clicks, 30+ = for apps that require a click to be held longer for them to register ) SetDefaultMouseSpeed, 0 ;The speed to move the mouse in the range 0 (fastest) to 100 (slowest).
that will allow you to stop the search while it is in the inner loop rather than having to wait for the 5 loops to finish.Code: Select all
Loop 5 { if(Stop) return }
Code: Select all
#SingleInstance,Force
SetBatchLines,-1
CoordMode, Mouse,Screen
CoordMode,Pixel, Screen
Gui,1:+AlwaysOnTop
Gui,1:Color,0E0A1B
Gui,1:Font,cWhite
Loop, 5 {
Gui,1:Add,CheckBox,xm vEnable%A_Index% gSubmit_All, Enable
Gui,1:Add,Progress,x+10 w20 h20 BackGroundF00626 vColor%A_Index%
Gui,1:Add,Button,x+10 vButt%A_Index% gSetColor, Set Color
}
Gui,1:Add,Button,xm gSetArea, Set Search Area
Gui,1:Add,Button,x+10 gViewArea, View Search Area
Gui,1:Add,Radio,xm y+10 Group Checked vClickOrMove gSubmit_All, Move
Gui,1:Add,Radio,x+10 gSubmit_All, Click
Gui,1:Add,Button,xm y+10 gStartSearch, Start
Gui,1:Add,Button,x+10 gStopSearch, Stop
Gui,1:Show,x1100 y100,Pixel Search Script
return
GuiClose:
GuiContextMenu:
*Esc::
ExitApp
Submit_All:
Stop := 1
Gui,1:Submit,NoHide
return
SetColor:
Stop := 1
ActiveControl := SubStr(A_GuiControl,5)
while(!GetKeyState("ctrl")){
ToolTip, hover over color then press "ctrl" to lock it.
MouseGetPos, tx, ty
PixelGetColor,OutColor,tx,ty,RGB
GuiControl,1: +Background%OutColor%, % "Color" ActiveControl
}
ToolTip,
Color%ActiveControl% := OutColor
return
SetArea:
SoundBeep,500
Active := 1
gosub, BuildDisplayGui
return
DrawSearchArea:
MouseGetPos,X2,Y2
(x2<x1)?(gx:=x2,gw:=x1-x2):(gx:=x1,gw:=x2-x1)
(y2<y1)?(gy:=y2,gh:=y1-y2):(gy:=y1,gh:=y2-y1)
gosub, ShowGui
return
#If (Active)
LButton::
MouseGetPos,X1,Y1
SetTimer,DrawSearchArea,30
return
LButton Up::
SetTimer,DrawSearchArea,Off
Active := 0
SoundBeep, 500
Sleep, 1000
Gui,2:Destroy
return
RButton::
SetTimer,DrawSearchArea,Off
Active := 0
Gui,2:Destroy
return
#If
ViewArea:
Stop := 1
if(!gw){
MsgBox, must set search area b4 u can view it! `nDumbAss!!!
return
}
gosub, BuildDisplayGui
gosub, ShowGui
Sleep, 1000
Gui,2:Destroy
return
BuildDisplayGui:
Gui,2:Destroy
Gui,2:+Owner1 -Caption -DPIScale +LastFound
Gui,2:Color,Lime
WinSet,TransParent, 120
return
ShowGui:
Gui,2:Show,% "x" gx " y" gy " w" gw " h" gh
return
StartSearch:
^!p::
Stop := 0
while(!Stop){
Loop, 5 {
if(Enable%A_Index% = 1){
if(!Color%A_Index%){
MsgBox, hey DumbAss u need to set a color
return
}
PixelSearch,Fx,Fy,X1,Y1,X2,Y2,Color%A_Index%,5,Fast RGB
if(!ErrorLevel){
if(ClickOrMove=1){
MouseMove,fx,fy
}else if(ClickOrMove=2){
ClickDelay(FX, FY)
}
}
}
}
}
return
StopSearch:
^!o::
Stop := 1
return
ClickDelay(x, y, delay:=350){
Sleep, delay
Click, %x%, %y%
}
Last edited by nexinferis on 03 Feb 2022, 08:36, edited 2 times in total.
Re: Click Speed/delay/sleep
What does sending binded keystrokes mean? Do you just want to send certain keystrokes when certain pixels are found? You would just use the Send command in place of where the script is currently moving the mouse and/or clicking. If you want certain keystrokes to be sent depending on which colors are found, you could have an associative array with the various colors as the array's keys, and the associated keystrokes as the values.nexinferis wrote: ↑ Hello.. How can i add keybind section near the set color section that can send binded keystrokes when pixel found for the box? @boiler
-
- Posts: 61
- Joined: 04 Jan 2022, 05:02
Re: Click Speed/delay/sleep
Yes.. I have an addon in game that can change the color of certain area when i use the spell. Its for rotation.. I can explain it like that; for example there is 2 color binded to 2 spell. 1st color is blue. 2nd color is red. These are different skills in game.. I want to use ahk exactly at this point.. Ahk will watch that color changing area and i will set 1st and 2nd skills color and lock it to ahk.. At this point i want keybind section near the locked color boxes like combobox that can set a key for locked colors and when ahk found that color will send that key to the game..boiler wrote: ↑03 Feb 2022, 09:09What does sending binded keystrokes mean? Do you just want to send certain keystrokes when certain pixels are found? You would just use the Send command in place of where the script is currently moving the mouse and/or clicking.nexinferis wrote: ↑ Hello.. How can i add keybind section near the set color section that can send binded keystrokes when pixel found for the box? @boiler
If i dont understand you sorry.. Im new at ahk..
Re: Click Speed/delay/sleep
This is how what I described would work. The array associates the letter x with pure blue and y with pure red. You can add as many colors and associated keypresses to be sent as you'd like.
Here's a demonstration that will show the result in a MsgBox for the case where the red color was found:
Code: Select all
Spells := {0x0000FF: "x", 0xFF0000: "y"}
PixelGetColor, SpellColor, 300, 250, RGB
if Spells.HasKey(SpellColor)
Send, % Spells[SpellColor]
Here's a demonstration that will show the result in a MsgBox for the case where the red color was found:
Code: Select all
Spells := {0x0000FF: "x", 0xFF0000: "y"}
SpellColor := 0xFF0000 ; PixelGetColor, SpellColor, 300, 250, RGB
if Spells.HasKey(SpellColor)
MsgBox, % Spells[SpellColor]
-
- Posts: 61
- Joined: 04 Jan 2022, 05:02
Re: Click Speed/delay/sleep
Thanks boiler i will try it and let you knowboiler wrote: ↑03 Feb 2022, 11:38This is how what I described would work. The array associates the letter x with pure blue and y with pure red. You can add as many colors and associated keypresses to be sent as you'd like.Code: Select all
Spells := {0x0000FF: "x", 0xFF0000: "y"} PixelGetColor, SpellColor, 300, 250, RGB if Spells.HasKey(SpellColor) Send, % Spells[SpellColor]
Here's a demonstration that will show the result in a MsgBox for the case where the red color was found:Code: Select all
Spells := {0x0000FF: "x", 0xFF0000: "y"} SpellColor := 0xFF0000 ; PixelGetColor, SpellColor, 300, 250, RGB if Spells.HasKey(SpellColor) MsgBox, % Spells[SpellColor]
Re: Click Speed/delay/sleep
I was playing around with a design for a general purpose script that can be set to watch n pixels for true or false values.
I don't have the time to finish it today but I'll post what I have so far.
This is my mock up for the individual search panels.
. .
@boiler you are more versed in pixel / image search.
Do you see anything that I am missing from the list of features seen in the panel image?
Also things that I may want to add here?
. .
I don't have the time to finish it today but I'll post what I have so far.
This is my mock up for the individual search panels.
. .
@boiler you are more versed in pixel / image search.
Do you see anything that I am missing from the list of features seen in the panel image?
Also things that I may want to add here?
. .
Re: Click Speed/delay/sleep
@Hellbent - That is a very impressive interface! (as always) It should be a really useful tool for many people. One thing that you might want to consider adding is the ability to allow for a variation in color shades to be considered a match even though PixelGetColor doesn't directly allow for that since its purpose is just to get the exact color of a certain pixel. You could either use PixelSearch with that variation option and use it to check individual pixels, or you could still use PixelGetColor and then break the color into its R, G, and B components and the same for the reference color, and you can check whether they all fall within the allowable variation of each other.
Another thought: In case you wanted to expand its functionality or have a separate tool is to have it work for other use cases that are more based on PixelSearch to check an area of the screen/window for a color to appear (or for it to no longer appear). Sometimes it is not known exactly where the color might appear but when it does, it will be within a certain area. But you're already doing plenty with the tool as it is. Just throwing out an idea.
I suppose one other checkbox or radio buttons that could be useful is to allow for the selection of CoordMode based on Window, Client, or Screen.
Another thought: In case you wanted to expand its functionality or have a separate tool is to have it work for other use cases that are more based on PixelSearch to check an area of the screen/window for a color to appear (or for it to no longer appear). Sometimes it is not known exactly where the color might appear but when it does, it will be within a certain area. But you're already doing plenty with the tool as it is. Just throwing out an idea.
I suppose one other checkbox or radio buttons that could be useful is to allow for the selection of CoordMode based on Window, Client, or Screen.
Re: Click Speed/delay/sleep
Thanks.boiler wrote: ↑05 Feb 2022, 15:06@Hellbent - That is a very impressive interface! (as always) It should be a really useful tool for many people. One thing that you might want to consider adding is the ability to allow for a variation in color shades to be considered a match even though PixelGetColor doesn't directly allow for that since its purpose is just to get the exact color of a certain pixel. You could either use PixelSearch with that variation option and use it to check individual pixels, or you could still use PixelGetColor and then break the color into its R, G, and B components and the same for the reference color, and you can check whether they all fall within the allowable variation of each other.
Of course, forgot all about variation. I like the idea of splitting the RGB and then testing high / low.
That sounds like a good idea. I would need to consider the extra controls needed to have all the necessary functions covered.Another thought: In case you wanted to expand its functionality or have a separate tool is to have it work for other use cases that are more based on PixelSearch to check an area of the screen/window for a color to appear (or for it to no longer appear). Sometimes it is not known exactly where the color might appear but when it does, it will be within a certain area. But you're already doing plenty with the tool as it is. Just throwing out an idea.
For example having an Offset for the x and y.
I'm going to do another pass at the panel layout shortly, can you think of anything else that I should add?
Also, do you think that I should use a system like I have in my Pixel Predator where most of the settings are set in a single edit, or keep things separated like they are now?
Have you ever tried my Pixel Predator, and if so did you find the command structure hard to use?
Wouldn't this require setting a target window as well?I suppose one other checkbox or radio buttons that could be useful is to allow for the selection of CoordMode based on Window, Client, or Screen.
Re: Click Speed/delay/sleep
It's looking pretty complete at this point. I suppose there are always some special use cases that could be added such as moving the mouse pointer onto or away from a certain point because the desired color only appears on a hover or when not hovered on, but that could be over-complicating things.
I have seen the thread and your video, but I haven't had a need to use it myself yet, so I'm not that familiar with its detailed workings. I suppose any feedback you might have gotten from those that have been using it would be more helpful than what I could offer at this point.
I guess it depends on how you envision it would be used. I was thinking the user could activate their window of interest before hitting their "Start" hotkey, but it might be a nice option to allow the user to positively identify a window to be active if you wanted to add that. The reason I think it can be useful is that they might define their coordinates based on where the window is currently positioned, and if they drag the window somewhere else, those coordinates (for both searching and clicking) would still be valid if they choose window coordinates and drag the window somewhere else. But maybe the typical user is just using this for full-screen games so this option wouldn't be as useful as I think it may be.
Re: Click Speed/delay/sleep
That's a good point, I normally just take a screen shot when that comes up but I have easy access to those tools so it may not be so simple for everyone. Perhaps what I can do is include a screen clipper with a bit of zoom to make getting a color easier in all cases. I can add a button that once pressed would wait for the user to drag over a area to capture a screenshot and then it can stay on screen until they get the color.boiler wrote: ↑05 Feb 2022, 17:10It's looking pretty complete at this point. I suppose there are always some special use cases that could be added such as moving the mouse pointer onto or away from a certain point because the desired color only appears on a hover or when not hovered on, but that could be over-complicating things.
I think that I have only had one person ask how the send text param worked, and 2-3 people ask how to send a specific set of keys {F1}{Enter} etc.boiler wrote: ↑05 Feb 2022, 17:10I have seen the thread and your video, but I haven't had a need to use it myself yet, so I'm not that familiar with its detailed workings. I suppose any feedback you might have gotten from those that have been using it would be more helpful than what I could offer at this point.
So I guess it is pretty clear how to use it.
I don't have much use for pixel/image search so I don't use the script for that, but I have found that it is really good for creating macros on the fly since I can give it a condition that is always true and it just runs the macro instantly with the press of the hotkey.
I did a mockup of a new layout using the command structure.
. .
Unfortunately, I don't think I can shrink the height down small enough to be able to display a min of 3 panels on screen at once.
I can definitely reduce the height a bit, but I don't think it will be enough.
So it looks like for this to have the ability to have unlimited panels and have at least a few shown at once I will need to go back to the other design and just modify it a bit for color variation and add a Index number to the panel.
That works for me lol.