 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Wed Feb 27, 2008 2:38 pm Post subject: problem running 2 ahk's at same time |
|
|
i have a problem when i run two .ahk programs at the same time. I run 1st one and it works fine, then when I run the 2nd one it affects the 1st, the 1st one still kinda works but parts of it dont work until i reload it, but then the 2nd one doesnt work correctly...etc, etc.
Two of the .ahk's i like to run at the same time are shown below. Basically what I use them for is playing online poker at various poker sites. The .ahk lets me play without having to use the mouse to check, bet, etc.
When I run FTP_NL ahk the first thing I do is select the table i'm playing at and press "Esc & NumpadEnd", this sets that specific table (or window) as the table that the keys below work on. Then I run "PCPChat ahk" and open my forums chat window and press "Esc & '", this sets that window to be activated when i press the ' key. That way while i'm playing at my table i don't have to use the mouse to click from window to window and can chat with my friends while playing poker.
the problem is since FTP was loaded first if during my poker game I get moved to a new table (ie window) I have to reset that table by pressing "Esc & NumpadEnd", but it doesn't work and won't reset to the new window unless I reload teh FTP ahk.
What am I doing wrong?
FYI
In case your wondering we don't discuss hands being played or give any hints about our poker table play, we usually just chat about whatever friends chat about while we are playing, we don't cheat in other words. |
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Wed Feb 27, 2008 2:39 pm Post subject: |
|
|
i tried to put the ahk's in the post above but kept getting a 'General Error"
so i'll try putting them here
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 3
#WinActivateForce
;setWin ft_nlhe
Esc & NumpadEnd::
WinGet, wstit_ft_nlhe, ID, A
ft_nlhex1:=0.691
ft_nlhex2:=0.818
ft_nlhex3:=0.941
ft_nlhex4:=0.890
ft_nlhex5:=0.920
ft_nlhex6:=0.950
ft_nlhey1:=0.938
ft_nlhey2:=0.780
ft_nlhey3:=1
ft_nlhey4:=1
ft_nlhey5:=1
return
;foldft_nlhe
NumpadEnd::
WinActivate, ahk_id %wstit_ft_nlhe%
WinWaitActive, ahk_id %wstit_ft_nlhe%, , 1
WinGetPos, ft_nlhexw, ft_nlheyw, ft_nlheww, ft_nlhehw, ahk_id %wstit_ft_nlhe%
ft_nlheXtarget1:=ft_nlhex1*ft_nlheww
ft_nlheYtarget1:=ft_nlhey1*ft_nlhehw
MouseClick, left, %ft_nlheXtarget1%, %ft_nlheYtarget1%, 1, 0
return
;callft_nlhe
NumpadDown::
WinActivate, ahk_id %wstit_ft_nlhe%
WinWaitActive, ahk_id %wstit_ft_nlhe%, , 1
WinGetPos, ft_nlhexw, ft_nlheyw, ft_nlheww, ft_nlhehw, ahk_id %wstit_ft_nlhe%
ft_nlheXtarget2:=ft_nlhex2*ft_nlheww
ft_nlheYtarget1:=ft_nlhey1*ft_nlhehw
MouseClick, left, %ft_nlheXtarget2%, %ft_nlheYtarget1%, 1, 0
return
;betft_nlhe
NumpadPgDn::
WinActivate, ahk_id %wstit_ft_nlhe%
WinWaitActive, ahk_id %wstit_ft_nlhe%, , 1
WinGetPos, ft_nlhexw, ft_nlheyw, ft_nlheww, ft_nlhehw, ahk_id %wstit_ft_nlhe%
ft_nlheXtarget3:=ft_nlhex3*ft_nlheww
ft_nlheYtarget1:=ft_nlhey1*ft_nlhehw
MouseClick, left, %ft_nlheXtarget3%, %ft_nlheYtarget1%, 1, 0
return |
|
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Wed Feb 27, 2008 2:40 pm Post subject: |
|
|
heres the second ahk
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 3
#WinActivateForce
;setWin pcpchat
Esc & `::
WinGet, pcpchat, ID, A
return
;foldf
`::
WinActivate, ahk_id %pcpchat%
WinWaitActive, ahk_id %pcpchat%, , 1
WinGetPos, pcpx, pcpy, pcpw, pcph, ahk_id %pcpchat%
pcpchatx:=160
pcpchaty:=pcph-50
MouseClick, left, %pcpchatx%, %pcpchaty%, 1, 0
return |
|
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 722 Location: Florida
|
Posted: Wed Feb 27, 2008 2:42 pm Post subject: |
|
|
I may be wrong but I don't think that both can use sendmode input, which might affect you. _________________ [Join IRC!]
 |
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Wed Feb 27, 2008 7:39 pm Post subject: |
|
|
ok thanks.
I thought all scripts had to start with the Sendmode Input?
So, what must i do to get this to work?
Do i have to put both scripts into one big ahk or is there anothe way?
I have one of these types of scripts for each poker siter i play at (3 sites) and in the event I'm playing two tables at teh same time I also use a different script for the other table. |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 722 Location: Florida
|
Posted: Wed Feb 27, 2008 9:57 pm Post subject: |
|
|
Scripts don't have to start with that, but it's part of the template since it's the preferred method. I think that what happens is that only one script at once can use that method, so the whichever was opened second will use another method. The easiest thing to do would be to just combine them into one script.
If it doesn't work after that, let us know... _________________ [Join IRC!]
 |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 901
|
Posted: Wed Feb 27, 2008 11:31 pm Post subject: |
|
|
| Are you sure? Because I almost always use SendMode Input and I've never noticed a problem. |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 722 Location: Florida
|
Posted: Thu Feb 28, 2008 1:29 am Post subject: |
|
|
I'm not sure, but that's how I'm interpreting this:
| Manuel Auxveride wrote: |
If a script other than the one executing SendInput has a low-level keyboard hook installed, SendInput automatically reverts to SendEvent (or SendPlay if SendMode InputThenPlay is in effect). This is done because the presence of an external hook disables all of SendInput's advantages, making it inferior to both SendPlay and SendEvent. However, since SendInput is unable to detect a low-level hook in programs other than AutoHotkey v1.0.43+, it will not revert in these cases, making it less reliable than SendPlay/Event. |
I haven't really tested it, but I think that once when I was running two scripts that used SendInput, one of them (presumably the second one I started) sent text much slower than usual... Maybe someone can say for sure if my perception is correct or not. _________________ [Join IRC!]
 |
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Thu Feb 28, 2008 9:18 am Post subject: |
|
|
Wow! Thanks for all the reply's and thoughtful advice. (although I don't actually understand half of what your saying....lol)
So best I can figure, I have to just put all the scripts into one ahk file. Was hoping I wouldn't have to do that, i suppose i will have a better ahk when i figure it out so it will be worth it.
thanks again for the discussion.
i am learning alot from you all. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Thu Feb 28, 2008 10:00 am Post subject: |
|
|
I can say for certain that on my system SendMode, Input considerably increases the speed keystrokes are sent, regardless of how many scripts have a low-level keyboard hook. Looking at the AutoHotkey source, all logic tells me the help file should be accurate. My eyes tell me it is not.
livinthelife's issue is unrelated: using a key as a prefix key in a custom combination causes AutoHotkey to block the key from the operating system, the active window, and other scripts. In other words, Esc & ` in the second script blocks Esc from the first script. Since the first script never sees the Esc key as "pressed", the hotkey Esc & NumpadEnd can never trigger.
| Quote: | | So best I can figure, I have to just put all the scripts into one ahk file. | That should solve the issue. Alternatively you could use standard modifier keys (Ctrl, Alt, etc.) instead of Esc, or use ~Esc (but then the active window would get the escape key-press too.) |
|
| Back to top |
|
 |
livinthelife
Joined: 09 Feb 2008 Posts: 18
|
Posted: Sat Mar 01, 2008 5:59 pm Post subject: |
|
|
thanks i think that was the problem so i will no longer use 2 key combos for ahk files.
Made me think though, are there keys that should not be used as hotkeys? for example i had part of the script above set with the hotkeys being Insert, Home, PageUp, Delete, End, PageDown..... sometimes I would have problems
any ideas |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 722 Location: Florida
|
Posted: Mon Mar 03, 2008 5:16 am Post subject: |
|
|
It's tough to choose a bunch of hotkeys that aren't going to cause you a problem in some program, sometime. For what it's worth, I've picked one hotkey (win+z) and made it display a menu where I can choose lots of different things. Less to remember and less chance of that hotkey colliding with something (afaik win+z doesn't 'do' anything in Windows). Even this has problems when I use some of the old work laptops that don't have a windows key. I thought about making a 'hot corner' that will create the menu after holding the mouse in the 0,0 pixel (or is it 1,1?) for more than a second, but now I'm just rambling. _________________ [Join IRC!]
 |
|
| 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
|