;https://autohotkey.com/board/topic/79357-how-to-add-action-to-a-button/
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; create the gui:
Gui, +AlwaysOnTop
gui, add, button, x50 y5 h20 w300 gGuiclose, 1-Hide Gui
gui, add, button, x50 y35 h20 w300 gExplorerCycle, 2-Cycle through Explorer tabs
gui, add, button, x50 y65 h20 w300 gDateLong, 3-Date long format
gui, add, button, x50 y95 h20 w300 gDate4File, 4-Date YYYmmdd for file
gui, add, button, x50 y125 h20 w300 gDate4Time,5- Date & Time
gui, add, button, x50 y155 h20 w300 gUrlButton, 6-Make a button html for URL
gui, add, button, x50 y185 h20 w300 gUrlHtml, 7-Make html string for URL
gui, add, button, x50 y215 h20 w300 gUrlBase, 8-Make html from slected text
gui, add, button, x50 y245 h20 w300 gOpenTabs, 9-Open URL Tabs
gui, add, button, x50 y275 h20 w300 gexit, x-Exit Script
OnMessage(0x200, "Help")
;gui, show, w200
return
;when creating the subroutine remember to leave off the g.[/color] [color=#008000] OpenTabs|ExplorerCycle|DateLong|Date4File|Date4Time|UrlButton|UrlHtml|UrlBase
;-------------Hotkeys-----------
^!d:: ;ctrl+alt+d drakemax@hotmail.com
{ SendInput drakemax@hotmail.com
Return
}
`::Enter ;remap Tilda key to Enter
{
Return
}
::hw::Hello World
Return
:*:rx::Expand this text RIGHT AWAY please, AutoHotkey.
Return
^!r::
; :?*:asdkffasd::
SoundBeep, 500,500
MsgBox, String asdkffasd has been scanned
Return
;-------------GUI----------
; Press F1 to show the gui:
F1::
{
CoordMode, Mouse, Screen
MouseMove, 40, 50, 0
Gui, Show, x0 y50 w400, Tasks
return
}
Help(wParam, lParam, Msg) { ;Tooltips
MouseGetPos,,,, OutputVarControl
IfEqual, OutputVarControl, Button1
Help := "Hide programme, use F1 to unhide"
else IfEqual, OutputVarControl, Button2
Help := "Cycle through all open Explorer tabs, starts with latest/last"
else IfEqual, OutputVarControl, Button3
Help := "Date long format in text area"
else IfEqual, OutputVarControl, Button4
Help := "Date YYYmmdd for file when renaming file youi can put date in"
else IfEqual, OutputVarControl, Button5
Help := "Date & Time in text field"
else IfEqual, OutputVarControl, Button6
Help := "Make a button html for URL"
else IfEqual, OutputVarControl, Button7
Help := "Make html string for URL"
else IfEqual, OutputVarControl, Button8
Help := "Make html from slected text"
else IfEqual, OutputVarControl, Button9
Help := "Open web page tabs in FF "
else IfEqual, OutputVarControl, Button10
Help := "Exit programme"
ToolTip % Help
}
{#IfWinExist, Tasks
1::ControlClick, Button1
2::ControlClick, Button2
3::ControlClick, Button3
4::ControlClick, Button4
5::ControlClick, Button5
6::ControlClick, Button6
7::ControlClick, Button7
8::ControlClick, Button8
9::ControlClick, Button9
x::ControlClick, Button10
#IfWinExist
}
Action:
Gui, Submit ; or
; Gui, Submit, NoHide ; if you don't want to hide the gui-window after an action
Guiclose:
{if WinExist("Tasks")
WinHide
Return
}
ExplorerCycle:
; Cycles through Explorer tabs,starts on latest
{
; This is a script that will always go to The last explorer window you had open.
; If explorer is already active, it will go to the NEXT last Explorer window you had open.
; CTRL Numpad2 is pressed with a single button stoke from my logitech G15 keyboard -- Macro key 17.
; from vid https://www.youtube.com/watch?v=OqyQABySV8k
IfWinNotExist, ahk_class CabinetWClass
Run, explorer.exe
GroupAdd, taranexplorers, ahk_class CabinetWClass
if WinActive("ahk_exe explorer.exe")
GroupActivate, taranexplorers, r
else
WinActivate ahk_class CabinetWClass ;you have to use WinActivatebottom if you didn't create a window group.
Return
}
DateLong:
{
FormatTime, CurrentDateTime,,dddd,MMMM d, yyyy
SendInput, %CurrentDateTime% `n ; current date formats long format
if WinExist("Tasks")
Return
}
Date4File:
; current date formats yyyymmdd (good for file naming)
{
FormatTime, CurrentDateTime,,yyyMMdd
SendInput, %CurrentDateTime% `n ; current date formats yyy-mm-dd
if WinExist("Tasks")
WinHide
Return
}
Date4Time:
{
; current date/time formats yyy-mm-dd & Time in AM/PM
FormatTime, CurrentDateTime,,yyy-MM-dd h:mm tt
SendInput, %CurrentDateTime% `n ; current date/time formats yyy-mm-dd & Time in AM/PM
if WinExist("Tasks")
WinHide
Return
}
UrlButton:
;Button-Be in Text area Put a new URL in box (OK) Put a Word/String for what you want to read (OK)
{ Sleep, 100
InputBox, UrlLink, "New Link", "Put a new URL in box ""
InputBox, Texty, "New Text", "Put a Word/String for what you want to read"
Sleep, 50
clipurl := " %Texty%
if WinExist("Tasks")
WinHide
Return
}
UrlHtml:
{
;Alt+1 Popup for URL, paste then OK, then Popup for Title, add then OK and it will write out html string in text app/field
Sleep, 100
InputBox, UrlLink, "New Link", "Put a new URL in box ""
InputBox, Texty, "New Text", "Put a Word/String for what you want to read"
;nTab:= ""target="_blank"""
Sleep, 50
clipurl := "" Texty ""
SendInput {Raw}%clipurl%
if WinExist("Tasks")
WinHide
Return
}
UrlBase:
{
; First copy URL, it goes to clipboard- Next Select text you want to make the link to & then Alt+2
Sleep, 100
clipurl := clipboard ; This takes URL from clipbd and assigns to var
Send, ^c ; This copies the selected/highlighted text in the doc, again to clipboard (so overwrites the URL)
Sleep, 50
;clipurla := "" . clipboard . ""
clipurla := "" clipboard ""
SendInput {Raw}%clipurla%
clipboard := clipurl
clipurl =;
if WinExist("Tasks")
WinHide
Return
}
OpenTabs:
{ IfWinExist, ahk_exe firefox.exe
{ WinActivate
Run, % "firefox.exe https://www.autohotkey.com/ -new-tab"
sleep, 100
Run, % "firefox.exe https://www.quickaccesspopup.com/ -new-tab"
sleep, 100
Run, % "firefox.exe https://www.macrocreator.com/ -new-tab"
sleep, 100
Run, % "firefox.exe https://github.com/UnBOlievable/Pie-Menu-AHK -new-tab"
sleep, 100
Run, % "firefox.exe http://capture2text.sourceforge.net/ -new-tab"
sleep, 100
Run, % "firefox.exe https://gist.github.com/endolith/876629 -new-tab"
sleep, 100
Run, % "firefox.exe https://github.com/ahkscript/awesome-AutoHotkey -new-tab"
sleep, 100
Run, % "firefox.exe https://github.com/deadlydog/AHKCommandPicker -new-tab"
} else Run, C:\Program Files\Mozilla Firefox\firefox.exe, C:\Users\drake\Downloads
if WinExist("Tasks")
WinHide
return
}
exit:
{
exitapp
}
return