按钮中多段文字切换.ahk

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=74948
#NoEnv
#Warn
#SingleInstance, Force

Gui, -DPIScale
s := 11,  DPI := A_ScreenDPI 
Gui, Font, % "s" . s-( DPI<=96 ? 0 : DPI<=120 ? 1 : DPI<=144 ? 2 : 3), Calibri
Gui, Margin, 25, 15

Gui, Add, Text,   xm ym  w175 h30 0x200, SetBatchLines
Gui, Add, Text,   xm     wp   h30 0x200, DetectHiddenWindows
Gui, Add, Text,   xm     wp   h30 0x200, Process priority

Gui, Add, Button, x+10  ym w75  h30   gSubRoutine, % T1 := ""
Gui, Add, Button, wp hp               gSubRoutine, % T2 := "Off"
Gui, Add, Button, wp hp    w140       gSubRoutine, % T3 := "Normal"

Gui, Add, Text,   xm                , Use Alt+Arrow key to adjust the size of edit control    
Gui, Add, Edit,   xm       w325 h120, Hello world!                               
Gui, Show,, NotStr() Demo 
T4 := "", T5 := ""
Return

SubRoutine:
GuiControlGet, Button, Focus

  Switch (Button) 
  {
    case "Button1" : 
      {
        GuiControl,,Button1, % T1 := NotStr(T1, "-1")
        SetBatchLines, %T1%
      }  
    case "Button2" : 
      {
        GuiControl,,Button2, % T2 := NotStr(T2, "On|Off")
        DetectHiddenWindows, %T2%
      }
    case "Button3" : 
      {
        GuiControl,,Button3, % T3 := NotStr(T3, "Low BelowNormal Normal AboveNormal High", " ")
        Process,Priority,, %T3%
      }   
  }
Return

EditWidth:
  Switch (A_ThisHotkey) 
  {
    Case "!Right" : GuiControl,Move,Edit1, % T4 := NotStr(T4, "w425 w525 w625 w700 w900 w325", " ")
    Case "!Left"  : GuiControl,Move,Edit1, % T4 := NotStr(T4, "w900 w700 w625 w525 w425 w325", " ")      
    Case "!Up"    : GuiControl,Move,Edit1, % T5 := NotStr(T5, "h180 h240 h320 h480 h120", " ")
    case "!Down"  : GuiControl,Move,Edit1, % T5 := NotStr(T5, "h480 h320 h240 h180 h120", " ")
  }
  Gui, Show, Center AutoSize
Return

#IfWinActive NotStr() Demo ahk_class AutoHotkeyGUI
  !Right:: GoSub, EditWidth
  !Left::  GoSub, EditWidth
  !Up::    GoSub, EditWidth
  !Down::  GoSub, EditWidth
#IfWinActive

NotStr(S:="", Z:="", D:="|") {               ; NotStr v0.6b By SKAN on D34M/D34R @ tiny.cc/notstr
Local Q, LS:=StrLen(S), LZ:=StrLen(Z), LD:=StrLen(D), P1, P2, Q
Return SubStr(LZ?Z:1,(P1:=LS+LZ=0||S=Z?1:InStr(Z,(S)(D),0,0-LZ+LS+LD)?LS+LD+1:InStr(Z,(D)(S),0,LZ
   -LS)?1:(Q:=InStr(Z,(D)(S)(D)))?Q+LD+LS+LD:1),(LS+LZ=0?2:S=Z?1:(Q:=InStr(Z,D,0,P1))?Q:LZ+1)-P1)
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。