It is currently Thu Jun 20, 2013 6:26 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Close FireFox tab
PostPosted: Wed Mar 21, 2012 9:10 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Mar 27, 2009 9:41 am
Posts: 333
Location: Athens, Greece
Is there a way to close programmatically only one tab in Firefox?
I tried
Code:
PostMessage_(GetForegroundWindow_(), #WM_CLOSE, 1, 0)
and
Code:
SendMessage_(GetForegroundWindow_(), #WM_SYSCOMMAND, #SC_CLOSE, 0)
but in every case closes the whole firefox and not only the active tab.

_________________
http://kc2000labs.shadowtavern.com/pb/pb_eng.htm


Top
 Profile  
 
 Post subject: Re: Close FireFox tab
PostPosted: Thu Mar 22, 2012 9:00 am 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1480
From my own quick tests, it seems Firefox ignores messages, which is probably why it doesn't respond.

You can force it with a virtual Ctrl+W keystroke like this, but it's Windows-only and a bad hack:

Code:
keybd_event_(#VK_CONTROL,0,0,0)
keybd_event_(#VK_W,0,0,0)
keybd_event_(#VK_W,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0)

_________________
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!


Top
 Profile  
 
 Post subject: Re: Close FireFox tab
PostPosted: Thu Mar 22, 2012 11:26 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Mar 27, 2009 9:41 am
Posts: 333
Location: Athens, Greece
I am interested only for Windows (for now). Is this working on Chrome too?

_________________
http://kc2000labs.shadowtavern.com/pb/pb_eng.htm


Top
 Profile  
 
 Post subject: Re: Close FireFox tab
PostPosted: Thu Mar 22, 2012 12:27 pm 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1480
If it uses the same shortcut (Ctrl+W), then yes. If not, change the code to whatever shortcut Chrome uses to close a tab.

_________________
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!


Top
 Profile  
 
 Post subject: Re: Close FireFox tab
PostPosted: Thu Mar 22, 2012 1:25 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Mar 27, 2009 9:41 am
Posts: 333
Location: Athens, Greece
Works fine with Chrome. Thanx a lot!!

_________________
http://kc2000labs.shadowtavern.com/pb/pb_eng.htm


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye