AutoHotkey Community

It is currently May 27th, 2012, 9:11 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: January 19th, 2009, 3:41 am 
Offline

Joined: January 19th, 2009, 3:31 am
Posts: 2
I found that every time when I run a AHK script, my TweakUI setting of "Prevent applications from stealing focus" will be reset.

http://www.autohotkey.com/forum/topic4632.html
this page says that is by designed, but this feature is annoying to me :(
I have tried the solving method by calling Tweakui, but that is not very convenient to call tweakui in every AHK script.
Is there any way to prevent AHK reset the setting?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2009, 3:47 am 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
In the post you linked, Chris also proposed a solution:
Quote:
The program makes the following call:
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, SPIF_SENDCHANGE)

The above could also be called inside the script via DllCall to undo the change. In that case, I think you would pass a non-zero timeout value (perhaps the one from the registry) in place of the second zero.

Otherwise, short of changing the source code and compiling AHK yourself, I don't know what else you can do.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2009, 4:08 am 
Offline

Joined: January 19th, 2009, 3:31 am
Posts: 2
I have tried to add this line in my script, but it didn't work to me.
Code:
dllcall("SystemParametersInfo", SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, SPIF_SENDCHANGE)


Is that right?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2009, 4:15 am 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
Try it again using the actual values of the constants:
SPI_SETFOREGROUNDLOCKTIMEOUT = 8193
SPIF_SENDCHANGE = 2
Edit: You also have to use the specify the argument types. See DllCall for more info.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2010, 2:42 pm 
Offline

Joined: March 24th, 2010, 2:04 pm
Posts: 1
Hi,

this "stealing focus" AutoFunction in AutoHotkey is terrible. Although I know it's necessary I'm getting crazy always loosing my focused windows while I'm working in them. Even every reload of the script again resets the focus.

It's somehow like those big applications (we all know them) doing things automatically you don't want. I don't like that. At least there should be a function in AutoHotkey to enable/disable this behavior. There are cases when you don't really need this "WinActivate"-basics.

And of course, at the end AutoHotkey should reset SETFOREGROUNDLOCKTIMEOUT to the state before (automatically or manually). Is there any (hidden) function I missed?

Anyway, for the workaround I'm trying to reset it by DllCall. But it doesn't work (verified and resetted by TweakUI). So, what am I doing wrong?


Code:
SPI_SETFOREGROUNDLOCKTIMEOUT = 8193
SPIF_UPDATEINIFILE = 1
SPIF_SENDCHANGE = 2

DllCall("SystemParametersInfo", "UInt", 8193, "UInt", 0, "UInt", 0, "UInt", SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)


Btw: I love AutoHotkey. A big thanx to the coders, scripters and all the other helpful people around here! :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2011, 6:31 pm 
Anyone found the correct format for this function? Thx in advance


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2011, 7:37 pm 
Ok, this works:

Code:
ForegroundLockTimeoutValue = 200000
SPI_SETFOREGROUNDLOCKTIMEOUT = 8193
SPIF_UPDATEINIFILE = 1
SPIF_SENDCHANGE = 2

DllCall("SystemParametersInfo", "UInt", SPI_SETFOREGROUNDLOCKTIMEOUT, "UInt", 0, "UInt", ForegroundLockTimeoutValue, "UInt", SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2011, 11:21 am 
Offline

Joined: February 9th, 2006, 8:36 pm
Posts: 339
Why is it still enabled?
Such window behavior is dangerous.
It should be off by default or at least configurable.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher and 71 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