微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

自动热键 AHK 可见倒数计时器,带有选择零击键的选项

如何解决自动热键 AHK 可见倒数计时器,带有选择零击键的选项

这里的绝对初学者,一直在搜索和编译不同的变体,以便在计时器完成时按下按键序列。

如果我修改选项 2 以在计时器达到零时按 Shift+F9 开始/停止 Snagit 录制

尝试了许多不同的组合,但似乎无法让它发挥作用。 一个组合实际上在计时器启动时按下了组合键,而不是在它归零时。

如果我可以让它工作,这意味着我可以只有一个计时器实例来创建许多选项 F10shift+F10F9Shift-F9 等,具体取决于我正在运行什么应用程序。 注意:下面的“或”是我应用的各种更改,而不是最终代码中的内容

据我所知,第 30 行中的选项名称并不重要,它们只是出现在选项列表中???因此,我只是在打开文件选项前添加了“F9”,以便选择正确的第二个选项并进行测试

第 30 行:

Gui,Timer:Add,DropDownList,vtimer_options Choose1 altsubmit x60 y113 w104 gset_option_func,No_option|**F9Open File**]|System Beep|Message Box|Hybernate/Sleep|Shutdown|Start_After_Idle

第 122 行:

opa2:
Send,+{F9} or {+F9} or {+ down}{F9}

opb2:
return

完整脚本:

;https://www.autohotkey.com/boards/viewtopic.PHP?f=6&t=87367&p=403508#p403508
; fstoldr Feb 2021
#NoEnv

rscrn := A_ScreenWidth-300

Gui,Timer:Show,w165 h140 X%rscrn% Y0,Timer
Gui,Timer: +hwndguiId +AlwaysOnTop +ToolWindow 
Gui,Timer:Font,s10,Trebuchet MS                       
;   ===========================================================
Gui,Timer:add,Text,x0 y0 w40 center,Hrs
Gui,x55 y0 w40 center,Min
Gui,x110 y0 w40 center,Sec
;   ===========================================================
Gui,Edit,x0 y16 w55 h20 center ve3
Gui,updown,x0 y16 w55 h20 -VScroll,0
Gui,x55 y16 w55 h20 center ve2
Gui,x55 y16 w55 h20 -VScroll,x110 y16 w55 h20 center ve1,Gui,x110 y16 w55 h20 -VScroll,10
;   ===========================================================
Gui,Button,gstart x0 y41 w80 h22 center vbStart,Re/Start
bStart_TT := "start countdown timer"
Gui,gresume x80 y41 w85 h22 center vbPause,P/Resume
bPause_TT := "pause or resume countdown timer"
;   ===========================================================
Gui,text,vTIdle x1 y105 w58 gopa7,00:00:00     
Tidle_TT := "PC idle time before auto countdown - 0 to disable"
Gui,vTStart x1 y120 w58 gSTTTT,TStart_TT := "This is the time the timer last started."  
;   ===========================================================   
Gui,No_option|F9Open File|System Beep|Message Box|Hybernate/Sleep|Shutdown|Start_After_Idle
timer_options_TT := "Select action to take."
;   ===========================================================
Gui,s26 cBlue,Segoe UI
Gui,x0 y62 w169 h38 center vdispt gresume,C/D Timer
dispt_TT := "Time remaining on countdown"
;   ===========================================================
OnMessage(0x200,"MsMoveTTP")      
OnMessage(0x2A1,"HoverTTP") 
return

MsMoveTTP(wParam,lParam,msg,hwnd)
    {
    static TrackPos
     if (TrackPos = lParam)
     return
    TrackPos := lParam  
    tooltip
    cbSize:=(A_PtrSize+4)*2
    VarSetCapacity(TrkMEvnt,cbSize,0)
    Numput(cbSize,TrkMEvnt,"Uint")
    Numput(3,4,"Uint")
    Numput(hwnd,8,"Ptr")
    Numput(800,A_PtrSize+8,"Uint")
    DllCall("User32.dll\TrackMouseEvent","uint",&TrkMEvnt)
    }
STTTT:
return
HoverTTP()
    {
    tooltip % %A_GuiControl%_TT
    }
return

start:
   Tog:=1
   Gui,Submit,NoHide
   Gui,Segoe UI
   GuiControl,dispt
    e3 := round(e3,3)
    e2 := round(e2,3)
    e1 := round(e1,3)
   secsleft :=  e3*3600+e2*60+e1
   seconds := Format("{:02}",floor(mod(secsleft,60)))       ;entry field
   minutes := Format("{:02}",mod(floor(secsleft/60),60))    
   hours  :=  floor(secsleft/3600)                              
   
   hur := Format("{:02}",floor(abs(secsleft)/3600))           ;display
   min := Format("{:02}",floor(mod(abs(secsleft/60),60)))
   sec := Format("{:02}",floor(mod(abs(secsleft),60)))
   
   GuiControl,Timer:text,dispt,%hur%:%min%:%sec% 
   FormatTime,TimeString,HH:mm:ss               
   GuiControl,TStart,%TimeString%
   SetTimer,CDTimer,1000
return

resume:
  if (hours+minutes+seconds < -1)
    goto start
    else SetTimer,% (Tog:=!Tog) ? "on":"off"
   GuiControl,e3,%hours%
   GuiControl,e2,%minutes%
   GuiControl,e1,%seconds%
   GuiControl,%hur%:%min%:%sec%
return

CDTimer:
   secsleft--
   hur := Format("{:02}",60)))
   GuiControl,%hur%:%min%:%sec%
   secsleft:=floor(secsleft)
   Ifequal,secsleft,0
    {
    Gui,s26 cRed,Segoe UI
    GuiControl,dispt  
    goto  opb%timer_options%
    return
    }
   Else 
      Return
   
set_option_func:
   Gui,NoHide
   goto  opa%timer_options%
opa1:
opb1:
return

opa2:
Send,{+ down}{F9}

opb2:
return
   
opb3:
run %A_WinDir%\Media\alarm01.wav
opa3:
return

opb4:
   msgBox,262144,Timer,Time's Up !
opa4:
return

opb5:
   run,rundll32.exe powrprof.dll`,SetSuspendState Sleep
opa5:
return

opb6:
   run,shutdown.exe /s
opa6:
return

Check4Idle:
;   Gui,NoHide
;tooltip %A_TimeIdle%
if (IdleTCd < 1)
{
settimer Check4Idle,off
return
}
If (A_TimeIdle > IdleTCd*1000)
    {
    SetTimer Check4Idle,Off
    IdleTCd:=0
    goto start
    }
return

opa7: 
   Gui,NoHide
   inputBox,IdleTCd,Idle Time,Please enter minutes for PC to idle before auto countdown. 0 to disable,180,160
    idlhur := Format("{:02}",floor(abs(IdleTCd)/60))
    idlmin := Format("{:02}",floor(mod(abs(IdleTCd),60)))
    idlsec := Format("{:02}",floor(mod(abs(IdleTCd*60),60)))
    IdleTCd := floor(IdleTCd*60)
    SetTimer,Check4Idle,1000
    GuiControl,TIdle,%idlhur%:%idlmin%:%idlsec%
opb7:
return 

TimerGuiClose:
ExitApp

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。