 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Sun Mar 02, 2008 3:00 pm Post subject: 1 hot key , Mouseclicks differetn ClassNN on 1st, 2nd, 3rd c |
|
|
I want One hotkey (NumPadClear) to Mouseclick in 1 spot on 1st hit, another spot on 2nd hit, and a 3rd spot on 3rd hit. And loop so that a 4th hit would go to 1st spot, etc. It would also be resest to back to 1st spot after i hit Enter key. Any ideas on how to do this?
I will use this for playing online poker, the three buttons on the game table are right next to each other and i want 1st hit to click "MinBet"(ClassNN: FTCSkinButton11), 2nd hit to click "PotBet"(ClassNN:FTCSkinButton12).
3rd hit to click "MaxBet"(ClassNN:FTCSkin13).
And I need it to be extra reliable.
thanks fro any help you can give me. |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 338
|
Posted: Sun Mar 02, 2008 11:51 pm Post subject: |
|
|
I'm not sure about really reliable because I don't play that game, but here is something to get you started.
| Code: | #Persistent
;put title here
winTitle = ???
counter=0
Return
#c:: ;just fer testing, my laptop does not have the numpadclear button
NumpadClear::
counter++
If(counter=1)
{ ControlClick, FTCSkinButton11, %winTitle%
ToolTip,MinBet
}
Else If(counter=2)
{ ControlClick, FTCSkinButton12, %winTitle%
ToolTip,PotBet
}
Else If(counter=3)
{ ControlClick, FTCSkinButton13, %winTitle%
counter=0
ToolTip,MaxBet
}
Sleep,1500
ToolTip
Return | If the controlclick doesn't work, maybe try using screen coords to click. _________________
 |
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Mon Mar 03, 2008 1:39 pm Post subject: |
|
|
Thank you very much Micahs, very helpful.... much more help than I expected to get.
I made a few modifications assuming they would help the reliability , but im not sure. Do you see anything that is a red flagt
| Code: |
;starting stuff, not sure if all 6 of these are needed but it works so.
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3
#WinActivateForce
#Persistent
;get unique window id of window to be controlled by arrow keys
F1::
WinGet, 1winTitle, ID, A
Return
1counter=0
Return
;cycles through minbet, pot bet or half pot bet, All in or maxbet
Up::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1
1counter++
If(1counter=1)
{ ControlClick, FTCSkinButton23, ahk_id %1winTitle%
}
Else If(1counter=2)
{ ControlClick, FTCSkinButton25, ahk_id %1winTitle%
}
Else If(1counter=3)
{ ControlClick, FTCSkinButton24, ahk_id %1winTitle%
1counter=0
}
Sleep,200
Return
;fold check or checkfold
Left::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1
ControlClick, FTCSkinButton11, ahk_id %1winTitle%
ControlClick, FTCSkinButton29, ahk_id %1winTitle%
Sleep,200
Return
;call or check in preflop preact
Down::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1
ControlClick, FTCSkinButton12, ahk_id %1winTitle%
ControlClick, FTCSkinButton31, ahk_id %1winTitle%
Sleep,200
Return
;bet
Right::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1
ControlClick, FTCSkinButton13, ahk_id %1winTitle%
Sleep,200
Return
;;get unique window id of window to be controlled by numpadkeys
F2::
WinGet, 21winTitle, ID, A
Return
21counter=0
Return
NumpadAdd::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
21counter++
If(21counter=1)
{ ControlClick, FTCSkinButton23, ahk_id %21winTitle%
}
Else If(21counter=2)
{ ControlClick, FTCSkinButton25, ahk_id %21winTitle%
}
Else If(21counter=3)
{ ControlClick, FTCSkinButton24, ahk_id %21winTitle%
21counter=0
}
Sleep,200
Return
NumpadEnd::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
ControlClick, FTCSkinButton11, ahk_id %21winTitle%
ControlClick, FTCSkinButton29, ahk_id %21winTitle%
Sleep,200
Return
NumpadDown::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
ControlClick, FTCSkinButton12, ahk_id %21winTitle%
ControlClick, FTCSkinButton31, ahk_id %21winTitle%
Sleep,200
Return
NumpadPgDn::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
ControlClick, FTCSkinButton13, ahk_id %21winTitle%
Sleep,200
Return |
|
|
| Back to top |
|
 |
Kellianjaxon
Joined: 05 Jan 2008 Posts: 39
|
Posted: Mon Mar 03, 2008 7:11 pm Post subject: |
|
|
| livinthelife wrote: | | Do you see anything that is a red flagt |
I could suggest just a few improvements. First of all, you want to add the following portions of code in the auto-execute section.
| Code: |
1counter=0
Return
; ...
21counter=0
Return
|
So the beginning of your script should look like this:
| Code: |
#NoEnv
;SendMode Input ; Not necessary because your script doesn't use variants of 'Send', nor 'Click' nor 'MouseMove/Click/Drag'
;SetWorkingDir %A_ScriptDir% ; Not necessary because your script doesn't refer to any file names
SetTitleMatchMode, 3
#WinActivateForce
;#Persistent ; Not necessary because hotkey definitions prevent the script from exiting
1counter=0 ; Add initialization here, otherwise these lines will not be executed
21counter=0 ; .
Return ; Auto-execution ends here. Having 'return' line is not absolutely necessary in this case
; because the first hotkey definition (F1::) would also end the auto-execute section.
|
Other thing you could do to make your script more compact, is to use "Last Found Window". I've also commented a few more things:
| Code: |
;starting stuff, not sure if all 6 of these are needed but it works so.
#NoEnv
SetTitleMatchMode, 3
#WinActivateForce
;get unique window id of window to be controlled by arrow keys
F1:: WinGet, 1winTitle, ID, A ; As long as you have only one line, you can put it right after the hotkey and leave 'return' away.
;cycles through minbet, pot bet or half pot bet, All in or maxbet
Up::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1 ; Last Found Window updated here
1counter++
If(1counter=1)
{ ControlClick, FTCSkinButton23 ; ahk_id not needed anymore, the current subroutine will refer to Last Found Window from now on
}
Else If(1counter=2)
{ ControlClick, FTCSkinButton25 ; .
}
Else If(1counter=3)
{ ControlClick, FTCSkinButton24 ; .
1counter=0
}
Sleep,200 ; Are these sleeps necessary? Do they improve reliability?
Return
;fold check or checkfold
Left::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1 ; Last Found Window updated
ControlClick, FTCSkinButton11
ControlClick, FTCSkinButton29
Sleep,200
Return
;call or check in preflop preact
Down::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1 ; Etc.
ControlClick, FTCSkinButton12
ControlClick, FTCSkinButton31
Sleep,200
Return
;bet
Right::
WinActivate, ahk_id %1winTitle%
WinWaitActive, ahk_id %1winTitle%, , 1
ControlClick, FTCSkinButton13
Sleep,200
Return
;;get unique window id of window to be controlled by numpadkeys
F2:: WinGet, 21winTitle, ID, A
NumpadAdd::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
21counter++
If(21counter=1)
{ ControlClick, FTCSkinButton23
}
Else If(21counter=2)
{ ControlClick, FTCSkinButton25
}
Else If(21counter=3)
{ ControlClick, FTCSkinButton24
21counter=0
}
Sleep,200
Return
NumpadEnd::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
ControlClick, FTCSkinButton11
ControlClick, FTCSkinButton29
Sleep,200
Return
NumpadDown::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
ControlClick, FTCSkinButton12
ControlClick, FTCSkinButton31
Sleep,200
Return
NumpadPgDn::
WinActivate, ahk_id %21winTitle%
WinWaitActive, ahk_id %21winTitle%, , 1
ControlClick, FTCSkinButton13
Sleep,200
Return |
|
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Wed Mar 05, 2008 5:06 am Post subject: |
|
|
thanks for the advice
i'm not sure about the sleep adding reliability, but it was in one of the first scripts i copied from someone else. so i just use it and haven't found a good reason to leave it out. makes sense to me to Forcefully give the computer an extra couple milliseconds to make sure it executes cleanly. as i understand it, sleep just forces the computer to wait when it is under load. this sleep is usually given when computer is under normal load.....but seriously im not that smart with computers.
i noticed you removed some of the auto execute lines, below is what i currently am using, what do you think?
| Code: | #NoEnv
SendMode Input ; do i need this
SetWorkingDir %A_ScriptDir% ; do i need this
SetTitleMatchMode, 3
#WinActivateForce
#Persistent ; do i need this, Micah had this in first reply
1counter=0
21counter=0
31counter=0
41counter=0
Return
|
|
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 338
|
Posted: Wed Mar 05, 2008 5:33 am Post subject: |
|
|
| livinthelife wrote: | | #Persistent ; do i need this, Micah had this in first reply |
| Autohotkey Help wrote: | #Persistent
If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes. This is useful in cases where a script contains timers and/or custom menu items but not hotkeys, hotstrings, or any use of OnMessage() or Gui. | No, not needed. I guess I didn't need it originally either. _________________
 |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 05 Jan 2008 Posts: 39
|
Posted: Wed Mar 05, 2008 2:59 pm Post subject: |
|
|
| livinthelife wrote: | | makes sense to me to Forcefully give the computer an extra couple milliseconds to make sure it executes cleanly. |
That would make sense if Sleep was used between two commands under circumstances where it's crucial that the first one gets to "go through" before the second one is executed. However, I can't see such happening in your script.
There's another thing that does benefit from sleep at the end of every hotkey subroutine, though. It prevents accidental double-presses within the time each hotkey routine takes to execute, as long as #MaxThreadsPerHotkey directive is set to the value 1, that being the default value.
| livinthelife wrote: | | i noticed you removed some of the auto execute lines, below is what i currently am using, what do you think? |
You can surely remove the lines I commented out earlier, and to be honest, any of the lines in the first block (until xcounter=0 init lines) are not necessary for your script to behave correctly. #NoEnv directive is good to have, the rest I'd personally drop off.
| Code: | ; This would do fine
#NoEnv
; SendMode Input ; do i need this
; SetWorkingDir %A_ScriptDir% ; do i need this
; SetTitleMatchMode, 3
; #WinActivateForce
; #Persistent ; do i need this, Micah had this in first reply |
I noticed I've earlier suggested improvements that can possibly prevent your script momentarily from working under heavy system load. The problem occurs if the application window receiving ControlClicks does not activate within one second, in which case WinWaitActive times out and Last Found Window is never updated. You may want to make the following modification to every hotkey subroutine:
| Code: | Up::
IfWinExist, ahk_id %1winTitle% ; Last Found Window updated here
{
WinActivate
WinWaitActive, , , 1
1counter++
If(1counter=1)
{ ControlClick, FTCSkinButton23
}
Else If(1counter=2)
{ ControlClick, FTCSkinButton25
}
Else If(1counter=3)
{ ControlClick, FTCSkinButton24
1counter=0
}
Sleep,200
}
Return |
|
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Sun Mar 23, 2008 9:40 am Post subject: |
|
|
thanks for all your advice guys.
sorry for asking again, but it is very important that this script be reliable. often times a bad click or script error could cost me a couple hundred dollars.
so, are you sure about not needing any of the top lines except #NoEnv?
for almost a month i've been using the script as shown below and haven't had 1 problem, it has worked perfectly. so i am hesistant about changing anything, but honestly i dont really understand what each one does. do you know of any possible problems i could have if i have then in? or are they simply just not needed?
thanks
| Code: | #NoEnv
SendMode Input ; help says it improves reliability
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3 ; the windows at each table have very similar names
#WinActivateForce ; i usually have many windows open at the same time
;#Persistent ; i removed this yesterday, so far no problems
1counter=0
21counter=0
31counter=0
41counter=0
Return
F1:: WinGet, 1winTitle, ID, A
Up::
IfWinExist, ahk_id %1winTitle%
{
WinActivate
WinWaitActive, , , 1
1counter++
If(1counter=1)
{ ControlClick, FTCSkinButton23
}
Else If(1counter=2)
{ ControlClick, FTCSkinButton25
ControlClick, FTCSkinButton26
}
Else If(1counter=3)
{ ControlClick, FTCSkinButton24
ControlClick, FTCSkinButton27
1counter=0
}
Sleep, 200
}
Return
Left::
IfWinExist, ahk_id %1winTitle%
{
WinActivate
WinWaitActive, , , 1
ControlClick, FTCSkinButton11
ControlClick, FTCSkinButton29
Sleep, 200
}
Return
;etc etc etc .... i now have this set up to run 4 different tables
|
|
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 338
|
Posted: Sun Mar 23, 2008 2:03 pm Post subject: |
|
|
| Autohotkey Help wrote: | SendMode Input:
Makes Send synonymous with SendInput or SendPlay rather than the default (SendEvent). Also makes Click and MouseMove/Click/Drag use the specified method. | You are not using send. However, you are using: | Autohotkey Help wrote: | ControlClick:
To improve reliability -- especially during times when the user is physically moving the mouse during the ControlClick -- try one or both of the following:
1) Use SetControlDelay -1 prior to ControlClick. This avoids holding the mouse button down during the click, which in turn reduces interference from the user's physical movement of the mouse.
2) Specify the string NA anywhere in the sixth parameter (Options). This avoids activating the window, and also avoids merging the script's input processing with that of the target window (which as a side-effect prevents physical movement of the mouse from interfering, but usually only when the target window is not active).
However, these modes might not work for all types of windows and controls. |
| Autohotkey Help wrote: | #WinActivateForce:
Although this directive will usually not change how quickly or reliably a window is activated, it might prevent task bar buttons from flashing when different windows are activated quickly one after the other. | If the flashing taskbar buttons do not happen (since you are working with only one window or don't care about them) this is not needed.
| Autohotkey Help wrote: | SetWorkingDir:
The script's working directory is the default directory that is used to access files and folders when an absolute path has not been specified. | You aren't doing anything that would require this.
| Autohotkey Help wrote: | SetTitleMatchMode:
Sets the matching behavior of the WinTitle parameter in commands such as WinWait. | You are not using titles, but ids.
I hope that this ridiculously long answer to a simple question helps!
On the other hand, if it ain't broke don't fix it!  _________________
 |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Mar 23, 2008 2:35 pm Post subject: |
|
|
Thank you so much.... that is exactly what i needed, much appreciated.
SendMode Input.... i should have mentioned it, but i have a few non poker related scripts that i use and they have use Send to place a some text in a note pad file and other simple things. So I will leave this in.
#WinActivateForce....... i usually have 4 or more windows open at the same time when playing. and often when i'm deciding on a decision at one table it will come my turn to act at another table and the poker software always tries to switch to that table or starts beeping and flashing and a bunch of other crap. i need to be assured that when i hit my bet or fold button at a table, it does it no matter what. so i will leave this in.
As for the others, I will experiment cautiausly with removing them.... simply because If it aint broke dont fix it..... is a major rule of mine, especially with computer stuff.
thanks much |
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Mon Mar 24, 2008 8:51 am Post subject: |
|
|
hmmm...
not sure why it called me a guest?
but the post above is from me ....
thanks for all your help |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|