Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2006, 04:02 PM
tinhat tinhat is offline
Senior Member
 
Join Date: Apr 2005
Location: white courtesy phone
Posts: 521
Default simple ahk help

Can someone tell me what's the matter w/the code below? It's part of an ahk script, I made a desktop link and 50-75% of the time when I first click it gets hung up; after I kill ahk and double-click the desktop icon a second time it works fine.

Of the 50-75% of the time it fails initially, it's usually hung up closing the default pt db (not always); but what I don't get is that when it fails, I kill ahk and the second time I double-click this script icon it *always* runs to completion correctly (I added the "sleeps" hoping it was just overrunning itself or something - didn't do any good).

<font class="small">Code:</font><hr /><pre>
;; pokertracker
SetTitleMatchMode, 1
Process, Exist, ptrack2.exe
if %ErrorLevel% = 0
{
Run, "C:\Documents and Settings\mike\Desktop\Poker Tracker.lnk",max
openDb :=1
startImport := 0
closeDb := 0
}

if openDb = 1
{
WinWait, Poker Tracker (Version
WinActivate, Poker Tracker (Version
WinMenuSelectItem, Poker Tracker, , File, Open A Database...
;WinWait, Poker Tracker (Version
Send {TAB}
Send {TAB}
Send {Down}
Send {Down}
Send {Space}
Send {Enter}
closeDb := 1
}
sleep, 500

if closeDb = 1
{
WinWait, Poker Tracker (Version
WinActivate, Poker Tracker (Version
WinMenuSelectItem, Poker Tracker, , File, Close A Database...
;WinWait, Poker Tracker (Version
Send {TAB}
Send {TAB}
Send {Space}
Send {Enter}
Send {Enter}
startImport := 1
}
sleep, 500

if startImport = 1
{
WinWait, Poker Tracker (Version
WinActivate, Poker Tracker (Version
WinMenuSelectItem, Poker Tracker, , File, Auto-Import Hand Histories
;WinWait, Poker Tracker (Versio
Send {TAB}
Send {TAB}
Send {TAB}
Send {TAB}
Send {Space}
WinWait, Poker Tracker (Version, Stop Timer
}
sleep, 500

WinMinimize, Poker Tracker (Version</pre><hr />
Reply With Quote
  #2  
Old 11-06-2006, 04:57 PM
illunious illunious is offline
Senior Member
 
Join Date: Oct 2003
Posts: 1,992
Default Re: simple ahk help

just a quick guess.. after doing the menu item in the first one, add a winwait for the "open a database" dialog
Reply With Quote
  #3  
Old 11-06-2006, 10:15 PM
TheIrishThug TheIrishThug is offline
Senior Member
 
Join Date: Jan 2005
Location: Belligerent and numerous
Posts: 1,819
Default Re: simple ahk help

illunious' idea sounds like a good one. I can't test it as I only have one database right now.

That being said, I'm not really sure why you have structured your program the way you have. If you run your script and PT is open, it will just minimize PT.

If PT isn't open, the script will open it, and then always run the next three blocks within the if statement.

This is because when PT is not open you set openDb to 1. Then you check to see if openDb is equal to 1 (which it is). So you run through the block that opens a database. This block ends by setting closeDb to 1.
You then check to see if closeDb is 1, and it is. So you enter the block that closes a database. This block ends by setting startImport to 1.
You then check to see if startImport is 1, and it is. So you enter the block that starts an import.

If you actually do want to do each of the 3 blocks every time when PT is not open when the script is executed you can just use the following. (I cleaned up a few other things, too. I prefer ControlClick type interaction with windows as opposed to Sending keyboard events. But that is only because it sometimes makes the code more readable for people that don't know what the control is active after 2 tabs.)

<font class="small">Code:</font><hr /><pre>;; pokertracker
;1 is the default of TitleMatchMode, so you do not need to set it.
Process, Exist, ptrack2.exe
if ErrorLevel = 0
{
Run, "C:\Documents and Settings\mike\Desktop\Poker Tracker.lnk",max

WinWait, Poker Tracker (Version
WinActivate, Poker Tracker (Version
WinMenuSelectItem, Poker Tracker, , File, Open A Database...
Send, {TAB 2}{Down 2}{Space}{Enter}
sleep, 500

;Repeated WinWait, WinActivate can be left out because you are not likely to deactivate PT in the 1/2 second sleep time.
;If you think you will, look into BlockInput

WinMenuSelectItem, Poker Tracker, , File, Close A Database...
Send, {TAB 2}{Space}{Enter 2}
sleep, 500

WinMenuSelectItem, Poker Tracker, , File, Auto-Import Hand Histories
Send, {TAB 4}{Space}
WinWait, Poker Tracker (Version, Stop Timer
}
sleep, 500

WinMinimize, Poker Tracker (Version</pre><hr />
Reply With Quote
  #4  
Old 11-07-2006, 02:51 PM
tinhat tinhat is offline
Senior Member
 
Join Date: Apr 2005
Location: white courtesy phone
Posts: 521
Default Re: simple ahk help

Excellent! illunious' idea does seem to be what was missing but I wanted to thank you for the code cleanup. I learned alot about ahk just looking over your changes/explanations. Thanks both...

Mike
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.