Quote:
Originally Posted by Dread Wings
So I wrote this script to quickly click on my sorting options in the "Sort" window in the pokerstars client. The thing is I am worried about other windows stealing focus in the middle of the script causing misclicks while playing. How do I make sure the script only clicks on the "Sort" window?
Also the script would be a lot better if it automatically ran when the Sort window appeared. I have no idea how to do that either.
Lol, I had no idea that window was there...
You are better off using Control, ChooseString and ControlClick... No chance of misclicks that way.
Code:
#NoEnv
#SingleInstance force
SendMode Input
; edit to your liking:
prefs:="Wait,Asc|Plrs/Flop,Desc|<None>,Asc"
; loop endlessly, waiting for the sort window:
Loop {
WinWait Sort ahk_class #32770
setPrefs(prefs, winExist())
WinWaitClose ; wait for it to close, and repeat
}
return
; sets the prefs and closes the Sort window
setPrefs(prefs, win) {
WinExist("ahk_id" win) ; set last-found window
StringSplit, pair, prefs, |
Loop % pair0 {
i:=a_index
StringSplit, pref, pair%i%, `,
Control, ChooseString, % pref1, ComboBox%i%
; calculate button#:
button#:=(pref2="Asc") ? (i-1)*2+1 : (i-1)*2+2
; ControlClick is unreliable, do it 5 times to make sure
Loop 5
ControlClick, Button%button#%
}
WinActivate
Send {enter}
}
Having written it, I'm not quite sure what the point of this is, as Stars saves your sort settings?