AutoHotkey Community

It is currently May 25th, 2012, 7:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: February 15th, 2005, 6:07 pm 
Hi people,
I want to close Opera 8 (http://www.opera.com) using a Autohotkey script. First i tried
Code:
taskkill /im opera.exe

but this doesn't work well since if there are multiple windows open, only one of them is closed. If I used it in a loop, this wouldn't work well, since I want Opera to remember all pages from this session the next time it starts up.
I also tried
Code:
taskkill /f /im opera.exe

but this kills Opera without letting it save the open windows etc.
I tried
Code:
ControlSend, , ^q, Opera

to send Opera the close hotkey (Ctrl+Q), but it didn't work either. (Previously, I did also SetTitleMatchMode, 2)
Has anyone any ideas how to close Opera cleanly?

Thanks (and thanks to the Autohotkey maintainer for the program!)!
Piet


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 6:09 pm 
Opera also doesn't have any command line args to close it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 6:37 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
You could use PostMessage or WinKill


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 7:21 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
WinClose is equivalent to pressing a program's X button in the top right. If that's not what you want it to do, though, you could see if it's a menu item and then select it using WinMenuSelectItem.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 7:52 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Actually, WinClose isn't quite the same as the X button. The X button usually produces an SC_CLOSE message (similar to Alt-F4), while WinClose sends WM_CLOSE to the window, which is a littler harsher.

Here is the way that is closest to Alt-F4:
PostMessage, 0x112, 0xF060,,, WinTitle, WinText ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 8:34 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Ah, that's right. Dang, I should know that, too, because I just researched that a little while ago for the KDE script. :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 8:50 pm 
Offline

Joined: February 15th, 2005, 8:38 pm
Posts: 5
Thanks for the quick replies! Unfortunately, none of your proposes worked for me :(
WinClose, WinKill and PostMessage with the proposed parameters only close one window if multiple browser windows are open.
WinMenuSelectItem didnt work either, as Opera seems to have non-standard menus. Although it would have been nice, I think I can also close Opera manually.
Maybe I'll try ControlSend again...
But thanks again
Piet


Last edited by piet on February 15th, 2005, 9:23 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 8:59 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Have you tried a loop with IfWinExist and WinClose? If one string matches all browser windows (like " - Opera" or something), that should close them all.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 9:22 pm 
If I used a loop to close one window at a time, then at the next start Opera would only reopen the last closed window. Instead, if I exit Opera with Ctrl-Q (corresponds to File/Exit), the next time Opera will automatically open all the windows opened during the last session.
But when I tried ControlSend to send Ctrl-Q, it didnt work :(


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 9:44 pm 
Offline

Joined: November 6th, 2004, 11:03 am
Posts: 170
Location: Salt Lake City, UT
Did you try to ControlSend to the active window, or to a control in the window?
Code:
ControlSend, Edit1, ^Q

is different than
Code:
ControlSend, , ^Q

unless Edit1 is the topmost control of the window.

It seems odd to me that a key like CTRL+Q wouldn't send properly via AHK.
Did you try:
Code:
Send, ^Q


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2005, 11:28 pm 
Offline

Joined: February 15th, 2005, 8:38 pm
Posts: 5
Code:
ControlSend, OperaWindowClass16, ^q, Opera

made it work. Previously, I omitted the second parameter, but it seems to be needed.
Thanks for your help
Piet


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2005, 2:57 am 
Offline

Joined: December 28th, 2004, 12:33 am
Posts: 60
Just a thought, Opera handles tabbed windows very well... if you try it you'll never go back ).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: billym, bobbysoon, Ohnitiel, Pulover, sarevok9, tic, toddintr and 22 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group