AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

com based windows activate different between computers

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
pantagruel



Joined: 08 Oct 2006
Posts: 67
Location: denmark

PostPosted: Fri Jun 06, 2008 8:26 am    Post subject: com based windows activate different between computers Reply with quote

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
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Fri Jun 06, 2008 10:06 am    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group