New AutoHotkey Script Template

Talk about anything
User avatar
joedf
Posts: 8975
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: New AutoHotkey Script Template

13 Mar 2016, 13:34

Hhaha yeah ;)
No problem
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
lexikos
Posts: 9609
Joined: 30 Sep 2013, 04:07
Contact:

Re: New AutoHotkey Script Template

13 Mar 2016, 21:29

derz00 wrote::P Does Microsoft like that? :D :lol: Really what are they afraid of, not letting you have ownership? :roll:
Microsoft has nothing to do with it, except for following sensible security policies (in this case). If you are not an administrator, you are not permitted to write files in system folders or Program Files. The AutoHotkey installer created the file just fine - because it had administrative privileges. You just need to run your text editor as admin to edit it (or you can create the file elsewhere and drag-drop; Explorer will ask you to confirm).
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: New AutoHotkey Script Template

14 Mar 2016, 09:18

Notepad++ has a useful plugin that I often use:
Save as admin

This plugin allows you to save any file as administrator.
Just press "Save" in Notepad++ and if you are not allowed to change this file as user, Notepad++ will save it as administrator.
Windows XP, Windows 7 and Windows Vista are supported.
Author: Khnykin Evgeniy
lexikos
Posts: 9609
Joined: 30 Sep 2013, 04:07
Contact:

Re: New AutoHotkey Script Template

14 Mar 2016, 20:02

@TheDewd: Even if you don't have the plugin, stock Notepad++ 6.9 prompts to elevate if needed:
---------------------------
Save failed
---------------------------
The file cannot be saved and it may be protected.
Do you want to launch Notepad++ in Administrator mode?
---------------------------
Yes No
---------------------------
I suppose with the plugin, Notepad++ would not remain running as admin after the file is saved.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: New AutoHotkey Script Template

20 Mar 2016, 04:22

I couldn't stand having all that stuff on a new script. :? I need a blank canvas to start working.

Code: Select all

#singleInstance force
#persistent
#include <Lib_1>

Lib_1 takes care of my defaults.

Code: Select all

#noEnv
settings:=a_programFiles "\Masonjar13"
if(!fileExist(settings))
    fileCreateDir,% settings
sini:=settings "\settings.ini"
coordMode,pixel,screen
coordMode,mouse,screen
sendMode input
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
HinkerLoden
Posts: 93
Joined: 23 Mar 2016, 07:50
Contact:

Re: New AutoHotkey Script Template

09 Apr 2016, 11:02

Not thought that something like that stands in the OFFTOPIC :shock:

:SCRATCHINGBALLS: ( ! tHATS OFFTOPIC ! ) :mrgreen:

Nevermind. I am in progress to create 3 different Templates .

1.) General - Save Settings - description to some settings - Beginner Friendly.
2.) Performance - Speed Settings - possible unstable but fast setting and more AHK specific Commands are listed and explained
3.) Gui Variant - Save SEttings but some Gui Elements are integreated - This is more a Root-DataSheet for the Upcoming Tutorials i want to write.

First additional. OS and Versionsinfo. Not thought it is so important.

Code: Select all

;************************************************
; AHK _ SCRIPT STRUCTURE TEMPLATE v1.0
; by HinkerLoden
; 25/03/2016 
; OS  			--> 	Win 10 / etc. 
;AHK Version	-->		1.1.23.05 
;************************************************

;************************************************
;Script Global Settings
;************************************************

#NoEnv						; Clear All Systemvariables 
#Persistent 				;Keeps a script permanently running until ExitApp execute

#SingleInstance force		;The word FORCE skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.

;************************************************
;Performance PARAMETERS - if you need speed 
;************************************************
;SetBatchLines, -1   		
;Process, Priority, , L  ;A  - Max Speed
;************************************************
; Input PARAMETERS
;************************************************
SendMode Input					;Default = Event , Play - for Speed -> Set Keydelay to -1 & Setmousedely to -1 
;----
SetKeyDelay, 10, 10   			; for speed -1, -1, 
SetMouseDelay, 25				;0 recommend   /  -1 for max speed 
SetDefaultMouseSpeed, 0			;0-100 
;************************************************
;History Protocols 
;Switch setting for more Speed 
;************************************************
#KeyHistory 1					;  0 - No Keyhistory 
ListLines  On  					; Off  - for more speed 
;************************************************
;Window detection
;************************************************
SetTitleMatchMode, 2
SetTitleMatchMode Fast			;slow detect hidden windows

SetWinDelay, 200  				;0 - for more speed 
;DetectHiddenWindows, On		; | Off   
;i double the standard settings to be on the save side 
;#######################				#######################
; Script Parameter
;#######################				#######################

SetWorkingDir %A_ScriptDir%  	;Ensures a consistent starting directory.

;#Include %A_ScriptDir%\YourLibrarys2integrate.ahk

CoordMode, Pixel, Screen		;relative/Window - active Window
CoordMode, Mouse, Screen

;WinMinimizeAll					;Optional

;#######################				#######################
; Try to avoid pure numbers inside the code - adress all Vars here
;=============================================================
; 						Variable Section
;=============================================================
;#######################				#######################
;global / static
;EnvUpdate ; --> Notifies the OS and all running applications that environment variable(s) have changed. 
;#######################				#######################

;===============================  TimerVars
Variable_01	=	
Variable_02	=	
Variable_03	=	
Variable_04	=	
Variable_05	=	
Variable_06	=	
Variable_07	=	
Variable_08	=	
Variable_09	=	
Variable_10	=	
;#######################				#######################
;=============================================================
; 						CODE 
;=============================================================
;#######################				#######################

 
 
;=============================================================
; 						GUI 
;=============================================================
;=============================================================

;#######################				#######################

;=============================================================






;=============================================================
; 						gLabel 
;=============================================================
;ButtonX
;=============================================================
;EditX
;=============================================================
;
;=============================================================


;=============================================================
; 						TIMER 
;=============================================================
;TimerX
;=============================================================
return

; Timer2
;=============================================================
Timer2:
 
return
 
;=============================================================
; 						HOTKEYS 
;=============================================================




; Hotkey1
;=============================================================






; Hotkey2
;=============================================================




; Exit 
;=============================================================
Exit:
^!x::  ; Hotkey ALT+x.
GuiEscape:
GuiClose:
 ExitApp


 
;#######################				#######################
;=============================================================
; 						FUNCTIONS 
;=============================================================
;#######################				#######################

Code: Select all


;************************************************
; AHK _ SCRIPT PERFORMANCE TEMPLATE v1.0
; by HinkerLoden
; 25/03/2016 
; OS  			--> 	Win 10 / etc. 
;AHK Version	-->		1.1.23.05 
;************************************************

;************************************************
;Script Global Settings
;************************************************

#NoEnv						; Clear All Systemvariables 
#Persistent 				;Keeps a script permanently running until ExitApp execute

#SingleInstance force		;The word FORCE skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.

;************************************************
;Performance PARAMETERS
;************************************************
SetBatchLines, -1				; look up long descriptions
Process, Priority, , A  		;H  - Max Speed but maybe unstable
;************************************************
; Input PARAMETERS
;************************************************
SendMode Input					;Default = Event , Play - for Speed -> Set Keydelay to -1 & Setmousedely to -1 
SetKeyDelay, -1, -1, Play		; for speed -1, -1, 

SetMouseDelay, -1				;0 recommend   /  -1 for max speed 
SetDefaultMouseSpeed, 0			;0-100 
;************************************************
;History Protocols
;************************************************
#KeyHistory 0					;  0 - No Keyhistory 
ListLines Off					; Off  - for more speed 
;************************************************
;Window detection
;************************************************
SetTitleMatchMode 2
SetTitleMatchMode Fast

SetWinDelay, 0 
SetControlDelay, 0	 

;#######################				#######################
; Script Parameter
;#######################				#######################

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

;#######################				#######################
; Prepare Start 
;#######################				#######################

WinMinimizeAll



;************************************************
;PERFORMANCE PARAMETERS DESCRIPTION
;************************************************
/*
;************************************************
;Performance PARAMETERS
;************************************************

SetBatchLines, -1

;default = 10ms
   
;SetBatchLines is set to 10 ms (the default), a task that uses 20 ms of CPU time will run for ~10 ms, sleep to allow other processes to run, and then run for the final 10 ms. If SetBatchLines is set to 2 ms, a task that uses 20 ms of CPU will sleep ~10 times before completing.
 
My advice... Leave SetBatchLines at the default of 10 ms. 10 ms is a good default. Most scripts run fine with this setting. If needed, increase SetBatchLines to a higher value (20ms, 50ms, -1, etc.) if one or more of your tasks needs more priority.

As Lower the Value as Slower the Script runs !!!
SetBatchLines, 20ms
SetBatchLines, LineCount



Process, Priority, , A  

;L (or Low)
;B (or BelowNormal), N (or Normal), A (or AboveNormal), H (or High), R (or Realtime). 
;Note: Any process not designed to run at Realtime priority might reduce system stability if set to that level.

Process, Priority, , L ;if unstable, comment or remove this line

;************************************************
; Input PARAMETERS
;************************************************

SendMode Input

;Keysettings		***********************

SetKeyDelay, -1, -1  ;  Delay, PressDuration
; default = 10
;Sets the delay that will occur after each keystroke sent by Send and ControlSend. -1 
;Use -1 for no delay at all and 0 for the smallest possible delay 


;Mousesettings		***********************
 
SetMouseDelay, -1 
;Sets the delay that will occur after each mouse movement or click.
;default = 10 - Sets the delay that will occur after each mouse movement or click.
 
SetDefaultMouseSpeed, 0
;default = 2 , Min = 0 , Max = 100

;Hotkeysettings		***********************
#MaxHotkeysPerInterval 99000000	:default = 70  	- prevent creating endless loops

#HotkeyInterval 99000000		;default = 2000 - Hoy much hotkeys can activate per ms

#MaxThreads 255					;default 10 	- How many Hotkeys + Timers .. can run simultanously 

#MaxThreadsBuffer On			;default Off - This is the default behavior. A hotkey press will be ignored whenever that hotkey is already running its maximum number of threads (usually 1, but this can be changed with #MaxThreadsPerHotkey).
 


;************************************************
;History Protocols
;************************************************
#KeyHistory 0					;disable KeyHistory log

ListLines,  Off					
;ListLines Off/On can be used to selectively omit some lines from the history, which can help prevent the history from filling up too quickly (such as in a loop with many fast iterations). ListLines Off may also improve performance by a few percent.
 

;************************************************
;Window detection
;************************************************

 
SetTitleMatchMode fast
;Fast: This is the default behavior. Performance may be substantially better than Slow, but certain WinText elements for some types of windows may not be "seen" by the various window commands.
;The built-in variables A_TitleMatchMode and A_TitleMatchModeSpeed contain the current settings.
 
SetWinDelay, 0 ;default = 100,  no delay = -1 	
;Sets the delay that will occur after each windowing command, such as WinActivate.


SetControlDelay, 0	 ; default = 20     , fastest = -1 
;Sets the delay that will occur after each control-modifying command.


SendMode Input	
; Recommended for new scripts due to its superior speed and reliability.
;Input: Switches to the SendInput method for Send, SendRaw, Click, and MouseMove/Click/Drag. Known limitations:Windows Explorer ignores SendInput's simulation of certain navigational hotkeys such as Alt+LeftArrow. To work around this, use either SendEvent !{Left} or SendInput {Backspace}. 

;************************************************
;Other 
;************************************************

#MaxMem 4095					;default 64MB - Max 4095	 set the Memory use for each Variable 


*/
 

Code: Select all


;************************************************
; AHK _ SCRIPT STRUCTURE TEMPLATE v1.0
; by HinkerLoden
; 09/04/2016 
; OS  			--> 	Win 10 / etc. 
;AHK Version	-->		1.1.23.05 
;************************************************

;************************************************
;Script Global Settings
;************************************************

#NoEnv						; Clear All Systemvariables 
#Persistent 				;Keeps a script permanently running until ExitApp execute

#SingleInstance force		;The word FORCE skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.

;************************************************
;Performance PARAMETERS - if you need speed 
;************************************************
;SetBatchLines, -1   		
;Process, Priority, , L  ;A  - Max Speed
;************************************************
; Input PARAMETERS
;************************************************
SendMode Input	;Default = Event , Play - for Speed -> Set Keydelay to -1 & Setmousedely to -1 
;----
SetKeyDelay, 10, 10   			; for speed -1, -1, 
SetMouseDelay, 25				;0 recommend   /  -1 for max speed 
SetDefaultMouseSpeed, 0			;0-100 
;************************************************
;History Protocols 
;Switch setting for more Speed 
;************************************************
#KeyHistory 1					;  0 - No Keyhistory 
ListLines  On  					; Off  - for more speed 
;************************************************
;Window detection
;************************************************
SetTitleMatchMode, 2
SetTitleMatchMode Fast			;slow detect hidden windows

SetWinDelay, 200  				;0 - for more speed   

DetectHiddenWindows, On			; | Off 

;i double the standard settings to be on the save side 
;#######################				#######################
; Script Parameter
;#######################				#######################

SetWorkingDir %A_ScriptDir%  	;Ensures a consistent starting directory.

;#Include %A_ScriptDir%\YourLibrarys2integrate.ahk

CoordMode, Pixel, Screen		;relative/Window - active Window
CoordMode, Mouse, Screen

;WinMinimizeAll     ;optional 


;#######################				#######################
; Try to avoid pure numbers inside the code - adress all Vars here
;=============================================================
; 						Variable Section
;=============================================================
;#######################				#######################
;global / static
;EnvUpdate ; --> Notifies the OS and all running applications that environment variable(s) have changed. 
;#######################				#######################

;===============================  TimerVars
CycleTimer1=500
CycleTimer2=500

Timer1Status=0
Timer2Status=0



;#######################				#######################
;=============================================================
; 						CODE 
;=============================================================
;#######################				#######################

 
 
;=============================================================
; 						GUI 
;=============================================================

;#######################				#######################
; GUI Template
;=============================================================

Gui, Tutorial: New , -ToolWindow +AlwaysOnTop, test
gui, font, s14, Verdana
Gui Add, Text, vText x40 y24 w350 h40 +0x200, Text
Gui Add, Edit, vEdit gEdit x40 y72 w350 h40, Edit
;----------
Gui Add, Button, vButton1 gButton1 x40 y152 w132 h44,  Button1
Gui Add, Button, vButton2 gButton2 x272 y152 w132 h44, Button2

;----------
Gui Add, Button, gExit x72 y272 w352 h76 cRed , -- E X I T --

Gui Show, w480 h380, Window
Return

/*	Used Vars 
Text =
Edit =
Button1 =
Button2 =
*/

;=============================================================
; 						gLabel 
;=============================================================
; Button1 - Start-Stop-Timer
;=============================================================
Button1:



If Timer1Status=1
	{
	SetTimer, Timer1, Off
	Timer1Status=0
	}
SetTimer, Timer1, %CycleTimer1%
Timer1Status=1
Return




; Button2 - Start-Stop-Timer
;=============================================================
Button2:


If Timer2Status=1
	{
	SetTimer, Timer2, Off
	Timer2Status=0
	}
SetTimer, Timer2, %CycleTimer2%
Timer2Status=1
Return

; gEdit
;=============================================================
Edit:


return
;=============================================================
; 						TIMER 
;=============================================================

; Timer1
;=============================================================
Timer1:


Return


return

; Timer2
;=============================================================
Timer2:
 
return
 
;=============================================================
; 						HOTKEYS 
;=============================================================




; Hotkey1
;=============================================================






; Hotkey2
;=============================================================




; Exit 
;=============================================================
Exit:
^!x::  ; Hotkey ALT+x.
GuiEscape:
GuiClose:
 ExitApp


 
;#######################				#######################
;=============================================================
; 						FUNCTIONS 
;=============================================================
;#######################				#######################

Last edited by jNizM on 10 Apr 2016, 04:47, edited 2 times in total.
Reason: fixed code-tag
victorel
Posts: 21
Joined: 09 Jun 2016, 14:44
Location: Canada

Re: New AutoHotkey Script Template

13 Jun 2016, 20:33

I actually had a small trouble with:

Code: Select all

SendMode, Input ; Recommended for new scripts due to its superior speed and reliability
my small piece of code

Code: Select all

;--------case conversion------------------

^u:: 
    save:=clipboard
    send, ^c
    ;sleep, 1000
    StringUpper, clipboard, clipboard
    ;sleep, 1000
    send, ^v
    clipboard:=save
return
^+u:: 
    save:=clipboard
    send, ^c
    ;sleep, 1000
    stringlower, clipboard, clipboard
    ;sleep, 1000
    send, ^v
    clipboard:=save
return
;-----------------------------------------
only worked in notepad.exe with that "sendmode input" and not in wordpad.exe, webmail and others; after dis-activating that mode, it worked fine everywhere.
Replacing "^c" with "{ctrl down}c{ctrl up}", or putting sleep in place, did not help.

Why?
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: New AutoHotkey Script Template

14 Jun 2016, 04:29

I am not a coder I just learned AHK my self and when I get stuck I had huge help from #ahkscript IRc and this forum I am very thank full for that :) before ahk I only knows excel and little bid macros. I have never made any tamplet file yet but yes I wana share What was my first ahk script ... I wrote my first ahk within excel and have made a macro that save as excel file into scriptmaker.ahk ... yess my first AHK code is written in excel.

1) Excel macro that save as xlsx into ahk and run that

Code: Select all

Sub ScriptMaker()
'
' ScriptMaker Macro
'
' Keyboard Shortcut: Ctrl+j
'
    Range("B2").Select
    ActiveWorkbook.Save
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="C:\Users\user\Documents\AhkScript.ahk", _
        FileFormat:=xlTextPrinter, CreateBackup:=False
    Application.DisplayAlerts = True
    ActiveWindow.Close savechanges:=True
    Shell ("C:\Program Files\AutoHotkey\AutoHotkey.exe C:\Users\user\Documents\AhkScript.ahk")
End Sub
2) my first ahk code written in scriptmaker.xlsx file I have upgraded it time to time :) so it is doing so many things. https://drive.google.com/open?id=0BzJv4 ... TQ4NS1tMlE

3) a short code that update links of / within scriptmaker.xlsx

Code: Select all

^F1::
FileDelete, D:\My Documents\SSHEDLE\*.xlsx
FileCopy, Z:\network\*.xlsx, D:\My Documents\SSHEDLE\*.*
SourcePath := "D:\My Documents\SSHEDLE\"
Loop, %SourcePath%\*.*
{
StringLeft, NewFileName, A_LoopFileName, 34
FileMove, %SourcePath%\%A_LoopFileName%, %SourcePath%\%NewFileName%.xlsx
}
msgbox, Recent schedule loaded , Scriptmaker alert
return

^F2::
XlApp := ComObjActive("Excel.Application")
G15 := XlApp.Worksheets("GAP USA COMMERCIAL").Range("G15").value

E2 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,12,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("E2").value := E2

G1 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,10,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G1").value := G1

G4 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,8,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G4").value := G4

G5 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,2,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G5").value := G5

G7 = =LEFT(SUBSTITUTE(VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,3,FALSE),"-",""),7)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G7").value := G7

G8 = =LEFT(VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,4,FALSE),6)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G8").value := G8

G9 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,5,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G9").value := G9

G10 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,9,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G10").value := G10

G13 = =VLOOKUP($B$2,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:O,7,FALSE)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G13").value := G13

G20 = =INDEX('D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!C:C,MATCH(G23,'D:\My Documents\SSHEDLE\%G15%SHIPMENT ADVICE'!E:E,0),1)
XlApp.Worksheets("GAP USA COMMERCIAL").Range("G20").value := G20

XlApp := ""
return
My first thought to do a task written in scriptmaker.xlsx and you need to see that excel file and you would find interesting. :HeHe:

and I wana know how you guys use ahk and do your tasks as I have seen tamplet.ahk and have no idea how to get used to code like you guys.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: New AutoHotkey Script Template

28 Mar 2017, 13:09

Once again, another revision of the New AutoHotkey Script template that I'm currently using:

Code: Select all

; Script Information ===========================================================
; Name:        New AutoHotkey Script
; Description: New Script Description
; AHK Version: AHK 1.1.25.01 (Unicode 32-bit)
; OS Version:  Windows 2000+
; Language:    English (United States)
; Author:      FirstName LastName <[email protected]>
; Filename:    New AutoHotkey Script.ahk
; ==============================================================================

; Revision History =============================================================
; Revision 1 (YYYY-MM-DD)
; * Initial release
; ==============================================================================

; Auto-Execute =================================================================
#SingleInstance, Force ; Allow only one running instance of script
#Persistent ; Keep the script permanently running until terminated
#NoEnv ; Avoid checking empty variables for environment variables
#Warn ; Enable warnings to assist with detecting common errors
;#NoTrayIcon ; Disable the tray icon of the script
SetWorkingDir, % A_ScriptDir ; Set the working directory of the script
SetBatchLines, -1 ; The speed at which the lines of the script are executed
SendMode, Input ; The method for sending keystrokes and mouse clicks
;DetectHiddenWindows, On ; The visibility of hidden windows by the script
;SetWinDelay, -1 ; The delay to occur after modifying a window
;SetControlDelay, -1 ; The delay to occur after modifying a control
OnExit("OnUnload") ; Run a subroutine or function when exiting the script

return ; End automatic execution
; ==============================================================================

; Labels =======================================================================
GuiEscape:
GuiClose:
ExitSub:
    ExitApp ; Terminate the script unconditionally
return
; ==============================================================================

; Functions ====================================================================
OnLoad() {
    Global ; Assume-global mode
    Static Init := OnLoad() ; Call function

    Menu, Tray, Tip, New AutoHotkey Script
}

OnUnload(ExitReason, ExitCode) {
    Global ; Assume-global mode
}

GuiCreate() {
    Global ; Assume-global mode
    Static Init := GuiCreate() ; Call function

    Gui, +LastFound -Resize +HwndGuiHwnd
    Gui, Margin, 10, 10
    Gui, Add, Text, w400 h200, Sample Text
    ;Gui, Add, Tab3, vTab, Tab1|Tab2|Tab3|Tab4
    ;Gui, Tab ; Future controls are excluded from any tab control
    ;Gui, Add, Button, w75 h23 vButton1, Button1
    Gui, Show, AutoSize, Example
}

GuiSize(GuiHwnd, EventInfo, Width, Height) {
    IfEqual, ErrorLevel, 1, return ; Window minimized
}

MenuHandler(ItemName, ItemPos, MenuName) {
    MsgBox, 0x40, MenuHandler, % "Item Name: " ItemName "`n"
    . "Item Position: " ItemPos "`n"
    . "Menu Name: " MenuName
}
; ==============================================================================
DaveT1
Posts: 225
Joined: 07 Oct 2014, 11:23

Re: New AutoHotkey Script Template

04 Jan 2022, 13:17

Thanks for this thread. Borrowing from you and others, this is what I'm currently using as a script header:

Code: Select all

{ ; Script Information ==================================================================
;
; Name:        Add#IncludeCode.ahk
; AHK Version: AutoHotkey_2.0-beta.3
; OS Version:  Microsoft Windows 10 Pro
; Author:      MyForumName (AUTOHOTKEY forums)
; Topic:			https://www.autohotkey.com/boards/viewtopic.php?f=81&t=97798
;
; Description:
;		- Item one of the description.
;		- Another item of the description.
;		- Further description point.
;
; Revision History: 
; (+) NEW, (*) CHANGED, (!) FIXED
; vX(new or changed functionality / maybe not backwards compatible).Y(minor revisons).
; ---------------------------------------------------------------------------------------
; v1.0 02-Jan-22	+ Initial release.
;
;\Script Information ===================================================================
}
Note that I include braces around this so this 'header' can be collapsed in case it gets too visually distracting.

Return to “Off-topic Discussion”

Who is online

Users browsing this forum: No registered users and 45 guests