I thought I could paste different scripts I find on the internet into one big script if I separated them (with return), however the second part doesn't appear to work despite it being fine when in a separate script. I wracked my head searching but I'm still not sure where it's going wrong. The only noticable change I've made to try to fix it is moving the Admin command from the last script to the top.
Anyone care to help me out? Tips for future merging would be appreciate too!
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#singleinstance, force
; run script as admin (reload if not as admin)
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
ExitApp
}
;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;NUMPAD > MEDIA CONTROLS
;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;https://www.autohotkey.com/boards/viewtopic.php?t=83382
ChangeBrightness(0)
; Variables
Increments := 5 ; < lower for a more granular change, higher for larger jump in brightness
CurrentBrightness := GetCurrentBrightNess()
; Hot Keys
NumpadUp::ChangeBrightness( CurrentBrightness -= Increments ) ; decrease brightness
NumpadPgUp::ChangeBrightness( CurrentBrightness += Increments ) ; increase brightness
; Functions
ChangeBrightness( ByRef brightness, timeout = 0.5 )
{
if ( brightness > 0 && brightness < 100 )
{
For property in ComObjGet( "winmgmts:\\.\root\WMI" ).ExecQuery( "SELECT * FROM WmiMonitorBrightnessMethods" )
property.WmiSetBrightness( timeout, brightness )
}
else if ( brightness >= 100 )
{
brightness := 100
}
else if ( brightness <= 0 )
{
brightness := 0
}
}
GetCurrentBrightNess()
{
For property in ComObjGet( "winmgmts:\\.\root\WMI" ).ExecQuery( "SELECT * FROM WmiMonitorBrightness" )
currentBrightness := property.CurrentBrightness
return currentBrightness
}
ChangeBrightness(0)
return
;----------------------
#Persistent
#SingleInstance Force
SetTitleMatchMode, 2
return
NumpadEnd::Volume_Mute
return
NumpadDown::Volume_Down
return
NumpadPgDn::Volume_Up
return
NumpadLeft::Media_Prev
return
NumpadClear::Media_Play_Pause
return
NumpadRight::Media_Next
return
;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;CTRL + CAPS LOCK > CHANGE SENTENCE CASE
;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; https://github.com/GorvGoyl/Autohotkey-Scripts-Windows/blob/master/ctrl_caps_as_case_change.ahk
; ctrl+capslock to show text case change menu
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
SetTitleMatchMode 2
GroupAdd All
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Fix Linebreaks, CCase
Menu Case, Add, &Reverse, CCase
^CapsLock::
GetText(TempText)
If NOT ERRORLEVEL
Menu Case, Show
Return
CCase:
If (A_ThisMenuItemPos = 1)
StringUpper, TempText, TempText
Else If (A_ThisMenuItemPos = 2)
StringLower, TempText, TempText
Else If (A_ThisMenuItemPos = 3)
StringLower, TempText, TempText, T
Else If (A_ThisMenuItemPos = 4)
{
StringLower, TempText, TempText
TempText := RegExReplace(TempText, "((?:^|[.!?]\s+)[a-z])", "$u1")
} ;Seperator, no 5
Else If (A_ThisMenuItemPos = 6)
{
TempText := RegExReplace(TempText, "\R", "`r`n")
}
Else If (A_ThisMenuItemPos = 7)
{
Temp2 =
StringReplace, TempText, TempText, `r`n, % Chr(29), All
Loop Parse, TempText
Temp2 := A_LoopField . Temp2
StringReplace, TempText, Temp2, % Chr(29), `r`n, All
}
PutText(TempText)
Return
; Handy function.
; Copies the selected text to a variable while preserving the clipboard.
GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^c
ClipWait 0.5
If ERRORLEVEL
{
Clipboard := SavedClip
MyText =
Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}
; Pastes text from a variable while preserving the clipboard.
PutText(MyText)
{
SavedClip := ClipboardAll
Clipboard = ; For better compatability
Sleep 20 ; with Clipboard History
Clipboard := MyText
Send ^v
Sleep 100
Clipboard := SavedClip
Return
}
return