Messages - jpprater [ switch to compact view ]

Pages: [1] 2 3 4 5 6 ... 16next
1
Developer's Corner / Re: Crazy Autohotkey issue
« on: January 19, 2016, 07:36 AM »
This is the updated LockDetect.ahk.  Changes between this version and the original are on line 46 and the additional constants on lines 29-39.
Code: Autohotkey [Select]
  1. ;---------------------------------------------------------------
  2. ;Notify Lock\Unlock
  3. ;   This script monitors LockWorkstation calls
  4. ;
  5. ;   If a change is detected it 'notifies' the calling script
  6. ;      On Lock
  7. ;         This script will call function "on_lock()"
  8. ;      On Unlock
  9. ;         This script will call fucntion "on_unlock()"
  10. ;IMPORTANT: The functions "on_lock()" and "on_unlock()" DO NOT
  11. ;exist in this script, they are to be created in the script that
  12. ;calls notify_lock_unlock() (presumably your main script)
  13. ;---------------------------------------------------------------
  14. ;Re-purposed by WTO605
  15. ;Last edited 2009-08-18 16:34 UTC
  16. ;---------------------------------------------------------------
  17. ;Based on Winamp_Lock_Pause by MrInferno
  18. ;Posted: Fri Apr 21, 2006 4:49 am
  19. ;Source: http://www.autohotkey.com/forum/topic9384.html
  20. ;---------------------------------------------------------------
  21. ;Winamp_Lock_Pause was/is based on script codes from "shimanov"
  22. ;Posted: Thu Sep 15, 2005 12:26 am  
  23. ;Source: http://www.autohotkey.com/forum/viewtopic.php?t=5359
  24. ;Posted: Tue Dec 06, 2005 9:14 pm
  25. ;Source: http://www.autohotkey.com/forum/viewtopic.php?t=6755
  26. ;---------------------------------------------------------------
  27.  
  28. ;Initialize global constants
  29. WTS_CONSOLE_CONNECT := 0x1
  30. WTS_CONSOLE_DISCONNECT := 0x2
  31. WTS_REMOTE_CONNECT := 0x3
  32. WTS_REMOTE_DISCONNECT := 0x4
  33. WTS_SESSION_LOGON := 0x5
  34. WTS_SESSION_LOGOFF := 0x6
  35. WTS_SESSION_LOCK      :=   0x7
  36. WTS_SESSION_UNLOCK      :=   0x8
  37. NOTIFY_FOR_ALL_SESSIONS   :=   1
  38. NOTIFY_FOR_THIS_SESSION   :=   0
  39. WM_WTSSESSION_CHANGE   :=   0x02B1
  40.  
  41. notify_lock_unlock()
  42. {
  43.    Global WM_WTSSESSION_CHANGE
  44.    Global NOTIFY_FOR_ALL_SESSION
  45.  
  46.    hw_ahk := FindWindowEx( 0, 0, "AutoHotkey", A_ScriptFullPath )
  47.  
  48.    OnMessage( WM_WTSSESSION_CHANGE, "Handle_WTSSESSION_CHANGE" )
  49.  
  50.    success := DllCall( "wtsapi32.dll\WTSRegisterSessionNotification", "uint", hw_ahk, "uint", NOTIFY_FOR_ALL_SESSIONS )
  51.  
  52.    if( ErrorLevel OR ! success )
  53.    {
  54.       success := DllCall( "wtsapi32.dll\WTSUnRegisterSessionNotification", "uint", hw_ahk )
  55.       ;If DLL registration fails, wait 20 seconds and try again
  56.       Sleep, 20000
  57.       notify_lock_unlock()
  58.       ;MsgBox, [WTSRegisterSessionNotification] failed: EL = %ErrorLevel%
  59.    }
  60.    return
  61. }
  62.  
  63. Handle_WTSSESSION_CHANGE( p_w, p_l, p_m, p_hw )
  64. ; p_w  = wParam   ;Session state change event
  65. ; p_l  = lParam   ;Session ID
  66. ; p_m  = Msg   ;WM_WTSSESSION_CHANGE
  67. ; p_hw = hWnd   ;Handle to Window
  68. {
  69.    Global WTS_SESSION_LOCK
  70.    Global WTS_SESSION_UNLOCK
  71.    Global WTS_SESSION_LOGON
  72.    Global WTS_SESSION_LOGOFF
  73.  
  74.    If ( p_w = WTS_SESSION_LOCK )
  75.    {
  76.       on_lock()
  77.    }
  78.    Else If ( p_w = WTS_SESSION_UNLOCK )
  79.    {
  80.       on_unlock()
  81.    }
  82.    Else If (p_w = WTS_SESSION_LOGON)
  83.    {
  84.       on_logon()
  85.    }
  86.    Else If (p_w = WTS_SESSION_LOGOFF)
  87.    {
  88.       on_logoff()
  89.    }
  90. }
  91.  
  92. FindWindowEx( p_hw_parent, p_hw_child, p_class, p_title )
  93. {
  94.    return, DllCall( "FindWindowEx", "uint", p_hw_parent, "uint", p_hw_child, "str", p_class, "str", p_title )
  95. }

2
Developer's Corner / Re: Crazy Autohotkey issue
« on: January 18, 2016, 08:48 AM »
This code right here in LockDetect.ahk:
Code: Autohotkey [Select]
  1. hw_ahk := FindWindowEx( 0, 0, "AutoHotkey", a_ScriptFullPath " - AutoHotkey v" a_AhkVersion )
This had to be changed to accurately reflect the title of the compiled script's window.
I don't have the code available to me just now, but I'll post it tomorrow.  If you compile the script yourself and try to run it, and then open the script's window, you'll see what the proper title to match is.

3
Sorry about the delayed response.  :-[
The bug:  When LBC is running, it steals focus from other open windows.  This only seems to happen when an LBC dock is set to "Always on Top" mode.
How to reproduce:
  • Create a dock in LBC.
  • Right-click and select "Configure Preferences and Options"
  • Go to Options
  • Enable the option to keep launchbars on top
  • Click the X in the top right.  The bar will reload.
  • Switch to another window
  • LBC will steal the focus from the active window, whatever that window is, within 5-10 seconds

4
You're welcome!  8)

5
Looks like this problem has been around for a while, based on previous forum posts, and it's still around in the latest version.  Turning off "Keep LaunchBars On Top" seems to fix it.  Is that the only solution, or is there something else that can be done?

Pages: [1] 2 3 4 5 6 ... 16next
Go to full version