 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
pantagruel
Joined: 08 Oct 2006 Posts: 67 Location: denmark
|
Posted: Fri Jun 06, 2008 8:26 am Post subject: com based windows activate different between computers |
|
|
Hi,
I have the following code
| Code: |
COM_Init()
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
pwb := COM_Invoke(psw, "Item", A_Index-1)
locationname := COM_Invoke(pwb, "LocationName")
IfInString,locationname,%gbssite%
{
wasfound := 1
uid := COM_Invoke(pwb, "hWnd")
WinActivate, ahk_id %uid%
}
COM_Release(psw)
COM_Release(psh)
COM_Term()
if(wasfound != 1)
{
GoSub, gogb
}
|
using com_ahk obviously.
Now the funny thing is that it works correctly on my computer, that is to say if the Window I'm looking for was found then it activates that window, and if it doesn't it goes to the sub gogb which basically starts up IE and loads a site.
Great, but when I put it on someone else's computer it always goes to the sub.
The value of the url is in an ini file, but it is the same value between the two computers.
wondering if anyone has encountered a problem like this before and what the solution was? |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Fri Jun 06, 2008 10:06 am Post subject: |
|
|
Your "Loop" doesn't loop, it only checks the first window
| Code: | COM_Init()
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
{
pwb := COM_Invoke(psw, "Item", A_Index-1)
locationname := COM_Invoke(pwb, "LocationName")
IfInString,locationname,%gbssite%
{
uid := COM_Invoke(pwb, "hWnd")
WinActivate, ahk_id %uid%
COM_Release(pwb) ; Don't forget to release the pwb
GoSub, gogb
Break
}
else
COM_Release(pwb)
}
; falls thru at the end of the loop to the CleanupCOM subroutine
CleanupCOM:
COM_Release(psw)
COM_Release(psh)
COM_Term()
Return |
disclaimer: not tested
HTH |
|
| 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
|