AutoHotkey Community

It is currently May 27th, 2012, 5:07 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: May 5th, 2010, 11:53 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Hi at All,

i have read across the Forum, and it seems as if i am not the
only one the has trouble with not working Hotkeys.

In my case i have put together a Startupscript, that contains
a couple of hotkeys, making life easier under windows.

The thing is these hotkeys stop working after some time.
Sometimes all of them stop working, sometimes only a view ones.

Chat and Forum came up with the solution that sets up a timer,
reloading the script periodically after a given time.
So far this works, but included in my startup script, there is a
function that hides windows to tray-menu on demand.

Reloading the Script means that this windows are going to be
unhidden. and i need to hide them again. I guess you are going
to agree on the fact, that this is not very productive when there
is the need to reload the script every five minutes to keep it
working.

So far i found no solution to get over it.
I hope Chris is going to read this, too
and perhaps knows what to do ?!

OK, thanks for the Moment.
Deep-Silence

BTW:
Using the original AHK
and have Keyboard and mousehook installed in that script


Last edited by Deep-Silence on May 7th, 2010, 8:24 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 9:28 am 
It would help Chris (and anyone else interested) if you would provide a short script that can be used to attempt to duplicate the problem. Do you expect Chris to just start digging through the source code looking for a bug, without more details concerning under what conditions the problem occurs? Obviously this is not a common problem (and may be a function of your particular code), as there would be many complaints about it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 10:15 am 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Hi Guest,

If you would have read the Forum,
it would have come to your Attention, that i am not the only
one with that problem. I would not open up a Thread for no reason,
and since the problem is known, i thought Chris might know
where so search...


Anyway,
Here is a little example where i got that problem, too.
The "Min Application to tray Menu" i have refered to earlier,
is not included. The Hotkeys stop working after a few Minutes.
My assumption is, that there is a problem to keep hook of the MouseWheel, if something like this exists.

HotKeys included:
Shift-Wheelup / Shift-WheelDown -> Control Volume
Shift-MButton -> Mute / Unmute Sound


Thanks,
Deep-Silence




Code:

/*
------------------------------------------------------------------------------------------------------------------------------
     _         _        _____                     _                  ___  ____  ____   __     __    _                         
    / \  _   _| |_ ___ | ____|_  _____  ___ _   _| |_ ___           / _ \/ ___||  _ \  \ \   / /__ | |_   _ _ __ ___   ___   _
   / _ \| | | | __/ _ \|  _| \ \/ / _ \/ __| | | | __/ _ \  _____  | | | \___ \| | | |  \ \ / / _ \| | | | | '_ ` _ \ / _ \ (_)
  / ___ \ |_| | |_ (_) | |___ >  <  __/ (__| |_| | |_  __/ |_____| | |_| |___) | |_| |   \ V / (_) | | |_| | | | | | |  __/  _
 /_/   \_\__,_|\__\___/|_____/_/\_\___|\___|\__,_|\__\___|          \___/|____/|____/     \_/ \___/|_|\__,_|_| |_| |_|\___| (_)
                                                                                                                               
------------------------------------------------------------------------------------------------------------------------------
*/

/*  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Disclaimer:

    I do not foresee any risk in running this script but
    you may run this file "ONLY" at your own risk.

    * * * * * * * * * * * * * * * * * * * * * * * * * * * *

http://www.autohotkey.com/forum/post-61081.html#61081


File Name   : OSD_VOL_Gradient.ahk

Download    : http://file.autohotkey.net/goyyah/Tips-N-Tricks/Gradients/OSD_VOL_Gradient.ahk
SnapShot    : http://file.autohotkey.net/goyyah/Tips-N-Tricks/Gradients/osd_vol_green.png
Post        : http://www.autohotkey.com/forum/viewtopic.php?p=61081#61081

Main Title  : Multimedia Utility
Sub Title   : OSD Volume Control - Gradient

Description :  Just an another OSD Volume Control Display for Windows!
               Written as an demonstration for BITMAP Gradients.
   
               Requires the following file for proper On Screen Display:

               http://file.autohotkey.net/goyyah/Tips-N-Tricks/Gradients/OSD_Green.bmp
                   
Author      : A.N.Suresh Kumar aka "Goyyah"
Email       : arian.suresh@gmail.com

Created     : 2006-03-24
Modified    : 2006-03-24

Version     : 0.50

Scripted in : AutoHotkey Version 1.0.44.00 , www.autohotkey.com
*/

#SingleInstance, Force
#InstallMouseHook
#InstallKeybdHook

#NoTrayIcon

Label_Create_OSD_Vulume_GUI:

IfNotExist, OSD_Green.bmp
 URlDownloadToFile, http://file.autohotkey.net/goyyah/Tips-N-Tricks/Gradients/OSD_Green.bmp, OSD_Green.bmp

Gui, Color, EEAA99
Gui, +Lastfound
WinSet, TransColor, EEAA99 250
Gui, -Caption
Gui, Font, s36 Bold, Verdana
Gui, Add, Text, x0 y10,+
X=25

Loop,25
   {
   Var=Pic%A_Index%
   X+=20
   Gui, Add, Picture, x%X% y10 w12 h50 Hidden Border v%var% , OSD_Green.bmp
   }

Gui, Add, Text, x+10 y10,-


/*
------------------------------------------------------------------------------------------------------------------------------
     _         _        _____                     _                __        ___     _____                __  __ _           
    / \  _   _| |_ ___ | ____|_  _____  ___ _   _| |_ ___          \ \      / (_)_ ___   _| __ __ _ _   _|  \/  (_)_ __    _
   / _ \| | | | __/ _ \|  _| \ \/ / _ \/ __| | | | __/ _ \  _____   \ \ /\ / /| | '_ \| || '__/ _` | | | | |\/| | | '_ \  (_)
  / ___ \ |_| | |_ (_) | |___ >  <  __/ (__| |_| | |_  __/ |_____|   \ V  V / | | | | | || | | (_| | |_| | |  | | | | | |  _
 /_/   \_\__,_|\__\___/|_____/_/\_\___|\___|\__,_|\__\___|            \_/\_/  |_|_| |_|_||_|  \__,_|\__, |_|  |_|_|_| |_| (_)
                                                                                                    |___/                   

------------------------------------------------------------------------------------------------------------------------------
*/


;----------------------------------------------------------
;----------------------------------------------------------
; WinTraymin.ahk
; by Sean
;----------------------------------------------------------
;----------------------------------------------------------
; Adding a trayminned trayicon of hWnd:   WinTraymin(hWnd,0), where 0 can be omitted.
; Removing all trayminned trayicons:   WinTraymin(0,-1).
; Other values than 0 & -1 are reserved for internal use.
;----------------------------------------------------------

;#NoTrayIcon
TrayminOpen:
SetWinDelay, 0
SetFormat, Integer, D
CoordMode, Mouse, Screen
DetectHiddenWindows On
hAHK:=WinExist("ahk_class AutoHotkey ahk_pid " . DllCall("GetCurrentProcessId"))
ShellHook:=DllCall("RegisterWindowMessage","str","SHELLHOOK")
DllCall("RegisterShellHookWindow","Uint",hAHK)
OnExit, TrayminClose
Return


;   Shift + Mbutton, to mute / unmute Mastervolume
+MButton::
Send {Volume_Mute}
Return

+WheelUp::
SetVolume(+7)
Return

+WheelDown::
SetVolume(-7)
Return

UpdateOSD:
 Gui, Show
 SoundGet,Volume,MASTER, VOLUME
 Volume:=Round((Volume/4),0)

 Loop,25
   {
   Var=Pic%A_Index%
   If A_Index <= %Volume%
      GuiControl Show, %Var%
   else
      GuiControl Hide, %Var%
   }

SetTimer, OSD_Volume_Gui_Hide, 1000
Return


SetVolume(Val) {
 SoundGet,Volume,MASTER, VOLUME
 Volume+=%Val%
 If Volume < 4
    Volume = 0
 SoundSet, %Volume%, MASTER, VOLUME
 GoSub, UpdateOSD
Return
}

OSD_Volume_Gui_Hide:
SetTimer, OSD_Volume_Gui_Hide, OFF
Gui, Hide
Return

/*
------------------------------------------------------------------------------------------------------------------------------
  ____                       __        ___     _____                __  __ _           
 |  _ \ _   _ _ __           \ \      / (_)_ ___   _| __ __ _ _   _|  \/  (_)_ __    _
 | |_) | | | | '_ \   _____   \ \ /\ / /| | '_ \| || '__/ _` | | | | |\/| | | '_ \  (_)
 |  _ <| |_| | | | | |_____|   \ V  V / | | | | | || | | (_| | |_| | |  | | | | | |  _
 |_| \_\\__,_|_| |_|            \_/\_/  |_|_| |_|_||_|  \__,_|\__, |_|  |_|_|_| |_| (_)
                                                              |___/                   

------------------------------------------------------------------------------------------------------------------------------
*/

TrayminClose:
DllCall("DeregisterShellHookWindow","Uint",hAHK)
WinTraymin(0,-1)
OnExit
ExitApp

RButton Up::
If   h:=WM_NCHITTEST()
   WinTraymin(h)
Else   Click, % SubStr(A_ThisHotkey,1,1)   ; for hotkey: LButton/MButton/RButton
Return

WM_NCHITTEST()
{
   MouseGetPos, x, y, z
   SendMessage, 0x84, 0, (x&0xFFFF)|(y&0xFFFF)<<16,, ahk_id %z%
   Return   ErrorLevel=8 ? z : ""
}

WM_SHELLHOOKMESSAGE(wParam, lParam, nMsg)
{
   Critical
   If   nMsg=1028
   {
      If   wParam=1028
         Return
      Else If   (lParam=0x201||lParam=0x205||lParam=0x207)
         WinTraymin(wParam,3)
   }
   Else If   (wParam=1||wParam=2)
      WinTraymin(lParam,wParam)
   Return   0
}

WinTraymin(hWnd = "", nFlags = "")
{
   Local   h, ni, fi, uid, pid, hProc, sClass
   Static   nMsg, nIcons:=0
   nMsg ? "" : OnMessage(nMsg:=1028,"WM_SHELLHOOKMESSAGE")
   NumPut(hAHK,NumPut(VarSetCapacity(ni,444,0),ni))
   If Not   nFlags
   {
      If Not   ((hWnd+=0)||hWnd:=DllCall("GetForegroundWindow"))||((h:=DllCall("GetWindow","Uint",hWnd,"Uint",4))&&DllCall("IsWindowVisible","Uint",h)&&!hWnd:=h)||!(VarSetCapacity(sClass,15),DllCall("GetClassNameA","Uint",hWnd,"str",sClass,"Uint",VarSetCapacity(sClass)+1))||sClass=="Shell_TrayWnd"||sClass=="Progman"
      Return
      OnMessage(ShellHook,"")
      WinMinimize,   ahk_id %hWnd%
      WinHide,   ahk_id %hWnd%
      Sleep,   100
      OnMessage(ShellHook,"WM_SHELLHOOKMESSAGE")
      uID:=uID_%hWnd%,uID ? "" : (uID_%hWnd%:=uID:=++nIcons=nMsg ? ++nIcons : nIcons)
      hIcon_%uID% ? "" : (VarSetCapacity(fi,352,0),DllCall("GetWindowThreadProcessId","Uint",hWnd,"UintP",pid),DllCall("psapi\GetModuleFileNameExA","Uint",hProc:=DllCall("kernel32\OpenProcess","Uint",0x410,"int",0,"Uint",pid),"Uint",0,"Uint",&fi+12,"Uint",260),DllCall("kernel32\CloseHandle","Uint",hProc),DllCall("shell32\SHGetFileInfoA","Uint",&fi+12,"Uint",0,"Uint",&fi,"Uint",352,"Uint",0x101),hIcon_%uID%:=NumGet(fi)),DllCall("GetWindowTextA","Uint",hWnd,"Uint",NumPut(hIcon_%uID%,NumPut(nMsg,NumPut(1|2|4,NumPut(uID,ni,8)))),"int",64)
      Return   hWnd_%uID%:=DllCall("shell32\Shell_NotifyIconA","Uint",hWnd_%uID% ? 1 : 0,"Uint",&ni) ? hWnd : DllCall("ShowWindow","Uint",hWnd,"int",5)*0
   }
   Else If   nFlags > 0
   {
      If   (nFlags=3&&uID:=hWnd)
         If   WinExist("ahk_id " . hWnd:=hWnd_%uID%)
         {
            WinShow,   ahk_id %hWnd%
            WinRestore,   ahk_id %hWnd%
         }
         Else   nFlags:=2
      Else   uID:=uID_%hWnd%
      Return   uID ? (hWnd_%uID% ? (DllCall("shell32\Shell_NotifyIconA","Uint",2,"Uint",NumPut(uID,ni,8)-12),hWnd_%uID%:="") : "",nFlags==2&&hIcon_%uID% ? (DllCall("DestroyIcon","Uint",hIcon_%uID%),hIcon_%uID%:="") : "") : ""
   }
   Else
      Loop, % nIcons
         hWnd_%A_Index% ? (DllCall("shell32\Shell_NotifyIconA","Uint",2,"Uint",NumPut(A_Index,ni,8)-12),DllCall("ShowWindow","Uint",hWnd_%A_Index%,"int",5),hWnd_%A_Index%:="") : "",hIcon_%A_Index% ? (DllCall("DestroyIcon","Uint",hIcon_%A_Index%),hIcon_%A_Index%:="") : ""
}





Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 10:30 am 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
I am quite sure this problem is related to modifiers, depending on below setting, modifiers could be in a wrong state and then your hoktey does not work.

Try to put following in top of your script, does it help?

Code:
#HotkeyModifierTimeout -1

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 11:38 am 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Hi HotKeyIt,
hope you are doing well, ;)

I tried your code,
The problem remains the same. Pity!

Thanks,
Deep-Silence


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 7:25 pm 
Offline

Joined: June 17th, 2008, 7:51 am
Posts: 243
I can confirm this behavior. Mostly this happens in context with WheelUp/WheelDown-hotkeys. Unfortunately I don't have a solution. Also have a look to http://www.autohotkey.com/forum/viewtopic.php?t=53016

_________________
Greetings
Rog


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 7:44 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
I will try to use that script and see if I have that problem :)
Btw, you should add NA, looks better because active window does not loose focus ;)
Code:
 Gui, Show, NA

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 7:59 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
ruespe wrote:
I can confirm this behavior. Mostly this happens in context with WheelUp/WheelDown-hotkeys. Unfortunately I don't have a solution. Also have a look to http://www.autohotkey.com/forum/viewtopic.php?t=53016


So, i guess my assumption was not that wrong.
Unfortunatly the Thread did not came up with an working solution without
reloading the script loosing data stored in Variables.

I also tried a SetTimer, that Switches all the Hotkeys off and back on
after a given time. Without Success.

Since there is no workaround on the User-Level, i guess it needs to be fixed on "Hard-Code"-Area.


HotKeyIt wrote:
I will try to use that script and see if I have that problem :)
Btw, you should add NA, looks better because active window does not loose focus ;)
Code:
 Gui, Show, NA


Thanks for that hint,
Please let me know about your try! ;)


That it is for the moment,
Thanks,
Deep-Silence


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: No registered users and 3 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