By Adde @ 2+2 forums (HstreamPoker at gmail dot com). The corresponding thread on 2+2 is here.
Modified by chris228 @ 2+2 foums. See script code for changes.
Poker Starter
Hotkeys to open/close poker applications, and start/stop datamining.
By default the script will open up Partypoker/Empirepoker, Pokeroffice, Pokertracker, Pokerace Hud and Multi Table Helper, plus any number of custom applications you define. These custom applications will just be opened, while Partypoker/Empirepoker will auto-login, and Pokertracker will start an auto-import. To add custom functions for other applications (say auto-login for Pokerstars), you have to write that code yourself.
Datamining functions needs iWitness and FreePHG to work. Empirepoker users need iWitnessEmpire.
This script has Scriptpad support. Scriptpad is a tool where you can connect any number of scripts to a Scriptpad, a small pop-up window with buttons for all available commands in these scripts. You access the Scriptpad by clicking a hotkey, for instance the middle mouse button.
How To Use This Script
Read instructions for AutoHotkey, and make sure you have the latest version installed.
Read all instructions on this page.
Save the script code below in a file named "PokerStarter.ahk"
Open script file in a text editor and edit settings.
Run the script (double-click the file).
Default settings will open/close applications when your press F5 and F6, and start/stop when you press F7 and F8 on your keyboard.
A green AHK icon will show in the system tray as long as the script is running. Right-click this icon and choose "Exit" to exit the script. If the script seems to have gone wild, choose "Reload this script".
Troubleshooting
If things don't seem to work, restart the script from the system tray.
Script Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Code begins here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;------------------------------------------------------------------------------------------------
; Poker Starter v0.14+
;------------------------------------------------------------------------------------------------
; Date: 2006-06-26
; AHK version: 1.0.44.01
;------------------------------------------------------------------------------------------------
; Author(s): Adde @ 2+2 forums
; Contact: HstreamPoker at gmail dot com
;------------------------------------------------------------------------------------------------
; Hotkeys to open/close poker applications, and start/stop datamining.
; See web page for more details.
;
; http://overcards.com/wiki/moin.cgi/PokerStarter
;
; All rights reserved. Use at your own risk.
;------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------
; Poker Starter Mod v0.62
;------------------------------------------------------------------------------------------------
; Date: 2006-07-07
;------------------------------------------------------------------------------------------------
; Author(s): chris228 @ 2+2 forums
;------------------------------------------------------------------------------------------------
; Changes:
; Added support for Poker Office
; Added support for FreePHG commandoline options
; Added support for EmpirePoker
; Added support for Multi Table Helper
; Added support for autoclosing the Party/Empire Welcome Message
; Added support for moving and backup the Hand History Files wirtten by FreePHG
; Added support for auto-minimize iWitness after Datamining starts
; Fixed "start Datamining" if you dont use Poker Tracker
;------------------------------------------------------------------------------------------------
;________________________________________________________________________________________________
;
; EDIT THESE SETTINGS
;________________________________________________________________________________________________
; Set what hotkeys should open/close applications, and start/stop datamining.
; Leave empty (=) if you don't want to use a hotkey for a specific function.
; List of available hotkeys: http://www.autohotkey.com/docs/KeyList.htm
ps_hotkey_open_all = F9
ps_hotkey_close_all = F10
ps_hotkey_datamine_start = F11
ps_hotkey_datamine_stop = F12
; Set paths to these poker applications. Leave blank if you don't use one.
; Set path to PartyPoker OR EmpirePoker. Leave one blank!
; For EmpirePoker you have to use iWitnessEmpire
; pp=partypoker; ep=empirepoker; pa=pokerace hud; pt=pokertracker; po=pokeroffice; iw=iwitness; hg=free party handgrabber
; mth=Multitablehelper
ps_pp_path =
ps_ep_path = E:\EmpirePokerMaster\EmpirePokerMaster.exe
ps_pa_path =
ps_pt_path =
ps_po_path = E:\PokerOffice.exe
ps_iw_path = E:\AHK Scripts\iWitnessEmpire.ahk
ps_hg_path = E:\FreePHG.exe
ps_mth_path = E:\Multi Table Helper\mth.exe
; Set paths to custom applications you want to start. If 5 is not enough, create more ("ps_ca_path6" and so on).
ps_ca_path1 =
ps_ca_path2 =
ps_ca_path3 =
ps_ca_path4 =
ps_ca_path5 =
; Set if Pokertracker should be minimized (1) or not (0).
; Set if auto-import should start (1) or not (0) when PT opens.
; Set auto-import minutes interval.
; Set if Partypoker auto-import should be used (1) or not (0). If not, the generic auto-import will be used.
ps_pt_minimize = 1
ps_pt_import_at_start = 1
ps_pt_import_minutes = 1
ps_pt_import_party = 0
; Set if PokerOffice should be minimized (1) or not (0).
ps_po_minimize = 1
; Set if Pokerace should be minimized (1) or not (0).
ps_pa_minimize = 1
; Set if Multi Table Helper should be minimized (1) or not (0).
; Set if you use (1) Multi Table Helper Trial or not (0).
ps_mth_minimize = 1
ps_mth_trial = 0
; Set if iWitness should be minimized after Datamining starts (1) or not (0).
ps_iw_minimize = 1
; Set if FreePHG commandoline options (see FreePHG ReadMe.txt).
ps_hg_com = -o -p -2
; Set if the Hand Histories writen by FreePHG should be moved (1) or not (0).
; It will create a subfolder with the current date and time.
; Set if the Hand Histories writen by FreePHG should be backuped and compressed (1) or not (0). Requires WinRAR.
; The filename of the .rar contains the current date and time.
; Set if you specified another file extension for the Hand Histories written by FreePHG. Otherwise leave blank.
; Set the folder (with \ at the end) where the Hand History Files should be moved and backuped.
; If you leave it blank the FreePHG folder will be used.
ps_hg_move = 1
ps_hg_backup = 1
ps_hg_ext =
ps_hg_backup_path = F:\Hand Histories\Party Poker\
; Set screen coordinates where PartyPoker/EmpirePoker lobby should be moved to. Leave blank for no move.
ps_pp_move_lobby_x =
ps_pp_move_lobby_y =
; Set if PartyPoker/EmpirePoker Welcome Message should be closed (1) or not (0).
ps_msg_close = 1
;________________________________________________________________________________________________
;
; DO NOT EDIT BELOW HERE
;________________________________________________________________________________________________
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; auto-execute ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#NoEnv
#SingleInstance Ignore
#Persistent
ps_scriptpad_command_header = Poker Starter|Poker Starter|Poker Starter|Poker Starter
ps_scriptpad_command_name = Open Poker Apps|Close Poker Apps|Start Datamine|Stop Datamine
ps_scriptpad_command_label = PS_OpenPokerApps_Label|PS_ClosePokerApps_Label|PS_DatamineStart_Label|PS_DatamineStop_Label
ps_scriptpad_command_enabled = 1|1|1|1|
ahk_version = 1.0.44.01
if A_AhkVersion < %ahk_version%
{
msgbox, 4, , This script needs AutoHotkey version %ahk_version% or newer (you are using version %A_AhkVersion%). Script will exit`n`nGo to web page and download new version now?
IfMsgBox, Yes
Run, http://www.autohotkey.com
ExitApp
}
/*
ps_web_page = http://overcards.com/wiki/moin.cgi/PokerStarter
IfNotExist, PokerCodeLibrary.ahk
{
msgbox, 4, , File "PokerCodeLibrary.ahk" is missing. This file is needed for the script to work.`nSee web page for
more instructions. Script will exit.`n`nGo to web page now?
IfMsgBox, Yes
Run, %ps_web_page%
ExitApp
}
#Include PokerCodeLibrary.ahk
*/
Hotkey, %ps_hotkey_open_all%, PS_OpenPokerApps_Label, UseErrorLevel
Hotkey, %ps_hotkey_close_all%, PS_ClosePokerApps_Label, UseErrorLevel
Hotkey, %ps_hotkey_datamine_start%, PS_DatamineStart_Label, UseErrorLevel
Hotkey, %ps_hotkey_datamine_stop%, PS_DatamineStop_Label, UseErrorLevel
goto PS_Scriptpad_End
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; labels ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS_OpenPokerApps_Label:
PS_OpenPokerApps()
return
PS_ClosePokerApps_Label:
PS_ClosePokerApps()
return
PS_DatamineStart_Label:
PS_DatamineStart()
return
PS_DatamineStop_Label:
PS_DatamineStop()
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS_OpenPokerApps()
{
global
local path
Lib_PS_FPHandgrabber_Close(ps_hg_path)
Lib_PS_iwitness_Close()
Lib_PS_Partypoker_Open(ps_pp_path, true, ps_pp_move_lobby_x, ps_pp_move_lobby_y, ps_msg_close)
Lib_PS_Empirepoker_Open(ps_ep_path, true, ps_pp_move_lobby_x, ps_pp_move_lobby_y, ps_msg_close)
Lib_PS_Pokerace_Open(ps_pa_path, ps_pa_minimize)
Lib_PS_Multitablehelper_Open(ps_mth_path, ps_mth_minimize, ps_mth_trial)
Lib_PS_PokerOffice_Open(ps_po_path, ps_po_minimize)
if not ps_pt_path = ""
{
if Lib_PS_Pokertracker_Open(ps_pt_path, ps_pt_minimize)
if (ps_pt_import_at_start)
Lib_PS_Pokertracker_StartAutoImport(ps_pt_import_minutes, ps_pt_minimize)
}
Loop, 100
{
if (ps_ca_path%a_index% = "")
break
path = % ps_ca_path%a_index%
Run, %path%
}
Lib_PS_Beep(1, 50)
}
PS_ClosePokerApps()
{
global
Lib_PS_Partypoker_Close()
Lib_PS_Empirepoker_Close()
Lib_PS_PokerOffice_Close()
Lib_PS_Pokerace_Close()
Lib_PS_Multitablehelper_Close()
Lib_PS_FPHandgrabber_Close(ps_hg_path)
Lib_PS_iwitness_Close()
if not ps_pt_path = ""
{
Lib_PS_Pokertracker_StopAutoImport(true, true)
Lib_PS_Pokertracker_Close()
}
;PS_CloseScript("ChipReloader.ahk")
;PS_CloseProcess("allSNap.exe")
Lib_PS_Beep(1, 50)
return
}
PS_DatamineStart()
{
global
Lib_PS_PokerOffice_Close()
Lib_PS_Pokerace_Close()
Lib_PS_Multitablehelper_Close()
Lib_PS_Partypoker_Open(ps_pp_path, true, ps_pp_move_lobby_x, ps_pp_move_lobby_y, ps_msg_close)
Lib_PS_Empirepoker_Open(ps_ep_path, true, ps_pp_move_lobby_x, ps_pp_move_lobby_y, ps_msg_close)
if not ps_pt_path = ""
{
if not Lib_PS_Pokertracker_Open(ps_pt_path, ps_pt_minimize)
return
if not Lib_PS_Pokertracker_StartAutoImport(ps_pt_import_minutes, ps_pt_minimize)
return
}
Lib_PS_FPHandgrabber_Open(ps_hg_path, ps_hg_com)
Lib_PS_Empirepoker_NavigateToGameHome()
Lib_PS_iwitness_Open(ps_iw_path)
Lib_PS_iwitness_Go()
if ps_iw_minimize=1
{
Lib_PS_iWitness_Minimize()
}
Lib_PS_Beep(1, 50)
}
PS_DatamineStop()
{
global
Lib_PS_iwitness_Close()
Lib_PS_FPHandgrabber_Close(ps_hg_path)
Sleep, 1000
Lib_PS_Partypoker_CloseTables()
Lib_PS_Empirepoker_CloseTables()
Lib_PS_FPHandgrabber_Backup(ps_hg_path, ps_hg_backup_path, ps_hg_ext, ps_hg_move, ps_hg_backup)
if not ps_pt_path = ""
{
Lib_PS_Pokertracker_StopAutoImport()
}
Lib_PS_Beep(1, 50)
}
PS_CloseScript(name)
{
DetectHiddenWindows On
SetTitleMatchMode 2
WinClose %name% - AutoHotkey
DetectHiddenWindows Off
}
PS_CloseProcess(name)
{
Process, Close, %name%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; library (apps) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Lib_PS_FPHandgrabber_Backup(path, path2, hg_ext, fphg_move=false, fphg_backup=false)
{
FormatTime, TimeString, , dd.MM.yy - HH.mm
FreePHGdir := ""
StringGetPos, pos, path, \, r1
if (pos > 0)
StringLeft, FreePHGdir, path, pos+1
If (hg_ext = "")
{
hg_ext=hhf
}
If (path2 = "")
{
path2=%FreePHGdir%
}
IfExist, %FreePHGdir%*.%hg_ext%
{
If (fphg_backup = true)
{
IfNotExist, %path2%
{
FileCreateDir, %path2%
}
run, winrar.exe a -m5 -ep "%path2%Party Hands #%TimeString%.rar" "%FreePHGdir%*.%hg_ext%"
sleep, 500
IfNotExist, %path2%Party Hands #%TimeString%.rar
MsgBox, The compressed backup was NOT created.
}
if (fphg_move = true)
{
FileCreateDir, %path2%%TimeString%
FileMove, %FreePHGdir%*.%hg_ext%, %path2%%TimeString%
IfExist, %FreePHGdir%*.%hg_ext%
MsgBox, Not all Files have been moved.
}
}
return (true)
}
Lib_PS_Multitablehelper_Open(path, minimize=false, trial=false)
{
DetectHiddenWindows, on
SetTitleMatchMode, 1
Process, Exist, MTH.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
Run, %path%
if (trial = true)
{
WinWait, Register, ,2
WinActivate
Send {TAB}
Send {SPACE}
}
if (minimize = true)
{
Sleep, 1000
WinWait, MTH, ,4
WinMinimize
}
return (true)
}
Lib_PS_Multitablehelper_Close()
{
Process, Close, MTH.exe
return (true)
}
Lib_PS_iWitness_Minimize()
{
WinWait, iWitness, , 5
WinMinimize
return (true)
}
Lib_PS_PokerOffice_Open(path, minimize=false)
{
DetectHiddenWindows, on
SetTitleMatchMode, 1
Process, Exist, javaw.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
wdir := ""
StringGetPos, pos, path, \, r1
if (pos > 0)
StringLeft, wdir, path, pos+1
Run, %path%, %wdir%
if (minimize = true)
{
Sleep, 1000
WinWait, PokerOffice, ,5
WinMinimize
}
return (true)
}
Lib_PS_PokerOffice_Close()
{
Process, Close, javaw.exe
return (true)
}
Lib_PS_Empirepoker_Open(path, login=true, x="", y="", msg_close=false, timeoutSeconds=20, silentMode=false)
{
Process, Exist, EmpirePokerMaster.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
Run, %path% -P=EmpirePoker
winID := Lib_PS_Empirepoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
{
if (silentMode = false)
msgbox "Can't open connection to EmpirePoker."
return (false)
}
if (x <> "" and y <> "")
Lib_PS_WinMoveID(winID, x, y, "", "", 5)
winLoginID := Lib_PS_WinGetID(1, "Login to EmpirePoker.com", "", "#32770", timeoutSeconds)
if (winLoginID = "")
{
if (silentMode = false)
msgbox "Can't find EmpirePoker login window."
return (false)
}
result := Lib_PS_WinCloseID(winLoginID)
if (login = true)
{
WinActivate, ahk_id %winID%
Lib_PS_ClickButton(winID, 1, "Button3")
}
if (msg_close = true)
{
WinWait, Message from EmpirePoker, ,3
WinClose
}
return (true)
}
Lib_PS_Empirepoker_Close()
{
Process, Close, EmpirePokerMaster.exe
return (true)
}
Lib_PS_Empirepoker_GetLobbyWinID(timeoutSeconds=5)
{
winID := Lib_PS_WinGetID(1, "EmpirePoker: Poker Lobby", "", "#32770", timeoutSeconds)
return (winID)
}
Lib_PS_Empirepoker_NavigateToGameHome()
{
winID := Lib_PS_Empirepoker_GetLobbyWinID()
if (winID = "")
return (false)
winactivate, ahk_id %winID%
ControlFocus, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
send {HOME}
sleep, 300
return (true)
}
Lib_PS_Empirepoker_CloseTables()
{
SetTitleMatchMode, 2
WinGet, pid, PID, EmpirePoker:
WinGet, idList, List, Good Luck ahk_pid%pid% ahk_class #32770, , EmpirePoker:
Loop, %idList%
{
id := idList%a_index%
WinClose , ahk_id %id%
}
return (true)
}
Lib_PS_Partypoker_Open(path, login=true, x="", y="", msg_close=false, timeoutSeconds=20, silentMode=false)
{
Process, Exist, PartyGaming.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
Run, %path% -P=PartyPoker
winID := Lib_PS_Partypoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
{
if (silentMode = false)
msgbox "Can't open connection to PartyPoker."
return (false)
}
if (x <> "" and y <> "")
Lib_PS_WinMoveID(winID, x, y, "", "", 5)
winLoginID := Lib_PS_WinGetID(1, "PartyAccount Login", "", "#32770", timeoutSeconds)
if (winLoginID = "")
{
if (silentMode = false)
msgbox "Can't find PartyPoker login window."
return (false)
}
result := Lib_PS_WinCloseID(winLoginID)
if (login = true)
{
WinActivate, ahk_id %winID%
Lib_PS_ClickButton(winID, 1, "Button3")
}
if (msg_close = true)
{
WinWait, Message from PartyPoker.com, ,3
WinClose
}
return (true)
}
Lib_PS_Partypoker_Close()
{
Process, Close, PartyGaming.exe
return (true)
}
Lib_PS_Partypoker_GetLobbyWinID(timeoutSeconds=5)
{
winID := Lib_PS_WinGetID(1, "PartyPoker.com: Poker Lobby", "", "#32770", timeoutSeconds)
return (winID)
}
Lib_PS_Partypoker_NavigateToGameHome()
{
winID := Lib_PS_Partypoker_GetLobbyWinID()
if (winID = "")
return (false)
winactivate, ahk_id %winID%
ControlFocus, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
send {HOME}
sleep, 300
return (true)
}
Lib_PS_Partypoker_CloseTables()
{
SetTitleMatchMode, 2
WinGet, pid, PID, PartyPoker.com:
WinGet, idList, List, Good Luck ahk_pid%pid% ahk_class #32770, , PartyPoker.com:
Loop, %idList%
{
id := idList%a_index%
WinClose , ahk_id %id%
}
return (true)
}
Lib_PS_Pokertracker_Open(path, minimize=false, x="", y="", timeoutSeconds=10, silentMode=false)
{
Process, Exist, ptrack2.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
Run, %path% , , max
winID := Lib_PS_WinGetID(1, "Poker Tracker (Version", "", "", timeoutSeconds)
if (winID = "")
{
if (silentMode = false)
msgbox "Can't find PokerTracker main window."
return (false)
}
Loop
{
IfWinNotExist, Poker Tracker (Version, Checking to see
break
}
if (minimize = true)
PostMessage, 0x112, 0xF020,,, Poker Tracker (Version
return (true)
}
Lib_PS_Pokertracker_Close()
{
Process, Close, ptrack2.exe
return (true)
}
Lib_PS_Pokertracker_StartAutoImport(timerSeconds, minimize=false, timeoutSeconds=10, silentMode=false)
{
global ps_pt_import_party
openImport := false
SetTitleMatchMode, 1
IfWinNotExist, Poker Tracker (Version, Auto-Import
{
WinActivate, Poker Tracker (Version
if (ps_pt_import_party = 1)
{
WinMenuSelectItem, Poker Tracker (Version, , File, Auto-Import Party
Loop, 10
{
IfWinExist, Hand History Files, Please note
{
WinClose, Hand History Files, Please note
break
}
sleep, 200
}
}
else
WinMenuSelectItem, Poker Tracker (Version, , File, Auto-Import Hand Histories
sleep, 500
openImport := true
}
if (openImport)
{
if (ps_pt_import_party = 1)
winID := Lib_PS_WinGetID(1, "Poker Tracker (", "Auto-Import Party Poker", "", timeoutSeconds)
else
winID := Lib_PS_WinGetID(1, "Auto-Import", "Set timer to check for", "", timeoutSeconds)
if (winID = "")
{
if (silentMode = false)
msgbox "Can't find PokerTracker auto-import window."
return (false)
}
IfWinExist, Hand History Files, Please note
WinClose, Hand History Files, Please note
WinActivate, ahk_id %winID%
ControlSetText, PBEDIT701, %timerSeconds%, ahk_id %winID%
if (ps_pt_import_party = 1)
Lib_PS_ClickButton(winID, 1, "Button12")
else
Lib_PS_ClickButton(winID, 1, "Button2")
}
/*
winID := Lib_PS_WinGetID(1, "Poker Tracker (Version", "Start Timer", "", 1)
WinMenuSelectItem, Poker Tracker (Version, , Window, Layer
if (winID <> "")
Lib_PS_ClickButton(winID, 1, "Button17")
*/
if (minimize)
PostMessage, 0x112, 0xF020,,, Poker Tracker (Version
return (true)
}
Lib_PS_Pokertracker_StopAutoImport(closeWindow=true, forceStop=false, x=1586, y=83, timeoutSeconds=10)
{
winID := Lib_PS_WinGetID(1, "Poker Tracker (Version", "Force Import", "", timeoutSeconds)
if (winID = "")
return (true)
if (forceStop = false)
{
gosub Lib_PS_Pokertracker_StopAutoImport_Poll1
Lib_PS_ClickButton(winID, 1, "Stop Timer")
Lib_PS_ClickButton(winID, 1, "Button18")
sleep, 1000
;gosub Lib_PS_Pokertracker_StopAutoImport_Poll2
}
/*
if (closeWindow or forceStop)
{
;WinMenuSelectItem, Poker Tracker (Version, , Window, Layer
WinActivate, ahk_id %winID%
Click %x%, %y%
}
*/
return (true)
Lib_PS_Pokertracker_StopAutoImport_Poll1:
ct := 0
loop
{
ControlGetText, text, Button2, ahk_id %winID%
if (text <> "")
ct++
else
ct := 0
if (ct > 3)
break
sleep, 1000
}
return
Lib_PS_Pokertracker_StopAutoImport_Poll2:
Loop
{
ControlClick, pbdw702, ahk_id %winID%
Loop, 10
ControlSend, pbdw702, {UP}, ahk_id %winID%
ControlGet, text, Line, 1, Edit2, ahk_id %winID%
if InStr(text, "No hand history files have been created")
break
if InStr(text, "Import Finished")
break
sleep, 1000
}
return
}
Lib_PS_Pokerace_Open(path, minimize=false)
{
Process, Exist, PAHud.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
if (minimize)
Run, %path% , , min
else
Run, %path%
return (true)
}
Lib_PS_Pokerace_Close()
{
Process, Close, PAHud.exe
return (true)
}
Lib_PS_FPHandgrabber_Open(path, commands)
{
SetTitleMatchMode, 1
IfWinExist, %path%
return (true)
IfNotExist, %path%
return (false)
wdir := ""
StringGetPos, pos, path, \, r1
if (pos > 0)
StringLeft, wdir, path, pos+1
Run, %path% %commands%, %wdir%, min
return (true)
}
Lib_PS_FPHandgrabber_Close(path)
{
if (path = "")
return (false)
SetTitleMatchMode, 1
IfWinExist, %path%
WinClose, %path%
return (true)
}
Lib_PS_iwitness_Open(path)
{
SetTitleMatchMode, 1
IfNotExist, %path%
return (false)
IfWinExist, %path%
return (true) ; WinClose, iWitness
Run, %path%
WinWait, iWitness, , 10
WinActivate, iWitness
return (true)
}
Lib_PS_iwitness_Close()
{
SetTitleMatchMode, 1
DetectHiddenWindows, on
IfWinExist, iWitness
WinClose, iWitness
return (true)
}
Lib_PS_iwitness_Go()
{
SetTitleMatchMode, 1
WinWait, iWitness, , 5
IfWinNotExist, iWitness
return (false)
WinActivate, iWitness
ControlFocus, Button1 , iWitness
Send {SPACE}
return (true)
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; library (general) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Lib_PS_WinActivateID(winID)
{
WinActivate, ahk_id %winID%
}
Lib_PS_WinExist(matchMode, title, text, class="", titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
{
IfWinExist, %title% ahk_class %class%, %text%, %titleEx%, %textEx%
return (true)
else
return (false)
}
else
{
IfWinExist, %title%, %text%, %titleEx%, %textEx%
return (true)
else
return (false)
}
}
Lib_PS_WinExistID(winID)
{
IfWinExist, ahk_id %winID%
return (true)
else
return (false)
}
Lib_PS_WinClose(matchMode, title, text, class="", timeoutSeconds=5, titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
WinClose, %title% ahk_class %class%, %text%, %titleEx%, %textEx%
else
WinClose, %title%, %text%, %titleEx%, %textEx%
result := Lib_PS_WinWaitClose(matchMode, title, text, class, timeoutSeconds, titleEx, textEx)
return (result)
}
Lib_PS_WinCloseID(winID, timeoutSeconds=5)
{
WinClose, ahk_id %winID%
result := Lib_PS_WinWaitCloseID(winID, timeoutSeconds)
return (result)
}
Lib_PS_WinWait(matchMode, title, text, class="", timeoutSeconds="", titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
WinWait, %title% ahk_class %class%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
else
WinWait, %title%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
return (ErrorLevel = 0)
}
Lib_PS_WinWaitClose(matchMode, title, text, class="", timeoutSeconds="", titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
WinWaitClose, %title% ahk_class %class%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
else
WinWaitClose, %title%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
return (ErrorLevel = 0)
}
Lib_PS_WinWaitCloseID(winID, timeoutSeconds="")
{
WinWaitClose, ahk_id %winID%, , %timeoutSeconds%
if (ErrorLevel = 1)
return (false)
else
return (true)
}
Lib_PS_WinMoveID(winID, x, y, w="", h="", timeoutSeconds=0)
{
stopTimer := Lib_PS_CreateStopTimer(timeoutSeconds)
isMoved := false
Loop
{
WinGetPos, x0, y0, w0, h0, ahk_id %winID%
if (x0 = x AND y0 = y)
{
isMoved := true
break
}
WinMove, ahk_id %winID%, , x, y, w, h
Sleep, 25
if (A_Now > stopTimer)
break
}
return (isMoved)
}
Lib_PS_WinGetID(matchMode, title, text, class="", timeoutSeconds=0, titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
stopTimer := Lib_PS_CreateStopTimer(timeoutSeconds)
winID := ""
Loop
{
if (winID = "")
if (class <> "")
WinGet, winID, ID, %title% ahk_class %class%, %text%, %titleEx%, %textEx%
else
WinGet, winID, ID, %title%, %text%, %titleEx%, %textEx%
else
break
if (A_Now > stopTimer)
break
sleep, 100
}
return (winID)
}
Lib_PS_ClickButton(winID, matchMode, buttonName, clickByKey="")
{
if (clickByKey = "")
{
StringUpper, str, buttonName
StringLeft, str, str, 6
if (str = "BUTTON")
clickByKey := true
else
clickByKey := false
}
SetTitleMatchMode, %matchMode%
WinActivate, ahk_id %winID%
ControlGet, result, Visible, , %buttonName%, ahk_id %winID%
if (result = false)
return (false)
if (clickByKey)
{
ControlFocus, %buttonName%, ahk_id %winID%
Send {SPACE}
}
else
ControlClick, %buttonName%, ahk_id %winID%
return (ErrorLevel = 0)
}
Lib_PS_ClickButtonList(winID, matchList, buttonList, clickByKey=false)
{
StringSplit, buttonList, buttonList, |
StringSplit, matchList, matchList, |
Loop, %buttonList0%
{
thisButton := buttonList%a_index%
thisMatch := matchList%a_index%
SetTitleMatchMode, %thisMatch%
ControlGet, result1, Visible, , %thisButton%, ahk_id %winID%
ControlGet, result2, Enabled, , %thisButton%, ahk_id %winID%
If (result1 AND result2)
{
if (clickByKey)
{
ControlFocus, %thisButton%, ahk_id %winID%
Send {SPACE}
}
else
ControlClick, %thisButton%, ahk_id %winID%
return (ErrorLevel = 0)
}
}
return (false)
}
Lib_PS_ClickCheckbox(winID, matchMode, checkboxName, checked, timeoutSeconds=5)
{
stopTimer := Lib_PS_CreateStopTimer(timeoutSeconds)
SetTitleMatchMode, %matchMode%
Loop
{
ControlGet, result, Visible, , %checkboxName%, ahk_id %winID%
if (result = true)
break
sleep, 50
if (A_Now > stopTimer)
break
}
if (result = false)
return (false)
stopTimer := Lib_PS_CreateStopTimer(timeoutSeconds)
WinActivate, ahk_id %winID%
ControlGet, result, Checked, , %checkboxName%, ahk_id %winID%
if (result = checked)
return (true)
Loop {
if (checked)
Control, Check, , %checkboxName%, ahk_id %winID%
else
Control, Uncheck, , %checkboxName%, ahk_id %winID%
sleep, 50
ControlGet, result, Checked, , %checkboxName%, ahk_id %winID%
if (result = checked)
return (true)
if (A_Now > stopTimer)
break
}
return (false)
}
Lib_PS_CreateStopTimer(seconds)
{
stopTime := A_Now
EnvAdd, stopTime, %seconds%, seconds
return (stopTime)
}
Lib_PS_SaveMousePosition()
{
global Lib_PS_mouse_pos_x, Lib_PS_mouse_pos_y
CoordMode, Mouse, Screen
MouseGetPos, Lib_PS_mouse_pos_x, Lib_PS_mouse_pos_y
CoordMode, Mouse, Relative
}
Lib_PS_RestoreMousePosition()
{
global Lib_PS_mouse_pos_x, Lib_PS_mouse_pos_y
CoordMode, Mouse, Screen
MouseMove, Lib_PS_mouse_pos_x, Lib_PS_mouse_pos_y, 0
CoordMode, Mouse, Relative
}
Lib_PS_LongestListItem(list)
{
longest = 0
Loop, Parse, list, |
{
If (longest < StrLen(A_LoopField))
{
longest := StrLen(A_loopfield)
}
}
return (longest)
}
Lib_PS_Beep(times, length, frequency="")
{
Loop, %times%
SoundBeep, %frequency%, %length%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; scriptpad ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS_Scriptpad_End:
; Do nothing. This is needed to work with Scriptpad.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Code ends here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
