Skip to content

Instantly share code, notes, and snippets.

@Pandahisham
Forked from nshakin/CustomMsgBox.ahk
Created October 7, 2015 14:51
Show Gist options
  • Save Pandahisham/b372d7774c272e2300dd to your computer and use it in GitHub Desktop.
Save Pandahisham/b372d7774c272e2300dd to your computer and use it in GitHub Desktop.
AutoHotKey
CustomMsgBox(Title,Message,Font="",FontOptions="",WindowColor="")
{
Gui,66:Destroy
Gui,66:Color,%WindowColor%
Gui,66:Font,%FontOptions%,%Font%
Gui,66:Add,Text,,%Message%
Gui,66:Font
GuiControlGet,Text,66:Pos,Static1
Gui,66:Add,Button,% "Default y+10 w75 g66OK xp+" (TextW / 2) - 38 ,OK
Gui,66:-MinimizeBox
Gui,66:-MaximizeBox
SoundPlay,*-1
Gui,66:Show,,%Title%
Gui,66:+LastFound
WinWaitClose
Gui,66:Destroy
return
66OK:
Gui,66:Destroy
return
}
CustomSelectBox(Title,Message,Strings)
{
Gui,55:Add,Text,,%Message%
Gui,55:Add,ListBox,%Size%,%Strings%
GuiControlGet,Box,55:Pos,ListBox1
Gui,55:Add,Button,% "Default g55OK w75 y+10 xp+" (BoxW / 2) - 38,OK
Gui,55:-MinimizeBox
Gui,55:-MaximizeBox
Gui,55:Show,,%Title%
Gui,55:+LastFound
WinWaitClose
Gui,55:Destroy
return Result
55OK:
GuiControlGet,Selected,55:,ListBox1
Result:=Selected
Gui,55:Destroy
return ;This won't end the function, just the g55OK thread.
}
;www.autohotkey.com/board/topic/41575-date-and-time-picker/
#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.
Gui, Add, Text, x10 y15 w60 h20, StartDate:
Gui, Add, DateTime, x+10 y10 wp20 h20 vStartDate Section,
Gui, Add, Text, x10 y55 w70 h20 , StartTime:
Gui, Add, DateTime, x+10 y50 wp hp vStartTime 1, HH:mm:ss ;time
Gui, Add, Button, x10 y90 w60 h20 Default, &OK
Gui, Show, w200 h130, AHK-Scheduler
Return
ButtonOK:
Gui, submit, nohide
FormatTime, StartTime, %StartTime%, HH:mm:ss
FormatTime, StartDate, %StartDate%, dd.MM.yyyy
MsgBox, %StartDate%
MsgBox, %StartTime%
return
Esc::
ButtonCancel/Exit:
GuiClose:
ExitApp
WinFade(WinTitle, Duration, Direction) {
If (Direction = 1) {
FadeState := 0
} else {
FadeState := 255
}
LoopCount := Duration * 100
Loop, % LoopCount {
step := (255/LoopCount) * A_Index
WinSet, Transparent, % FadeState - step, % "AHK Launcher"
Sleep, % LoopCount/10
}
Return
}
WinFadeOut(WinTitle, Duration) {
WinFade(WinTitle, Duration, 0)
Return
}
WinFadeIn(WinTitle, Duration) {
WinFade(WinTitle, Duration, 1)
Return
}
; Get the relative height of the screen in pixels
Rel_ScreenHeight(){
DPI_scale := A_ScreenDPI / 96
return Round( A_ScreenHeight / DPI_scale, 0 )
}
; Get the relative width of the screen in pixels
Rel_ScreenWidth(){
DPI_scale := A_ScreenDPI / 96
return Round( A_ScreenWidth / DPI_scale, 0 )
}
; Searches for Process by name and return "on/off"
ProcessState(name) {
state := "off"
for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process") {
If ( proc.Name = name ) {
state := "on"
}
}
return state
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment