AHK ScriptWriter 0.31

Post your working scripts, libraries and tools
SOTE
Posts: 657
Joined: 15 Jun 2015, 06:21

AHK ScriptWriter 0.31

20 Feb 2017, 08:20

This partially comes from the old website, and I was playing with a macro recorder created by AHKnow. I was playing with it over a year and a half ago, to make various small scripts, and had almost forgotten about it. While cleaning out my old computer, I came back upon it, and thought it would be interesting to post it. And I have started to use it again. It was never quite completed, but good at starting off writing scripts or making little useful scripts for doing things on the computer.

AHK ScriptWriter is somewhat like AutoScriptWriter II, but in AutoHotKey. It was working with AutoHotkey version 1.1.22.02. Don't know if it will have any issues with the newer version. To get an ideal of the macro recorder AutoScriptWriter II, check out this old YouTube video- https://youtu.be/bS-ycdoOyj8 . This will familiarize you. AHK ScriptWriter can do many of the same things, but does have some differences and improvements, to include helper scripts and is fully customizable in AutoHotKey. The code is sometimes written in a bit of a funky way, but lots of comments (some funny) are made to help learn or understand it.

Some things about AHK ScriptWriter. The "Shortcut" button is used for getting file locations of desktop icons. It will then run the file, when you press "Record". Recording text is separate from just mouse recording. You would press "TextRecord" first, then "Record", to have both operating. The "Clean" button tries to take out some of the time between mouse clicks. Often, a person is deciding what they want to do, which adds unnecessary time (sleep) that can be eliminated. However, using "Clean" to remove extra time, can have mixed results. The "ToolTip" at the bottom would show you what the script code looks like in real time. Is a bit funky looking, but works. After you record, you can select "Play", to have it run again, or "Save". If you press "Record" again, it will wipe the previous script. So, save it, if you want to keep it.

The helper scripts come from the old site, to help edit scripts, and are included at the bottom. They are: AutoCompleteASW_2.ahk, Assist_Help_2.ahk, WordList_AHK_API.txt, and ActiveWindowInfo.ahk. Copy them all into the same folder.

These files are ran from the help menu, and it will also try to find and run the AutoHotkey.chm. They are all useful for modifying a script created by the macro recorder, so were included.

AutoCompleteASW_2.ahk- You press F2 to show AutoHotKey commands and F4 to add commands. It uses WordList_AHK_API.txt, which is modifiable, so you can update it or add your own sample code to it.

Assist_Help_2.ahk- When you select a word and press F2, it then looks up the word in the AutoHotkey Help file (AutoHotkey.chm).

When "Editing Help" is selected from the Help menu, it will run AutoCompleteASW_2.ahk, Assist_Help_2.ahk, and AutoHotkey.chm. For the autocomplete feature to work, you need to have WordList_AHK_API.txt too.

With the AHK ScriptWriter GUI, if you press the close button, it will minimize to an icon and still be active. You can right click it for various options. If you want to truly exit, Alt-F4 or close the window itself.

Update- 03/05/17. MouseClick and MouseClickDrag. Had other scripts which did in a different way, upon comparison, decided to post that script as works better.

Image

AHK ScriptWriter

Code: Select all

; AHK ScriptWriter 0.3 Alpha
; Parts from Thalon, Skrommel from (www.donationcoders.com/skrommel), and AHKnow.
; Additional parts from Sote

; Special Notes
;`r`n and `n in commands are for formatting of captured info in tooltip, variables, or text.
;SetTimer On or Off might partially or fully correct typing and tooltip problems, where no text shows and tooltip dies.
;SetTimer turns subroutines/functions/labels On and Off, and allow for asynchronous execution of them by interrupting the script's normal linear (top-down) 
;Input command gets keyboard = key/keys
;record input goes to endrecord

If not A_IsAdmin ; Placed here as permissions can affect macro recording or playback.
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}

record= ; If empty, turns recording keyboard text off.  
;keydelay=10		;xxx Not used at the moment
;windelay=100		;xxx Not used at the moment
;Get informations for abort-condition
StringReplace, endrecord, record, }, %A_Space%Down}
StringLen, length, endrecord ;counts characters

;Initial Start up condition
#SingleInstance,Force
#Persistent
;DetectHiddenText, On
SetTitleMatchMode, Slow
SetBatchLines, -1
PID := DllCall("GetCurrentProcessId")
AutoTrim, Off
CoordMode, Mouse, Relative
modifiers =LCTRL,RCTRL,LALT,RALT,LSHIFT,RSHIFT,LWIN,RWIN,LButton,RButton,MButton,XButton1,XButton2
recording = 0
playing = 0
SendFlag = 0		;Flag for keyboard-recording
ControlSendFlag = 0	;Flag for special record-mode
Stop := ""
SelectedExe := ""
ExeHold := ""
Run = Run,
File := A_Temp . "\TempPlay.ahk" 
ScriptHold := ""
VersionMark := ASWv030 ; identifier and used to preventing program recording itself
FakeSleep = Sleep, 100
ExtraSleep = Sleep, 2000
GoSub, InitStyle
GoSub, Traymenu
GoSub, ShowGUI1
Return

Traymenu: ; Default location of program

Menu, Tray, NoDefault
Menu, Tray, NoStandard
Menu, Tray, Add, &Gui, ShowGUI1
Menu, Tray, Add, E&xit, ProgramExit
Menu, Tray, Add, &Record, ButtonRecord
Menu, Tray, Add, &Stop, ButtonStop
Menu, Tray, Add, &Pause, Pause
Menu, Tray, Add, Play&back, ButtonPlay
Menu, Tray, Add, Re&load, Reload
Return

ShowGUI1: ; GUI that is launched from Traymenu

Gui, Font, s9, 
Gui, Add, Button, x2 y198 w80 h40 +Center, &Clean
Gui, Add, Edit, x92 y38 w350 h20 , 
Gui, Add, Button, x452 y18 w60 h20 , &Browse
Gui, Add, GroupBox, x92 y8 w350 h10 , If "exe" below`, will "run" upon "Record"
Gui, Add, Button, x2 y258 w80 h40 , &Save
Gui, Add, Button, x2 y318 w80 h40 , &Close
Gui, Add, Edit, x92 y78 w420 h280 vScriptEdit, 
Gui, Font, s12, 
Gui, Add, Button, x2 y138 w80 h40 , &Play
Gui, Font, s12, MS sans serif
Gui, Add, Button, x2 y18 w90 h60 , &Record
Gui, Font, s10 w700, Arial
Gui, Add, Button, x452 y48 w60 h20 , &Shortcut
Gui, Add, Button, x2 y88 w80 h40 , &TextRecord
Gui, Add, CheckBox, x92 y368 w90 h30 vToolTipOption gToolTipShow, ToolTip
Gui, Font, S8 CDefault, Bold Verdana
; Generated using SmartGUI Creator 4.0
Gui, Show, x440 y164 h411 w549, AHK ScriptWriter v 030 Alpha
;Gui, Add, ComboBox, x-25 y-81 w41 h89 +Menu, ComboBox

; Create the sub-menus:

;Menu, FileMenu, Add, &Save, FileSave
;Menu, FileMenu, Add, Save &As, FileSaveAs
;Menu, FileMenu, Add  ; Separator line.
;Menu, FileMenu, Add, E&xit, FileExit
Menu, HelpMenu, Add, &AutoHotKey Help, Help
Menu, HelpMenu, Add, &WindowInfoSpy, WindowInfoSpy
Menu, HelpMenu, Add, &Editing Help, EditHelpers
Menu, HelpMenu, Add, &Compile Script, CompileScript

; Menu bar for attaching sub-menus to it:
;Menu, MyMenuBar, Add, &File, :FileMenu
;Menu, MyMenuBar, Add, &About, :HelpAbout
Menu, MyMenuBar, Add, &Help, :HelpMenu

; Attach the menu bar to the window:
Gui, Menu, MyMenuBar

Return

HelpAbout:
Gui, About:+owner1  ; Make the main window (Gui #1) the owner of the "about box".
Gui +Disabled  ; Disable main window.
Gui, About:Add, Text,, Text for about box.
Gui, About:Add, Button, Default, OK
Gui, About:Show

Return

Help:

IfExist, %A_ScriptDir%\AutoHotkey.chm
	Run, %A_ScriptDir%\AutoHotkey.chm
Else		
IfExist, %ProgramFiles%\AutoHotkey\AutoHotkey.chm
	Run, %ProgramFiles%\AutoHotkey\AutoHotkey.chm
Else		
IfExist, C:\Program Files\AutoHotkey\AutoHotkey.chm
	Run, C:\Program Files\AutoHotkey\AutoHotkey.chm
Else
IfNotExist, %ProgramFiles%\AutoHotkey.chm OR %A_ScriptDir%\AutoHotkey.chm
	Run, https://www.autohotkey.com/docs/commands.htm
Else
	MsgBox, No help files could be found

Return

WindowInfoSpy:

IfExist, %A_ScriptDir%\ActiveWindowInfo.ahk
	Run, %A_ScriptDir%\ActiveWindowInfo.ahk
Else		
IfExist,%A_ScriptDir%\AU3_Spy.exe
	Run, %A_ScriptDir%\AU3_Spy.exe
Else		
IfExist, %ProgramFiles%\AutoHotkey\AU3_Spy.exe
	Run, %ProgramFiles%\AutoHotkey\AU3_Spy.exe
Else
IfNotExist, %A_ProgramFiles%\AutoHotkey\AU3_Spy.exe OR %A_ScriptDir%\AU3_Spy.exe
	Run, https://www.autohotkey.com/
Else
	MsgBox, No ActiveWindowInfo or AU3_Spy found.

Return

EditHelpers:

MsgBox, Will launch Context Sensitive Help (F2) & Auto Complete (F4) for script editing.

IfExist, %A_ScriptDir%\AutoCompleteASW_2.ahk
	Run, %A_ScriptDir%\AutoCompleteASW_2.ahk
Else		
	MsgBox, AutoComplete not found.

If !WinExist("AutoHotkey Help")
{
	IfExist, %A_ScriptDir%\AutoHotkey.chm 
		Run, %A_ScriptDir%\AutoHotkey.chm
	Else		
	IfExist, %ProgramFiles%\AutoHotkey\AutoHotkey.chm
		Run, %ProgramFiles%\AutoHotkey\AutoHotkey.chm
	Else		
	IfExist, C:\Program Files\AutoHotkey\AutoHotkey.chm
		Run, C:\Program Files\AutoHotkey\AutoHotkey.chm
	Else		
		MsgBox, AutoHotKey Help not found, so only Auto Complete is active.
}
Sleep, 1500
If WinExist("AutoHotkey Help")
{	
	IfExist, %A_ScriptDir%\AssistHelpASW_2.ahk
		Run, %A_ScriptDir%\AssistHelpASW_2.ahk
	Else		
		MsgBox, AssistHelp not found.
}
WinMinimize, AutoHotkey Help
WinActivate, AHK ScriptWriter v 030 Alpha

Return

CompileScript:

MsgBox, Will compile your present script into .EXE



Return

FileMenu:


ShowGUI2: ; Creates little STOP button in upper left hand corner
Gui, font, s10 w700, Arial
Gui, Add, Button, w45 h20, Stop
Gui, +AlwaysOnTop -SysMenu +Owner -Border
Gui, Color, EEAA99
Gui, +Lastfound ; Make the GUI window the last found window. 
WinSet, TransColor, EEAA99 
Gui, Show, x0 y0, ASWv030 
Return


HelpMenu2:

IfExist, %A_ScriptDir%\AutoHotkey.chm
	Run, %A_ScriptDir%\AutoHotkey.chm
Else		
IfExist, %A_ProgramFiles%\AutoHotkey\AutoHotkey.chm
	Run, %A_ProgramFiles%\AutoHotkey\AutoHotkey.chm
Else
IfNotExist, %A_ProgramFiles%\AutoHotkey\AutoHotkey.chm OR %A_ScriptDir%\AutoHotkey.chm
	Run, https://www.autohotkey.com/docs/commands.
Else
	MsgBox, No help files could be found

Return

ButtonClean: ;Deletes uneeded "Sleep" lines.  Attempt to fix script reliabilty or problems after already recorded.

MsgBox, Delete "Sleep", duplicates, & unneeded lines for possibly better performance?

;IfInString, ScriptUP, ControlClick
;	{
;	ScriptUP := RegExReplace(ScriptUP,"...NA,.*\r\n.*\r\n.*","1")
;	Sleep, 300
;	}
	
IfInString, ScriptUP, UNRS
	{
	ScriptUP := RegExReplace(ScriptUP,".*UNRS.*\r\n")
	Sleep, 300
	}	
	
IfInString, ScriptUP, SpecialButton
	{
;	ScriptUP := RegExReplace(ScriptUP,"...SpecialButton.*\r\n.*\r\n.*", "`nSleep, 2000")
	ScriptUP := RegExReplace(ScriptUP,"....SpecialButton*", "`nSleep, 2000")
	Sleep, 300
	}
	
If ScriptUP != 
	{
	Gosub, RemoveDuplicates
	GuiControl,,ScriptEdit, %ScriptUP%
	}
	
Return

RemoveDuplicates:

Result := ""
Loop Parse, ScriptUP, `n, `r
{
    if (A_LoopField != FoundDuplicate)
    {
        Result .= Result ? "`n" : ""
        Result .= A_LoopField
    }
    FoundDuplicate := A_LoopField
}
ScriptUP := Result

Return

ButtonBrowse: ; This is so you can select an .exe and show its path

FileSelectFile, SelectedExe, 3,, Select .EXE to run, Executables (*.exe) 
Gosub ExeShowBrowseEdit1

ExeShowBrowseEdit1:
    IfExist, %SelectedExe%
    	GuiControl,,Edit1,%SelectedExe%
       
    Else
        MsgBox, You did not select anything or an .EXE file.
		ExeHold = %SelectedExe%  
Return

ExeRunBrowseEdit1: ; This is so you can run an .exe/application file before using the mouse on its window or menus

IfEqual, ExeHold,  ; If ExeHold (SelectedExe) equal empty, then return
{ 
return
}    
IfNotEqual, ExeHold, ; If ExeHold not empty, then run it
{
;Sleep, 500
Run, %ExeHold%
GuiControl,,Edit1,
}   	
return
    
ButtonSave: ; This is so you can save your script

Gui +OwnDialogs  ; Force the user to dismiss the FileSelectFile dialog before returning to the main window. 
FileSelectFile, SelectedFileName, S16,, Save File, AutoHotkey Script (*.ahk) 
if SelectedFileName =  ; No file selected.
{ 
return
} 
Gosub SaveCurrentFile 
return 

SaveCurrentFile: ; Saves your AutoHotkey script

GuiControlGet, ScriptEdit
FileDelete, %SelectedFileName%.ahk 
FileAppend, %ScriptEdit%, %SelectedFileName%.ahk
return 

ButtonStop: ; Stops the recording

Recording = 0
ToolTipOption = 0
SetTimer, Check_Modifier_Keys, Off
Gui, Destroy
Clipboard = %keys% ;Send recorded data to clipboard
ToolTip, 
Gosub, ShowGUI1
IfEqual, ExeHold, 
{ 
FileAppend, %keys%, %File%
}
Else
{
FileAppend, %Run%%ExeHold%`n%keys%, %File%   ; `r`n needed for proper formatting in Edit2 and File
}
Sleep, 1000
FileRead, ScriptUP, %File%
GoSub, RemoveMark ; No longer needed.  GUI doesn't interfere in recordings anymore.
;ScriptUP = %ScriptUP%Exit ; place holder "Exit" to identify last line
;ScriptUP := RegExReplace(ScriptUP,"\r.*\r.*Exit") ; deletes last recorded line above Exit
ScriptUP = %ScriptUP%`r`nExit ; put the Exit command back
GuiControl,,ScriptEdit, %ScriptUP% ; puts the recorded script on the GUI
FileDelete, %File%
ScriptHold := ""
SelectedExe := ""
ExeHold := ""


Return 

RemoveMark: ; This kills possible self-recorded last line when you press "Stop" in the GUIs

IfInString, ScriptUP, ASWv030
{
ScriptUP := RegExReplace(ScriptUP,".*?ASWv030....*\r\n") ; Finds lines with ASWv030 and removes entire line or multiple lines with it.
return
}
Else
{
return
}

ButtonTextrecord: ;Turns Keyboard recording totally on

ToolTip, Text can now be recorded...
Loop
{
record = {LCtrl} {F12} ; Yes this is weirdness; turns text recording On or Off.  Also for key stoppage, but that not working at the moment.
endrecord = record
}
return

ButtonShortcut: ;Gets .EXE from Desktop Shortcuts.  Makes created Macros more reliable and portable
Gui, Submit, NoHide
ToolTip, Select Desktop Shortcut...
Sleep, 2000
KeyWait, LButton, D	
ControlGet, fileName, List, Selected, SysListView321, ahk_class Progman
fileName := SubStr(fileName,1,InStr(fileName,A_Tab)-1) ".lnk"
FileGetShortCut,% FileExist(A_Desktop "\" fileName)       ? A_Desktop "\" fileName

                 : FileExist(A_DesktopCommon "\" fileName) ? A_DesktopCommon "\" fileName

                 : fileName, WillRun
ToolTip				 
MsgBox, 4, EXE for Shortcut, %WillRun% ; This is the retrieved .EXE that is placed in GUI Edit1
	IfMsgBox Yes
		{
		GuiControl,,Edit1,%WillRun%
		ExeHold = %WillRun%
		return
		}
	else
		{
		MsgBox Select Again
		Gosub, ButtonShortcut
		}

Return

ButtonPlay: ; Play back script shown on GUI and Tooltip.

FileDelete, %File%
GuiControlGet, ScriptEdit ; Gets recorded data and any corrections you made before play
FileAppend, %ScriptEdit%, %File%
Sleep, 1000
Gui, Destroy
RunWait, %File%,, UseErrorLevel
if ErrorLevel = ERROR
{
RunWait, %A_ScriptDir%\AutoHotkey.exe "%File%",, UseErrorLevel
	If ErrorLevel = ERROR
	{
	Msgbox, AutoHotkey NOT found OR you may need to associate .AHK files with AutoHotkey.exe
	}
}
Sleep, 500
Gosub, ShowGUI1
FileRead, ScriptUP, %File%
GuiControl,,ScriptEdit, %ScriptUP%
FileDelete, %File%
return

ButtonRecord:   ; RECORD

; Blanking out these variable are very important, otherwise all kinds of bad results or weirdness.
GuiControl,,ScriptEdit,
ScriptHold := ""
ScriptUP := ""
keys := ""
ElapsedTime := ""
StartTime := ""
FileDelete, %File%
Gui, Destroy

Gosub Record_On
Return


Record_On: ; Part of recording subroutines

Gosub, ShowGUI2
Gosub, ExeRunBrowseEdit1

If recording = 0
{
Recording = 1
  ;Start recording if all modifier-keys are unpressed
	GetKeyState, state, LShift, P
  If state = d
  Loop
  {
    GetKeyState, state, LShift, P
    If state = U
      Break
  }
  GetKeyState, state, LCtrl, P
  If state = d
  Loop
  {
    GetKeyState, state, LCtrl, P
    If state = U
      Break
  }
  GetKeyState, state, LAlt, P
  If state = d
  Loop
  {
    GetKeyState, state, LAlt, P
    If state = U
      Break
  }
  GetKeyState, state, LWin, P
  If state = d
  Loop
  {
    GetKeyState, state, LWin, P
    If state = U
      Break
  }
  
  ;Start Recording
  recording = 1
  ToolTip, Recording... 
;  Process, Priority, %PID%, High	  ;Sets Priority to high, but may cause trouble on older and slower computers
  Gosub, Record_Loop
;  Process, Priority, %PID%, Normal	;Sets Priority to high
  
;  ToolTip, Recording finished
  
;	Send recorded data to clipboard
	Clipboard = %keys%
  
  Sleep, 1000
  ToolTip,
 ; recording = 0 ; strange command after recording = 1
}
Else
{
	recording = 0
	SetTimer, Check_Modifier_Keys, Off
}
Return

Record_Loop: ;Record keyboard and mouse, relative to screen.  ControSsend/ControlClick is preferable for reliability
SetTimer, Check_Modifier_Keys, 30
OldWinID =
keys =
Loop
{
  if recording = 0
  	break
	Input, key, M B C V I L1 T1, {BackSpace}{Space}{WheelDown}{WheelUp}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{F13}{F14}{F15}{F16}{F17}{F18}{F19}{F20}{F21}{F22}{F23}{F24}{ENTER}{ESCAPE}{TAB}{DELETE}{INSERT}{UP}{DOWN}{LEFT}{RIGHT}{HOME}{END}{PGUP}{PGDN}{CapsLock}{ScrollLock}{NumLock}{APPSKEY}{SLEEP}{Numpad0}{Numpad0}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}{NumpadDot}{NumpadEnter}{NumpadMult}{NumpadDiv}{NumpadAdd}{NumpadSub}{NumpadDel}{NumpadIns}{NumpadClear}{NumpadUp}{NumpadDown}{NumpadLeft}{NumpadRight}{NumpadHome}{NumpadEnd}{NumpadPgUp}{NumpadPgDn}{BROWSER_BACK}{BROWSER_FORWARD}{BROWSER_REFRESH}{BROWSER_STOP}{BROWSER_SEARCH}{BROWSER_FAVORITES}{BROWSER_HOME}{VOLUME_MUTE}{VOLUME_DOWN}{VOLUME_UP}{MEDIA_NEXT}{MEDIA_PREV}{MEDIA_STOP}{MEDIA_PLAY_PAUSE}{LAUNCH_MAIL}{LAUNCH_MEDIA}{LAUNCH_APP1}{LAUNCH_APP2}{PRINTSCREEN}{CTRLBREAK}{PAUSE}
  endkey = %ErrorLevel%
	if (key = "" AND Errorlevel = "Timeout") ;No key pressed
  	Continue
  
	GoSub, CheckWindow		;Check window-changes before key-record

  IfInString, endkey, EndKey:
  {
    StringTrimLeft, key, endkey, 7
    key = {%key%}
  } 
  GoSub, Start_Send
  
 ;IfNotInString, Controlname, Button ; Special rules to stop double recording of same button pushed (ControlSend VS ControlClick).
 ; if WinClass != #32770 ; Special rule; This with bottom send rule turns keys completely OFF
	{
		keys = %keys%%key% ; Will send extra unneeded characters on certain controls/buttons; controls recording text
	}	
  
  IfInString, keys, %endrecord%		;Finish-Shortcut was pressed. Which keys at top of the script for user to choose.
  {
		StringTrimRight, keys, keys, % length		;Remove Finish-Shortcut from record
		
		if (ControlSendFlag = 1)	;If "ControlSend" is recorded (due to pressing Finish-Shortcut)
		{
			StringRight, CheckTrimMode, keys, % 14 + StrLen(Controlname)
			if CheckTrimMode = ControlSend`, %Controlname%`,		;Check if Controlsend-Mode was initialized by Finish-Shortcut or if other letters where typed
				StringTrimRight, keys, keys, % 14 + StrLen(Controlname)		;Remove Controlsend-Command
			else		;Other letters typed --> Finish Controlsend-Command
				keys = %keys%`, %WinTitle%
		}
		else	;If "Send" is recorded (due to pressing Finish-Shortcut)
		{
			StringRight, CheckTrimMode, keys, % 5
			if CheckTrimMode = Send`,		;Check if Send-Mode was initialized by Finish-Shortcut or if other letters where typed
				StringTrimRight, keys, keys, 5		;Remove Send-Command
		}

			
	;recording = 0 ; if recieve endrecord (from record), turns recording off
  }
  If recording = 0
  {
	SetTimer, Check_Modifier_Keys, Off 
  }
}
Return

Check_Modifier_Keys:
Loop, Parse, modifiers, `,
{
  GetKeyState, state, %A_LoopField%, P
	If (state = "D" AND state%A_Index% = "")	

  {
		GoSub, CheckWindow		;Check window-changes before key-record
		state%A_Index% = D
    if InStr(A_LoopField, "Button")
    {
	    GoSub, End_Send
;			keys = %keys%Sleep`, %A_TimeSincePriorHotkey%`n  ;Wofür war das?
			
			if (WinClass = "Progman" or WinClass = "WorkerW")		;Desktop
			{
				keys = %keys%
				GoSub, MouseClick
			}
;			
;			if InStr(Controlname, "Start")
;									
			else	;"normal" Window
			{
				;Getting style for clearer information
				WinGetClass, WinClass, ahk_id %WinID%
				WinGetTitle, WinTitle, ahk_id %WinID%
				MouseGetPos, XPos, YPos, WinID, Controlname
				ControlGetText, Controltext, %Controlname%, %WinTitle%
				ControlGet, ControlStyle, Style, , %Controlname%, ahk_id %WinID%
				PixelGetColor, PixelHold, %XPos%, %YPos%
				;PixelGetColor, OutputVar, X, Y [, Alt|Slow|RGB]
				
						
				if InStr(Controlname, "Button")	;Normaler Button, Checkbox, Radio, 
				{
					if WinClass = #32770 
					if WinTitle != ASWv030
					if WinTitle != Run	
					if WinTitle != Start ;Menu
					{
						keys = %keys%ControlFocus`, %Controlname%`, %WinTitle%`n
						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,`n
						;MsgBox, rule 1	
					}
					
					if WinClass = #32770	
					if WinTitle = Run
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
					{
						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 2`, NA,`n	
						;MsgBox, rule 2
					}
					
					if WinClass != #32770
					if Controltext !=
					if ControlStyle !=	
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
					{
						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`,,;SpecialButton`n
						;MsgBox, rule 3
					}
					
;					if WinClass !=
;					if WinClass != #32770	
;					if WinTitle !=	
;					if WinTitle != ASWv030
;					if WinTitle != Start ;Menu
;					{
;						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,;SpecialButton`n		
;					}

							
					if ControlStyle := (ControlStyle & 0xF)		;Es ist nur B0000 bis B1111 interessant
					IfEqual, WinClass, Shell_TrayWnd
					if WinTitle != ASWv030
					if WinTitle =
					{
				 	keys = %keys%ControlClick`, %Controlname%`, ahk_class Shell_TrayWnd`, `, Left`, 1`, NA,`n
					}
					
;					if (ControlStyle = BS_PUSHBUTTON OR ControlStyle = BS_DEFPUSHBUTTON) ; rule was too tight and missing buttons
;					if WinTitle != ASWv030
;					if WinTitle != Start Menu
;					if WinTitle != 
;					IfNotEqual, WinClass, Shell_TrayWnd 
;					{
;						StartTime = %A_TickCount%
;						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,`n
;						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`,, 1, D`n
;					}
					else if (ControlStyle = BS_3STATE OR ControlStyle = BS_AUTO3STATE)
					{
						SendMessage, BM_GETSTATE, 0, 0, %Controlname%, %WinTitle%
				  	state := ErrorLevel
				  	;Obey: The previous state has to be used for check...
				  	If (state & 0x3 = BST_UNCHECKED)	;State = CHECKED
							keys = %keys%Control`, Check`, `, %Controlname%`, %WinTitle%`n
						Else If (state & 0x3 = BST_CHECKED)		;State = INDETERMINATE
							keys = %keys%SendMessage`, %BM_SETCHECK%`, %BST_INDETERMINATE%`, 0`, %Controlname%, %WinTitle%`n
						Else If (state & 0x3 = BST_INDETERMINATE)		;State = UNCHECKED
							keys = %keys%Control`, UnCheck`, `, %Controlname%`, %WinTitle%`n
					}
					else if (ControlStyle = BS_CHECKBOX OR ControlStyle = BS_AUTOCHECKBOX)
					{
						ControlGet, Checked2, Checked, , %Controlname%, %WinTitle%
						if Checked2 = 1	;Beachte: Mausklick erfolgt erst nach Statuserfassung!
							keys = %keys%Control`, UnCheck`, `, %Controlname%`, %WinTitle%`n
						else
							keys = %keys%Control`, Check`, `, %Controlname%`, %WinTitle%`n
					}
					
					else if (ControlStyle = BS_RADIOBUTTON OR ControlStyle = BS_AUTORADIOBUTTON)
					if WinTitle != Start Menu
					if WinTitle != ASWv030
					IfNotEqual, WinClass, Shell_TrayWnd 
					{
						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, NA,`n
					}	
					else	;Unhandled Button-Type
					{
;						StartTime = %A_TickCount%
						keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, `, `, %state%`n
					}
					
						
				}
				
					
				;if Instr(Controlname, "Static") ; This is for static type buttons
				;	if WinTitle != ASWv030
				;	if WinTitle != Start Menu
				;	if WinClass !=	
				;	IfNotEqual, WinClass, Shell_TrayWnd	
				;	{
				;		keys = %keys%ControlFocus`, %Controlname%`, %WinTitle%`n
				;		keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,`n
				;	}
					
				if Instr(Controlname, "Static") ; This is for static type buttons
					if WinTitle != ASWv030
					if WinTitle != Start Menu
					IfNotEqual, WinClass, Shell_TrayWnd	
					If ControlStyle !=	
					If ControlText !=	
					{
						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,;SpecialButton`n
					}
					
				if Instr(Controlname, "Static") ; This is for static type buttons
					if WinTitle != ASWv030
					if WinTitle != Start Menu
					IfNotEqual, WinClass, Shell_TrayWnd
					If ControlStyle =
					If ControlText =	
					{
						keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n
					}		
					
				if Instr(Controlname, "Static") ; This is for static type buttons
					if WinTitle != ASWv030
					if WinTitle != Start Menu
					IfNotEqual, WinClass, Shell_TrayWnd
					If ControlStyle !=	
					If ControlText =	
					{
						keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n
					}		
					
								
				if InStr(Controlname, "ComboLBox")	
					if WinClass = #32770 
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
					if PixelHold = 0xFF9933	
					{
						keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,`n
						;MsgBox, rule 4
					}
				if InStr(Controlname, "ScrollBar2")	
					if WinClass = #32770 
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
					{
						GoSub, MouseClick
					}
													
				if InStr(Controlname, "Checkbox")	;Normaler Button, Checkbox, Radio, 
								{
									if ControlStyle := (ControlStyle & 0xF)		;Es ist nur B0000 bis B1111 interessant
									IfEqual, WinClass, Shell_TrayWnd
									if WinTitle != ASWv030
									if WinTitle =
									{
								 	keys = %keys%ControlClick`, %Controlname%`, ahk_class Shell_TrayWnd`, `, Left`, 1`, NA,`n
									}
									
									if (ControlStyle = BS_PUSHBUTTON OR ControlStyle = BS_DEFPUSHBUTTON)
									if WinTitle != ASWv030
									if WinTitle != Start Menu
									if WinTitle != 
									IfNotEqual, WinClass, Shell_TrayWnd 
									{
;										StartTime = %A_TickCount%
										keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, 1`, NA,`n
									}
									else if (ControlStyle = BS_3STATE OR ControlStyle = BS_AUTO3STATE)
									{
										SendMessage, BM_GETSTATE, 0, 0, %Controlname%, %WinTitle%
								  	state := ErrorLevel
								  	;Obey: The previous state has to be used for check...
								  	If (state & 0x3 = BST_UNCHECKED)	;State = CHECKED
											keys = %keys%Control`, Check`, `, %Controlname%`, %WinTitle%`n
										Else If (state & 0x3 = BST_CHECKED)		;State = INDETERMINATE
											keys = %keys%SendMessage`, %BM_SETCHECK%`, %BST_INDETERMINATE%`, 0`, %Controlname%, %WinTitle%`n
										Else If (state & 0x3 = BST_INDETERMINATE)		;State = UNCHECKED
											keys = %keys%Control`, UnCheck`, `, %Controlname%`, %WinTitle%`n
									}
									else if (ControlStyle = BS_CHECKBOX OR ControlStyle = BS_AUTOCHECKBOX)
									{
										ControlGet, Checked2, Checked, , %Controlname%, %WinTitle%
										if Checked? = 1	;Beachte: Mausklick erfolgt erst nach Statuserfassung!
											keys = %keys%Control`, UnCheck`, `, %Controlname%`, %WinTitle%`n
										else
											keys = %keys%Control`, Check`, `, %Controlname%`, %WinTitle%`n
									}
									
									else if (ControlStyle = BS_RADIOBUTTON OR ControlStyle = BS_AUTORADIOBUTTON)
									if WinTitle != Start Menu
									if WinTitle != ASWv030
									IfNotEqual, WinClass, Shell_TrayWnd 
									{
										keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`, `, Left`, NA,`n
									}	
									else	;Unhandled Button-Type
									{
;										StartTime = %A_TickCount%
										keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, `, `, %state%`n
									}
				}

				else if InStr(Controlname, "Combobox")		;Edit, Combobox (here only Edit-part)
				{
;					GoSub, MouseClick
;					keys = %keys%ControlFocus`, %Controlname%`, %WinTitle%`n ; Which is better is unclear. 
					keys = %keys%ControlClick`, %Controlname%`, %WinTitle%`n
				}
				else if InStr(Controlname, "UIRibbonWorkPane1")						
				{
					keys = %keys%SendEvent`, {Click %XPos%` %YPos%}`n%FakeSleep% `;SS`n ; works better than MouseClick for this control
				}	
				else if InStr(Controlname, "NetUIHWND")						
				{
					keys = %keys%SendEvent`, {Click %XPos%` %YPos%}`n%FakeSleep% `;SS`n ; tested many times, effective and simple for now
					keys = %keys%SendEvent`, {Click %XPos%` %YPos%}`n%FakeSleep% `;SS`n
				}	
				else if InStr(Controlname, "DirectUIHWND")		; Weird Edit-like control, often with Combobox; mixes up alot with ComboLBox
				{
;					keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n ;Sleep`, %ElapsedTime%`n
					GoSub, MouseClick
				}
				else if InStr(Controlname, "SysTreeView321")		; Difficult control, using MouseClick and MouseClickDrag, often easier
				{
;					keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n ;Sleep`, %ElapsedTime%`n
					GoSub, MouseClick
				}
			

/*				
; These are recognized controls, but causes massive problems getting to work with script.

				else if InStr(Controlname, "ToolBarWindow322")		
					if WinClass = #32770 
					if Controltext !=	
					if WinClass != Program	
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
				{
					keys = %keys%ControlClick`, %Controltext%`, %WinTitle%`, `, Left`, 1`, NA,`n
;					keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n
				}
				
				else if InStr(Controlname, "ToolbarWindow321")
					if WinClass = #32770 
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
				{
;					keys = %keys%ControlClick`, %Controltext%`, %WinTitle%`, `, Left`, 1`, NA,`n
					keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n
				}
				
				
				else if InStr(Controltext, "Shell Preview Extension")
					if WinClass = #32770 
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
				{
					keys = %keys%ControlClick`, %Controltext%`, %WinTitle%`, `, Left`, 1`, NA,`n
					keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n
				}
				
				else if InStr(Controltext, "Navigation")		;Edit, Combobox (here only Edit-part); mixes up alot with ComboLBox
				else if InStr(Controlname, "ToolbarWindow")
					if WinClass = #32770 
					if WinTitle != ASWv030
					if WinTitle != Start ;Menu
				{
					keys = %keys%ControlClick`, %Controltext%`, %WinTitle%`, `, Left`, 1`, NA,`n
					keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`, `;SpecialClick`n
				}
*/				
								
/*
			
				else if InStr(Controlname, "ComboBox")	;DropDown, Combobox (hier nur Button zum droppen)
				{
					
				}
				else if InStr(Controlname, "Listbox")	;Listbox
				{
					
				}
				else if InStr(Controlname, "Hotkey")	;Hotkey-Control
				{
					History = %History%ControlFocus`, %Controlname%`, %WinTitle%`n
				}
				else if InStr(Controlname, "Trackbar")	;Slider
				{
					
				}
				
*/
				else	;Klick somewhere in the window or unknown control
				{
					GoSub, MouseClick
				}
			}
	
 
    }
    Else
    {
		GoSub, Start_Send
		keys = %keys%{%A_LoopField% Down}
	}
  }
  
  GetKeyState, state, %A_LoopField%, P
  If (state = "U" AND state%A_Index% = "D") 
  {
	GoSub, CheckWindow		;Check window-changes before key-record
		
    if InStr(A_LoopField, "Button")
    {
		GoSub, End_Send
		GoSub, MouseClick
	}	
	Else
	IfNotInstring, A_LoopField, Button
	{
		GoSub, Start_Send
		keys = %keys%{%A_LoopField% Up}
	}
    state%A_Index%=
  }
}
If keys = {LShift Up}
  keys =
If keys = {LCtrl Up}
  keys =
If keys = {LAlt Up}
  keys =
If keys = {LWin Up}
  keys =
StringRight, ScriptHold, keys, 500 ; Number of characters being displayed by ToolTip.  Too small (like 50) = Problems
Gosub, ToolTipShow
Return

ToolTipShow:
Gui, Submit, NoHide
IfEqual, ToolTipOption, 1
{
ToolTip, %ScriptHold% ; DISPLAYS ToolTip contents on screen
return
}
IfEqual, ToolTipOption, 0
{	
ScriptHold =
}
Return

RemoveToolTip:
ToolTip
return

MouseClick:		;Saves a mouseclick (unknown controls or for controls where position is needed (Edit-Control for example)

;CoordMode, Mouse, Window
GetKeyState, Right, RButton
GetKeyState, Left, LButton
;StartTime = %A_TickCount%
;StartTime =
if Right = D 
IfNotInString, Controlname, ComboLBox
IfNotInString, Controlname, Checkbox
IfNotInString, Controlname, Static
IfNotInString, Controlname, UIRibbonWorkPane1
IfNotInString, Controlname, NetUIHWND
IfNotInString, Controlname, Button
	{		
	MouseGetPos, XPos, YPos
	ElapsedTime := A_TickCount - StartTime
	KeyWait, RButton, U	
	StartTime := A_TickCount
	Loop, 3
	{
	If (ElapsedTime < 150)
		{
		keys = %keys%MouseClick`, Right`, %XPos%`, %YPos%`, 1`n%FakeSleep% `;SS`n
		break
		}
	If (ElapsedTime > 150)
		{
		keys = %keys%MouseClick`, Right`, %XPos%`, %YPos%`, 1`nSleep`, %ElapsedTime% `;UNRS`n
		break
		}
	}
	}
if Left = D 
IfNotInString, Controlname, ComboLBox
IfNotInString, Controlname, Checkbox
IfNotInString, Controlname, Static
IfNotInString, Controlname, NetUIHWND
IfNotInString, Controlname, UIRibbonWorkPane1
IfNotInString, Controlname, Button
	{
	MouseGetPos, XPos, YPos, id, ControlCh	
	WinGet, WindowCh, ID, A
	ElapsedTime := A_TickCount - StartTime ; Time between separate mouse down clicks.  Finishes when mouse is clicked down.
	KeyWait, LButton, U
	MouseGetPos, XPos2, YPos2, id, ControlCh2
	WinGet, WindowCh2, ID, A
	StartTime := A_TickCount ; Time between separate mouse down clicks. Starts from when mouse button is up.
	X3 = (XPos - XPos2)
	Y3 = (Ypos - XPos2)
	Loop, 3
	{
	If (XPos = XPos2) or (YPos = YPos2) 
	If (ElapsedTime < 150) ;for capturing most double-clicks
		{
		keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 2`n
		break
		}
	If (XPos = XPos2) or (YPos = YPos2) 
	If (ElapsedTime > 150)
		{
		keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`nSleep`, %ElapsedTime% `;UNRS`n
		break
		}		
	If ((XPos2 <> X3-5) or (XPos2 <> X3+5) or (YPos2 <> Y3-5) or (YPos2 <> Y3+5)) ;funky, but allows some movement before considered a drag
	If (WindowCh = WindowCh2) and (ControlCh = ControlCh2) ;and (ElapsedTime != "" ) ;stops opening or closing window to be considered a drag		
		{
		keys = %keys%MouseClickDrag`, Left`,%XPos%`, %YPos%`, %XPos2%`, %YPos2%`n
		break
		}
	Else
		{
		keys = %keys%MouseClick`, Left`, %XPos%`, %YPos%`, 1`n%FakeSleep% `;SS`n ;failsafe
		break
		}
	}
	}	
Return

PixelClick:

;CoordMode, ToolTip|Pixel|Mouse|Caret|Menu [, Screen|Window|Client]
;CoordMode, Pixel, Relative
; Initiated by long duration of down mouseclick, then inputs information for pixel search

			
/*
TRAYRECORD:
WinActivate, ahk_id %currentid%
WinWaitActive, ahk_id %currentid%, , 2
Gosub, Record_On		
Return
*/

UrlClick:

/*
Instead of MouseClick, copies url from address bar and adds to script.  Uses cursor type as check
If cursor IBeam, sends text





*/


CheckWindow:

WinGet, WinID, ID, A

If WinID <> %OldWinID%
{
	GoSub, End_Send
	
	WinGetClass, WinClass, ahk_id %WinID%
	WinGetTitle, WinTitle, ahk_id %WinID%

	if (WinClass = Progman) or (WinTitle = Program Manager)
	{
;		keys = %keys%{LWIN Down}m{LWIN UP}
;		ControlGet, fileName, List, Selected, SysListView321, ahk_class Progman
		Gosub, MouseClick
;		WinClass = 
;		WinTitle =
	}
	else 
		
	if WinTitle != Start 	; Prevents WinWait, etc... from being added to this window	
	if WinTitle != Start Menu	; Prevents WinWait, etc... from being added to this window
	if WinTitle != ASWv030 	; Prevents WinWait, etc... from being added to this window
	if WinTitle != 	; Adds WinWait, WinActivate, and WinWaitActive commands to found Window Title.
		keys = %keys%WinWait`, %WinTitle%`nWinActivate`, %WinTitle%`nWinWaitActive`, %WinTitle%`n
	
	else If WinClass !=
		keys = %keys%WinWait`, ahk_class %WinClass%`nWinActivate`, ahk_class %WinClass%`nWinWaitActive`, ahk_class %WinClass%`n
;
; WinWait, WinActivate, and WinWaitActive better than just WinActivate and WinWaitActive, so changed.
;

  OldWinID = %WinID%
  
}
return

Start_Send: ; Is beginning/front of the constructed command.

if SendFlag = 0		;If "Send" was not already added it is added just before the keypress...
;IfNotInString, Controlname, Button ; Turns ON and OFF ability to send text to Edit fields
;if WinClass != #32770	;
{
	ControlGetFocus, Controlname, ahk_id %WinID%
	if InStr(Controlname, "Edit")		;If control is of Edit-Type use "ControlSend" instead of "Send"
	{
		ControlSendFlag = 1
		keys = %keys%ControlSend`, %Controlname%`,
	}
	else if InStr(Controlname, "DirectUIHWND")		;This is an odd, almost Edit type control.
	{
		ControlSendFlag = 1
		keys = %keys%ControlSend`, %Controlname%`,
	}
	else
		keys = %keys%Send`,
		SendFlag = 1
}	

return

End_Send: ; Is end/last part of the constructed command on the same line from Start_Send

;IfNotInString, Controlname, Button
;if WinClass != #32770

if ControlSendFlag = 1
{
	SendFlag = 0
	ControlSendFlag = 0
	keys = %keys%`, %WinTitle%`n%ExtraSleep% `;SpecialSleep`n ; Very complicated, but needed to pad time when waiting for a file to load
	Controlname = 	;Delete Last Controlname on Windowchange
	
}
else if SendFlag = 1

{
	SendFlag = 0
	keys = %keys%`n%ExtraSleep% `;SpecialSleep`n ; Very complicated, but needed to pad time when waiting for a file to load
	

}

return

;Set constants
InitStyle:
;Borderstyles
BS_PUSHBUTTON = 0x0
BS_DEFPUSHBUTTON = 0x1
BS_CHECKBOX = 0x2
BS_AUTOCHECKBOX = 0x3
BS_RADIOBUTTON = 0x4 
BS_3STATE = 0x5
BS_AUTO3STATE = 0x6
BS_GROUPBOX = 0x7
BS_AUTORADIOBUTTON = 0x9
;BS_PUSHLIKE = 0x1000

;Constants for retreive/set 3rd state of a checkbox
BM_GETSTATE = 0xF2
BST_UNCHECKED = 0x0
BST_CHECKED = 0x1
BST_INDETERMINATE = 0x2
BM_SETCHECK = 0xF1
return

Reload:
Reload ; Should reload bring back GUI?  Presently it kills GUI and starts again in traymenu

Pause::Pause
Reload ; Why?  Pause should mean pause?

Esc::ExitApp

CloseHelpers:

DetectHiddenWindows, On  
SetTitleMatchMode, 2

winclose, AutoCompleteASW_2.ahk
winclose, AssistHelpASW_2.ahk

Return

ButtonClose:

Recording = 0
ToolTipOption = 0
SetTimer, Check_Modifier_Keys, Off
Gui, Destroy
FileDelete, %File%
ScriptHold := ""
SelectedExe := ""
ExeHold := 
GoSub, CloseHelpers

Return

GuiClose:  ; User closed the window.

Recording = 0
ToolTipOption = 0
SetTimer, Check_Modifier_Keys, Off
Gui, Destroy
FileDelete, %File%
ScriptHold := ""
SelectedExe := ""
ExeHold := ""
GoSub, CloseHelpers
ExitApp


Return

ProgramExit:

GoSub, GuiClose
Exit
ExitApp

This is a separate helper script, for doing auto complete and based on scripts from the old website. AutoCompleteASW_2.ahk

Code: Select all

;AutoCompleteASW_2
#Persistent
SetTimer, CheckNotExist, 120000, 10000
SetKeyDelay, 0
SetBatchLines, 5ms
SetTitleMatchMode, Slow
CoordMode, ToolTip, Relative
AutoTrim, Off

;_______________________________________

;    CONFIGURATIONS


ETitle = AHK ScriptWriter v 030 Alpha

WLen = 2
; Press F4 to complete command
; Escape & Enter clear command

;_______________________________________

;Gets path to AutoHotkey
;RegRead, AHKPATH, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Run\Command,
;StringGetPos, POS, AHKPATH, \AutoHotkey.exe
;StringLeft, AHKPATH, AHKPATH, %POS%
;StringReplace, AHKPATH, AHKPATH, ",, A

;reads command syntaxes
Loop, Read, %A_ScriptDir%\Wordlist_AHK_API.txt
{
	tosend = %a_loopreadline%

	StringReplace, tosend, tosend, }, +], a
	StringReplace, tosend, tosend, {, +[, a
	StringReplace, tosend, tosend, #, {#}, a
	StringReplace, tosend, tosend, ``n, {enter}, a
	StringReplace, tosend, tosend, ``t, {tab}, a
	StringReplace, tosend, tosend, ``b, {bs}, a

	cmd%a_index% = %toSend%
}

Loop
{
	;Editor window check
	Gosub, CheckNotExist
	WinGetActiveTitle, ATitle
	IfNotInString, ATitle, %ETitle%
	{
		ToolTip
		Setenv, Word,
		sleep, 500
		Continue
	}
	
	;Get one key at a time
	Input, chr, L1 V, {enter}{F4}{bs}{esc}{del}{Space}
	EndKey = %errorlevel%
	
	;Blanks word reserve
	ifequal, EndKey, Endkey:Enter, Setenv, Word,
	ifequal, EndKey, Endkey:Escape, Setenv, Word,
	Ifequal, EndKey, Endkey:Delete, Setenv, Word,
		
	;Backspace clears last letter
	ifequal, EndKey, Endkey:BackSpace, StringTrimRight, Word, Word, 1
	ifnotequal, EndKey, Endkey:BackSpace, Setenv, Word, %word%%chr%
		
	;Gosub, check if main script active. 
	
	Ifequal, EndKey, Endkey:Space
	{
		Gosub, CheckNotExist
	}	
	
	;Wait till minimum letters
	StringLen, len, Word
	IfLess, len, %wlen%
	{
		ToolTip
		Continue
	}
	
	;Match part-word with command
	Num =
	Match =
	Loop
	{
		IfEqual, cmd%a_index%,, Break
		StringLen, len, word
		StringLeft, check, cmd%a_index%, %len%
		IfEqual, word, %check%
		{
			num = %a_index%
			break
		}
	}
	
	;If no match then clear Tip
	IfEqual, Num,
	{
		ToolTip
		Continue
	}
	
	;Show matched command
	StringTrimLeft, match, cmd%num%, 0
	display_y = %A_CaretY%
	display_y -= 20 ; Move tooltip up a little so as not to hide the caret.
	IfNotEqual, Word,,ToolTip, %match%, %A_CaretX%, %display_y%
	
	;Complete command
	IfNotEqual, Word,, IfEqual, EndKey, Endkey:F4
	{
		StringLen, len, Word
		Send, {BS %len%}%match%
		Word =
		ToolTip
	}
}

return

CheckNotExist:

If !WinExist("AHK ScriptWriter v 030 Alpha")
{
	If !WinExist("ASWv030")
    {	
      IfNotExist, A_Temp . "\TempPlay.ahk" 
      {
      ToolTip, AHK ScriptWriter not found so exiting...
      Sleep, 5000
      ToolTip
      ExitApp
      }
    } 
  return
}

return
Assist_Help_2.ahk, works by selecting the word, and then pressing F2. This will automatically look up the world in the AutoHotKey help file.

Code: Select all

;Assist_Help_2.ahk
#SingleInstance Force
;SetTitleMatchMode RegEx


;#IfWinActive .*\.(\w+) - Notepad
F2::Gosub CopyandShow
Return

CopyAndShow:  
  ; Extract extension from the window title
  WinGetTitle WinTitle, A
  ;RegExMatch( WinTitle, ".*\.(\w+) - Notepad", RX_Token )
  ;Lang := RX_Token1
  
  ; First, assume we have a text already selected and try to copy it
  Clipboard = 
  SendInput ^c
  ClipWait 0.5
  
  ; If we got nothing, attempt to make a selection where the cursor is
  If( Clipboard = "" ) 
  {
    SendInput ^{Left}^+{Right}^c
    ClipWait 1
  }
  If( Clipboard = "" )
    Return
    
  ; Trim spaces and launch the CHM
WordHold = %Clipboard%
Clipboard := RegexReplace( WordHold, "\W", "" )
Gosub, DoHelp  
Return


DoHelp:

WinActivate, AutoHotkey Help,,,
ControlFocus, Edit1, AutoHotkey Help
SendInput, {BS 44}
SendInput, {Del 44}
Sleep, 300
Send, ^v
Send, {Enter}
Return
These are AutoHotKey Commands used by . This is WordList_AHK_API.txt, a little old, but usable. F2 shows AutoHotKey commands as you type, and F4 would complete them by adding from the list in this text. You can also modify this to add bits of your own example code.

Code: Select all

#ClipboardTimeout Milliseconds \nChanges how long the script keeps trying to access the clipboard when the first attempt fails.
#CommentFlag NewString \nNot recommended
#ErrorStdOut
#EscapeChar NewChar \nNot recommended
#HotkeyInterval Value
#HotkeyModifierTimeout Milliseconds
#Hotstring NewOptions
#If [expression] \nMakes subsequent hotkeys and hotstrings only function when the specified expression is true.
#IfTimeout timeout \nSets the maximum time that may be spent evaluating a single #If expression.
#IfWinActive [, WinTitle, WinText] \nMakes subsequent hotkeys and hotstrings only function when the specified window is active.
#IfWinExist [, WinTitle, WinText] \nMakes subsequent hotkeys and hotstrings only function when the specified window exists.
#IfWinNotActive [, WinTitle, WinText] \nMakes subsequent hotkeys and hotstrings only function when the specified window is not active.
#IfWinNotExist [, WinTitle, WinText] \nMakes subsequent hotkeys and hotstrings only function when the specified window doesn't exist.
#Include FileName \nCauses the script to behave as though the specified file's contents are present at this exact position.
#IncludeAgain FileName \nCauses the script to behave as though the specified file's contents are present at this exact position.
#InputLevel [, Level] \nControls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.
#InstallKeybdHook
#InstallMouseHook
#KeyHistory MaxEvents
#LTrim [On|Off]
#MaxHotkeysPerInterval Value
#MaxMem ValueInMegabytes
#MaxThreads Value
#MaxThreadsBuffer On|Off
#MaxThreadsPerHotkey Value
#MenuMaskKey keyname \nChanges which key is used to mask Win or Alt keyup events.
#NoEnv
#NoTrayIcon
#Persistent
#SingleInstance [Force|Ignore|Off]
#UseHook [On|Off]
#Warn [WarningType, WarningMode] \nEnables or disables warnings for selected load-time or run-time conditions that may be indicative of developer errors.
#WinActivateForce
AutoTrim , On|Off
BlockInput , On|Off|Send|Mouse|SendAndMouse|Default|MouseMove|MouseMoveOff
break [, LoopLabel]
Click
ClipWait [, SecondsToWait, 1]
catch [, OutputVar]
continue [, LoopLabel]
Control, Cmd [, Value, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlClick [, Control-or-Pos, WinTitle, WinText, WhichButton, ClickCount, Options, ExcludeTitle, ExcludeText]
ControlFocus [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlGet, OutputVar, Cmd [, Value, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlGetFocus, OutputVar [WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlGetPos [, X, Y, Width, Height, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlGetText, OutputVar [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlMove, Control, X, Y, Width, Height [, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlSend [, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlSendRaw [, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]
ControlSetText, Control, NewText [, WinTitle, WinText, ExcludeTitle, ExcludeText]
CoordMode, ToolTip|Pixel|Mouse|Caret|Menu [, Screen|Relative|Window|Client]
Critical [, Off]
DetectHiddenText, On|Off
DetectHiddenWindows, On|Off
Drive, Sub-command [, Drive , Value]
DriveGet, OutputVar, Cmd [, Value]
DriveSpaceFree, OutputVar, Path
Edit
else
EnvAdd, Var, Value [, TimeUnits]
EnvDiv, Var, Value
EnvGet, OutputVar, EnvVarName
EnvMult, Var, Value
EnvSet, EnvVar, Value
EnvSub, Var, Value [, TimeUnits]
EnvUpdate
Exit [, ExitCode]
ExitApp [, ExitCode]
FileAppend [, Text, Filename, Encoding]
FileCopy, Source, Dest [, Flag (1 = overwrite)]
FileCopyDir, Source, Dest [, Flag (1 = overwrite)]
FileCreateDir, Path
FileCreateShortcut, Target, ShortcutFile [, WorkingDir, Args, Description, IconFile, ShortcutKey, IconNumber, RunState]
FileDelete, FilePattern
FileEncoding [, CPnnn|UTF-8/16[-RAW] ] \nSets the default encoding for FileRead, FileReadLine, Loop Read, FileAppend, and FileOpen.
FileGetAttrib, OutputVar(RASHNDOCT) [, Filename]
FileGetShortcut, ShortcutFile [, OutTarget, OutDir, OutArgs, OutDescription, OutIcon, OutIconNum, OutRunState]
FileGetSize, OutputVar [, Filename, Units]
FileGetTime, OutputVar [, Filename, WhichTime (M (default), C, or A)]
FileGetVersion, OutputVar [, Filename]
FileInstall, Source, Dest [, Flag (1 = overwrite)]
FileMove, Source, Dest [, Flag (1 = overwrite)]
FileMoveDir, Source, Dest [, Flag (2 = overwrite, R = rename)]
FileRead, OutputVar, Filename
FileReadLine, OutputVar, Filename, LineNum
FileRecycle, FilePattern
FileRecycleEmpty [, Path]
FileRemoveDir, Path [, Recurse? (1 = yes)]
FileSelectFile, OutputVar [, Options, RootDir[\\DefaultFilename], Prompt, Filter]
FileSelectFolder, OutputVar [, *StartingFolder, Options, Prompt]
FileSetAttrib, Attributes(+-^RASHNOT) [, FilePattern, OperateOnFolders?, Recurse?]
FileSetTime [, YYYYMMDDHH24MISS, FilePattern, WhichTime (M|C|A), OperateOnFolders?, Recurse?]
finally
for key [,val] in obj
FormatTime, OutputVar [, YYYYMMDDHH24MISS, Format]
GetKeyState, OutputVar, WhichKey [, Mode (P|T)]
gosub, Label \nJumps to the specified label and continues execution until Return is encountered.
goto, Label \nJumps to the specified label and continues execution.
GroupActivate, GroupName [, R]
GroupAdd, GroupName, WinTitle [, WinText, Label, ExcludeTitle, ExcludeText]
GroupClose, GroupName [, A|R]
GroupDeactivate, GroupName [, R]
Gui, sub-command [, Param2, Param3, Param4]
GuiControl, Sub-command, ControlID [, Param3]
GuiControlGet, OutputVar [, Sub-command, ControlID, Param4]
Hotkey, KeyName [, Label, Options]
if Var = Value\n{\n	commands\n}else{\n	commands\n} \nSpecifies the command(s) to perform if Var = Value (can be for other operators).
if (Expression){\n	commands\n}else{\n	commands\n} \nSpecifies the command(s) to perform if an expression evaluates to TRUE.
if Var [not] between Low and High
if Var [not] contains value1,value2,...
if Var [not] in value1,value2,...
if Var is [not] integer|float|number|digit|xdigit|alpha|upper|lower|alnum|space|time
IfEqual, var, value
IfExist, File|Dir|Pattern
IfGreater, var, value
IfGreaterOrEqual, var, value
IfInString, Var, SearchString
IfLess, var, value
IfLessOrEqual, var, value
IfMsgBox, Yes|No|OK|Cancel|Abort|Ignore|Retry|Timeout
IfNotEqual, var, value
IfNotExist, File|Dir|Pattern
IfNotInString, Var, SearchString
IfWinActive [, WinTitle, WinText, ExcludeTitle, ExcludeText]
IfWinExist [, WinTitle, WinText, ExcludeTitle, ExcludeText]
IfWinNotActive [, WinTitle, WinText, ExcludeTitle, ExcludeText]
IfWinNotExist [, WinTitle, WinText, ExcludeTitle, ExcludeText]
ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
IniDelete, Filename, Section [, Key]
IniRead, OutputVar, Filename [, Section, Key, Default]
IniWrite, Value, Filename, Section [, Key]
Input [, OutputVar, Options, EndKeys, MatchList]
InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default]
KeyHistory
KeyWait, KeyName [, Options]
ListHotkeys
ListLines
ListVars
Loop [, Count]\nLoop, Files, FilePattern [, Mode]\nLoop, Parse, InputVar [, Delimiters|CSV, OmitChars]\nLoop, Read, InputFile [, OutputFile]\nLoop, Reg, RootKey[\\Key, Mode]\n{\n	commands\n} \nPerforms a repetition/file/file reading/parsing/registry loop.
Menu, MenuName, Cmd [, P3, P4, P5]
MouseClick, WhichButton [, X, Y, ClickCount, Speed, D|U, R]
MouseClickDrag, WhichButton, X1, Y1, X2, Y2 [, Speed, R]
MouseGetPos [, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, 1|2|3]
MouseMove, X, Y [, Speed, R]
MsgBox [, Options, Title, Text, Timeout] \nDisplays the specified text in a small window containing one or more buttons  (such as Yes and No).
OnExit [, Label]
OutputDebug, Text
Pause [, On|Off|Toggle, OperateOnUnderlyingThread?]
PixelGetColor, OutputVar, X, Y [, Alt|Slow|RGB]
PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID [, Variation, Fast|RGB]
PostMessage, Msg [, wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
Process, Cmd, PID-or-Name [, Param3]
Progress, Param1 [, SubText, MainText, WinTitle, FontName]
Random, OutputVar [, Min, Max]
RegDelete, RootKey\\SubKey [, ValueName]
RegRead, OutputVar, RootKey\\SubKey [, ValueName]
RegWrite, ValueType, RootKey\\SubKey [, ValueName, Value]
Reload
return [Expression]
Run, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID]
RunAs [, User, Password, Domain] 
RunWait, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID]
Send, Keys
SendEvent, Keys
SendInput, Keys
SendLevel [, Level] \nControls which artificial keyboard and mouse events are ignored by hotkeys and hotstrings.
SendMessage, Msg [, wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
SendMode, Event|Play|Input|InputThenPlay
SendPlay, Keys
SendRaw, Keys
SetBatchLines, -1 | 20ms | LineCount
SetCapsLockState, On|Off|AlwaysOn|AlwaysOff
SetControlDelay, Delay
SetDefaultMouseSpeed, Speed
SetEnv, Var, Value
SetFormat, FloatFast|IntegerFast, TotalWidth.DecimalPlaces|H|D
SetKeyDelay [, Delay, PressDuration]
SetMouseDelay, Delay
SetNumLockState, On|Off|AlwaysOn|AlwaysOff
SetRegView, RegView \nSets the default encoding for FileRead, FileReadLine, Loop Read, FileAppend, and FileOpen.
SetScrollLockState, On|Off|AlwaysOn|AlwaysOff
SetStoreCapslockMode, On|Off
SetTimer, Label [, Period|On|Off]
SetTitleMatchMode, Fast|Slow|RegEx|1|2|3
SetWinDelay, Delay
SetWorkingDir, DirName
Shutdown, Code
Sleep, Delay
Sort, VarName [, Options]
SoundBeep [, Frequency, Duration]
SoundGet, OutputVar [, ComponentType, ControlType, DeviceNumber]
SoundGetWaveVolume, OutputVar [, DeviceNumber]
SoundPlay, Filename [, wait]
SoundSet, NewSetting [, ComponentType, ControlType, DeviceNumber]
SoundSetWaveVolume, Percent [, DeviceNumber]
SplashImage [, ImageFile, Options, SubText, MainText, WinTitle, FontName]
SplashTextOff
SplashTextOn [, Width, Height, Title, Text]
SplitPath, InputVar [, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive]
StatusBarGetText, OutputVar [, Part#, WinTitle, WinText, ExcludeTitle, ExcludeText]
StatusBarWait [, BarText, Seconds, Part#, WinTitle, WinText, Interval, ExcludeTitle, ExcludeText]
StringCaseSense, On|Off|Locale
StringGetPos, OutputVar, InputVar, SearchText [, L#|R#, Offset]
StringLeft, OutputVar, InputVar, Count
StringLen, OutputVar, InputVar
StringLower, OutputVar, InputVar [, T]
StringMid, OutputVar, InputVar, StartChar [, Count, L]
StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, All]
StringRight, OutputVar, InputVar, Count
StringSplit, OutputArray, InputVar [, Delimiters, OmitChars]
StringTrimLeft, OutputVar, InputVar, Count
StringTrimRight, OutputVar, InputVar, Count
StringUpper, OutputVar, InputVar [, T]
Suspend [, On|Off|Toggle|Permit]
SysGet, OutputVar, Sub-command [, Param3]
Thread, Setting, P2 [, P3]
throw Expression
ToolTip [, Text, X, Y, WhichToolTip]
Transform, OutputVar, Cmd, Value1 [, Value2]
TrayTip [, Title, Text, Seconds, Options]
try
until Expression
URLDownloadToFile , URL, Filename
while Expression
WinActivate [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinActivateBottom [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinClose [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]
WinGet, OutputVar [, Cmd, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinGetActiveStats, Title, Width, Height, X, Y
WinGetActiveTitle, OutputVar
WinGetClass, OutputVar [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinGetPos [, X, Y, Width, Height, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinGetText, OutputVar [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinGetTitle, OutputVar [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinHide [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinKill [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]
WinMaximize [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinMenuSelectItem , WinTitle, WinText, Menu [, SubMenu1, SubMenu2, SubMenu3, SubMenu4, SubMenu5, SubMenu6, ExcludeTitle, ExcludeText]
WinMinimize [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinMinimizeAll
WinMinimizeAllUndo
WinMove, WinTitle, WinText, X, Y [, Width, Height, ExcludeTitle, ExcludeText]
WinRestore [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinSet, AlwaysOnTop|Trans, On|Off|Toggle|Value(0-255) [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinSetTitle, WinTitle, WinText, NewTitle [, ExcludeTitle, ExcludeText]
WinShow [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinWait, WinTitle, WinText, Seconds [, ExcludeTitle, ExcludeText]
WinWaitActive [, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText]
WinWaitClose, WinTitle, WinText, Seconds [, ExcludeTitle, ExcludeText]
WinWaitNotActive [, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText]

Abs(Number)
ACos(Number)
Asc(String) \n[DEPRECATED - Use Ord]
ASin(Number)
ATan(Number)
Ceil(Number)
Chr(Number)
Cos(Number)
DllCall("[DllFile\\]Function" [, Type1, Arg1, Type2, Arg2, ..., "Cdecl ReturnType"])
Exception(message [, what, extra])
Exp(Number)
FileExist("FilePattern")
Floor(Number)
Format(FormatStr [, Values...]) \nFormats a variable number of input values according to a format string.
GetKeyState(KeyName [, "P" or "T"])
IL_Add(ImageListID, Filename [, IconNumber, ResizeNonIcon?])
IL_Create([InitialCount, GrowCount, LargeIcons?])
IL_Destroy(ImageListID)
InStr(Haystack, Needle [, CaseSensitive?, StartingPos, Occurrence])
IsFunc(FunctionName)
IsLabel(LabelName)
Ln(Number)
Log(Number)
LV_Add([Options, Col1, Col2, ...])
LV_Delete([RowNumber])
LV_DeleteCol(ColumnNumber)
LV_GetCount(["S|C"])
LV_GetNext([StartingRowNumber, "C|F"])
LV_GetText(OutputVar, RowNumber [, ColumnNumber])
LV_Insert(RowNumber [, Options, Col1, Col2, ...])
LV_InsertCol(ColumnNumber [, Options, ColumnTitle])
LV_Modify(RowNumber, Options [, NewCol1, NewCol2, ...])
LV_ModifyCol([ColumnNumber, Options, ColumnTitle])
LV_SetImageList(ImageListID [, 0|1|2])
Mod(Dividend, Divisor)
NumGet(VarOrAddress [, Offset := 0] [, Type := "UPtr"])
NumPut(Number, VarOrAddress [, Offset := 0] [, Type := "UPtr"])
OnClipboardChange(Func [, AddRemove])
OnExit(Func [, AddRemove])
OnMessage(MsgNumber [, Function, MaxThreads])
Ord(String) \nReturns the ordinal value (numeric character code) of the first character in String.
RegExMatch(Haystack, NeedleRegEx [, UnquotedOutputVar := "", StartingPos := 1])
RegExReplace(Haystack, NeedleRegEx [, Replacement := "", OutputVarCount := "", Limit := -1, StartingPos := 1])
RegisterCallback("FunctionName" [, Options := "", ParamCount := FormalCount, EventInfo := Address])
Round(Number [, Places])
SB_SetIcon(Filename [, IconNumber, PartNumber])
SB_SetParts([Width1, Width2, ... Width255])
SB_SetText(NewText [, PartNumber, Style])
Sin(Number)
Sqrt(Number)
StrLen(String)
SubStr(String, StartingPos [, Length])
StrReplace(Haystack, SearchText [, ReplaceText, OutputVarCount, Limit := -1]) \nReplaces the specified substring with a new string.
StrSplit(String [, Delimiters, OmitChars])
Tan(Number)
TV_Add(Name, [ParentItemID, Options])
TV_Delete([ItemID])
TV_GetChild(ParentItemID)
TV_GetCount()
TV_GetNext([ItemID, "Checked | Full"])
TV_Get(ItemID, "Expand | Check | Bold")
TV_GetParent(ItemID)
TV_GetPrev(ItemID)
TV_GetSelection()
TV_GetText(OutputVar, ItemID)
TV_Modify(ItemID [, Options, NewName])
TV_SetImageList(ImageList [, 0|2])
VarSetCapacity(Var [, RequestedCapacity, FillByte])
WinActive(["WinTitle", "WinText", "ExcludeTitle", "ExcludeText"])
WinExist(["WinTitle" , "WinText", "ExcludeTitle", "ExcludeText"])

Trim(string [, omitchars := " `t"]) \nTrims characters from the beginning and end of a string.
LTrim(string [, omitchars := " `t"]) \nTrims characters from the beginning of a string.
RTrim(string [, omitchars := " `t"]) \nTrims characters from the end of a string.

FileOpen(file, mode[, encoding]) \nOpens a file and returns a new file object.
StrGet(address [, max][, encoding]) \nRetrieves the null-terminated string at the specified address.
StrPut(string [, encoding]) \nRetrieves the amount of characters (not bytes) that a string copy requires.
StrPut(string, address [, max] [, encoding]) \nCopies a string to the specified location.

GetKeyName(key)
GetKeyVK(key)
GetKeySC(key)
IsByRef(var)

Object([key, value, [key2, value2...]]) \nCreates a scriptable object which is also an associative array.
Object(obj) \nRetrieves an interface pointer from an object reference or vice versa.
Array([values...]) \nCreates an array.
IsObject(param) \nTests if the parameter is an object.
ObjInsert(obj, index, values...) \n[DEPRECATED - USE .InsertAt/.Push/ObjRawSet]
ObjInsert(obj, value) \n[DEPRECATED - USE .InsertAt/.Push/ObjRawSet]
ObjInsert(obj, key, value) \n[DEPRECATED - USE .InsertAt/.Push/ObjRawSet]
ObjRemove(obj, key) \n[DEPRECATED - USE .RemoveAt/.Delete/.Pop]
ObjRemove(obj, first, last) \n[DEPRECATED - USE .RemoveAt/.Delete/.Pop]
ObjRemove(obj, intkey, "") \n[DEPRECATED - USE .RemoveAt/.Delete/.Pop]
ObjMinIndex(obj)
ObjMaxIndex(obj)
ObjSetCapacity(obj, maxitems)
ObjSetCapacity(obj, key, bytesize)
ObjGetCapacity(obj[, key])
ObjGetAddress(obj, key)
ObjNewEnum(obj)
ObjAddRef(address)
ObjRelease(address)
ObjHasKey(obj, key)
ObjClone(obj)
ObjBindMethod(Obj, Method, Params) \nCreates a BoundFunc object which calls a method of a given object.
ObjRawSet(Obj, Key, Value) \nStores or overwrites a key-value pair in the object.
ObjInsertAt(Obj, Pos, Value1 [, Value2, ... ValueN]) \nInserts one or more values at a given position within a linear array.
ObjPush(Obj, Value [, Value2, ..., ValueN ]) \nAppends values to the end of an array.
ObjDelete(Obj, Key) \nRemoves key-value pairs from an object.
ObjDelete(Obj, FirstKey, LastKey) \nRemoves key-value pairs from an object.
ObjRemoveAt(Obj, Pos [, Length]) \nRemoves items from the given position in a linear array.
ObjPop(Obj) \nRemoves and returns the last array element.
ObjLength(Obj) \nReturns the length of a linear array beginning at position 1.

__Get([params...])
__Set([params...,] value)
__Call([params...])
__Delete()
__New([params...])

_NewEnum() \nObject method which returns an enumerator object, required by the for command.

class ClassName [extends ClassName]
new
extends

ComObjCreate(ProgIdOrCLSID [, IID]) \nCreates a COM object.
ComObjGet(name) \nReturns a reference to an object provided by a COM component.
ComObjConnect(obj [, funcPrefixOrObj])  \nListens to events from a ComObject (omit the 2nd parameter to stop listening).
ComObjError([Enable])\nEnables or disables notification of COM errors. If Enable is omitted, the current setting is returned.
ComObjActive(ProgIdOrCLSID) \nRetrieves a running object that has been registered with OLE.
ComObject(vt, val [, flags]) \nCreates an object representing a typed value to be passed as a parameter or return value.
ComObjMissing() \n[DEPRECATED - Write consecutive commas instead]
ComObjEnwrap(pdisp) \n[DEPRECATED - Use ComObject(9,ptr,1) and ObjAddRef(ptr) instead]
ComObjUnwrap(obj) \n[DEPRECATED - Use ComObjValue(ptr) and ObjAddRef(ptr) instead]
ComObjType(obj [, "Name|IID"]) \nRetrieves type information for a COM object.
ComObjValue(obj) \nRetrieves the raw 64-bit signed integer stored in a ComObject wrapper.
ComObjArray(VarType, Count1 [, Count2, ... Count8]) \nCreates a SAFEARRAY for use with COM.
ComObjQuery(ComObject [, SID], IID) \nQueries a COM object for an interface or service.
ComObjFlags(ComObject [, NewFlags, Mask]) \nRetrieves or changes flags which control a COM wrapper object's behaviour.

Func(funcname)

.__Call([params...]) \n'Call' meta-function of a class or object.
.__Get([params...]) \n'Get' meta-function of a class or object.
.__Set([params...,] value) \n'Set' meta-function of a class or object.

.Clone() \nReturns a shallow copy of the object.
.GetAddress(Key) \nReturns the current address of the field's string buffer, if it has one.
.GetCapacity([Key]) \nReturns the current capacity of an object or one of its fields.
.HasKey(Key) \nReturns true if Key is associated with a value (even "") within Object, otherwise false.
.Insert(index, values...) \n[DEPRECATED - USE .InsertAt/.Push/ObjRawSet]
.Insert(value) \n[DEPRECATED - USE .InsertAt/.Push/ObjRawSet]
.Insert(key, value) \n[DEPRECATED - USE .InsertAt/.Push/ObjRawSet]
.MaxIndex() \nIf any integer keys are present, returns the highest. Otherwise an empty string is returned.
.MinIndex() \nIf any integer keys are present, returns the lowest. Otherwise an empty string is returned.
._NewEnum() \nReturns a new enumerator to enumerate this object's key-value pairs.
.Remove(key) \n[DEPRECATED - USE .RemoveAt/.Delete/.Pop]
.Remove(first, last) \n[DEPRECATED - USE .RemoveAt/.Delete/.Pop]
.Remove(intkey, "") \n[DEPRECATED - USE .RemoveAt/.Delete/.Pop]
.SetCapacity(Key, ByteSize) \nAdjusts the capacity of an object field.
.SetCapacity(MaxItems) \nAdjusts the capacity of an object.

.InsertAt(Pos, Value1 [, Value2, ... ValueN]) \nInserts one or more values at a given position within a linear array.
.Push(Value [, Value2, ..., ValueN ]) \nAppends values to the end of an array.
.Delete(Key) \nRemoves key-value pairs from an object.
.Delete(FirstKey, LastKey) \nRemoves key-value pairs from an object.
.RemoveAt(Pos [, Length]) \nRemoves items from the given position in a linear array.
.Pop() \nRemoves and returns the last array element.
.Length() \nReturns the length of a linear array beginning at position 1.

.Read([CharCount]) \n[File object] Reads a string of characters from the file and advances the file pointer.
.Write(String) \n[File object] Writes a string of characters to the file and advances the file pointer.
.ReadLine() \n[File object] Reads a line of text from the file and advances the file pointer.
.WriteLine([String]) \n[File object] Writes a string of characters followed by the newline sequence and advances the file pointer.
.RawRead(VarOrAddress, Bytes) \n[File object] Read raw binary data from the file into memory.
.RawWrite(VarOrAddress, Bytes) \n[File object] Write raw binary data to the file.
.ReadUChar() \n[File object] Reads a little-endian unsigned 8-bit number from the file and advances the file pointer.
.ReadChar() \n[File object] Reads a little-endian signed 8-bit number from the file and advances the file pointer.
.ReadUShort() \n[File object] Reads a little-endian unsigned 16-bit number from the file and advances the file pointer.
.ReadShort() \n[File object] Reads a little-endian signed 16-bit number from the file and advances the file pointer.
.ReadUInt() \n[File object] Reads a little-endian unsigned 32-bit number from the file and advances the file pointer.
.ReadInt() \n[File object] Reads a little-endian signed 32-bit number from the file and advances the file pointer.
.ReadInt64() \n[File object] Reads a little-endian 64-bit number from the file and advances the file pointer.
.ReadFloat() \n[File object] Reads a little-endian 32-bit floating point number from the file and advances the file pointer.
.ReadDouble() \n[File object] Reads a little-endian 64-bit floating point number from the file and advances the file pointer.
.WriteUChar(num) \n[File object] Writes a little-endian unsigned 8-bit number to the file and advances the file pointer.
.WriteChar(num) \n[File object] Writes a little-endian signed 8-bit number to the file and advances the file pointer.
.WriteUShort(num) \n[File object] Writes a little-endian unsigned 16-bit number to the file and advances the file pointer.
.WriteShort(num) \n[File object] Writes a little-endian signed 16-bit number to the file and advances the file pointer.
.WriteUInt(num) \n[File object] Writes a little-endian unsigned 32-bit number to the file and advances the file pointer.
.WriteInt(num) \n[File object] Writes a little-endian signed 32-bit number to the file and advances the file pointer.
.WriteInt64(num) \n[File object] Writes a little-endian 64-bit number to the file and advances the file pointer.
.WriteFloat(num) \n[File object] Writes a little-endian 32-bit floating point number to the file and advances the file pointer.
.WriteDouble(num) \n[File object] Writes a little-endian 64-bit floating point number to the file and advances the file pointer.
.Seek(Distance [, Origin := 0]) \n[File object] Moves the file pointer.
.Position
.Pos
.AtEOF
.Close() \n[File object] Closes the file, flushes any data in the cache to disk and releases the share locks.
.Encoding
.__Handle

.Name
.IsBuiltIn
.IsVariadic
.MinParams
.MaxParams
.IsByRef(index) \n[Func object] Determines whether a parameter is ByRef.
.IsOptional(index) \n[Func object] Determines whether a parameter is optional.
.Call(Parameters) \n[Func object] Calls the function.
.Bind(Parameters) \n[Func object] Binds parameters to the function and returns a BoundFunc object.

Shift
LShift
RShift
Alt
LAlt
RAlt
Control
LControl
RControl
Ctrl
LCtrl
RCtrl
LWin
RWin
AppsKey

AltDown
AltUp
ShiftDown
ShiftUp
CtrlDown
CtrlUp
LWinDown
LWinUp
RWinDown
RWinUp

LButton
RButton
MButton
WheelUp
WheelDown
WheelLeft
WheelRight
XButton1
XButton2

Joy1
Joy2
Joy3
Joy4
Joy5
Joy6
Joy7
Joy8
Joy9
Joy10
Joy11
Joy12
Joy13
Joy14
Joy15
Joy16
Joy17
Joy18
Joy19
Joy20
Joy21
Joy22
Joy23
Joy24
Joy25
Joy26
Joy27
Joy28
Joy29
Joy30
Joy31
Joy32
JoyX
JoyY
JoyZ
JoyR
JoyU
JoyV
JoyPOV
JoyName
JoyButtons
JoyAxes
JoyInfo

Space
Tab
Enter
Escape
Esc
BackSpace
Delete
Del
Insert
Ins
PGUP
PGDN
Home
End
Up
Down
Left
Right

PrintScreen
CtrlBreak
Pause
ScrollLock
CapsLock
NumLock

Numpad0
Numpad1
Numpad2
Numpad3
Numpad4
Numpad5
Numpad6
Numpad7
Numpad8
Numpad9
NumpadMult
NumpadAdd
NumpadSub
NumpadDiv
NumpadDot
NumpadDel
NumpadIns
NumpadClear
NumpadUp
NumpadDown
NumpadLeft
NumpadRight
NumpadHome
NumpadEnd
NumpadPgup
NumpadPgdn
NumpadEnter

F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24

Browser_Back
Browser_Forward
Browser_Refresh
Browser_Stop
Browser_Search
Browser_Favorites
Browser_Home
Volume_Mute
Volume_Down
Volume_Up
Media_Next
Media_Prev
Media_Stop
Media_Play_Pause
Launch_Mail
Launch_Media
Launch_App1
Launch_App2

Pixel
Mouse
Screen
Relative
RGB

LTrim
RTrim
Join

Low
BelowNormal
Normal
AboveNormal
High
Realtime

ahk_id
ahk_pid
ahk_class
ahk_group
ahk_exe

between
contains
in
Integer
Float
IntegerFast
FloatFast
number
digit
xdigit
alpha
upper
lower
alnum
time
date

not
or
and

AlwaysOnTop
Topmost
Top
Bottom
Transparent
TransColor
Redraw
Region
ID
IDLast
ProcessName
ProcessPath
MinMax
ControlList
Count
List
Capacity
StatusCD
Eject
Lock
Unlock
Label
FileSystem
Label
SetLabel
Serial
Type
Status

static
global
local
ByRef

Seconds
Minutes
Hours
Days

Read
Parse

Logoff
Close
Error
Single

Tray
Add
Rename
Check
UnCheck
ToggleCheck
Enable
Disable
ToggleEnable
Default
NoDefault
Standard
NoStandard
Color
Delete
DeleteAll
Icon
NoIcon
Tip
Click
Show
MainWindow
NoMainWindow
UseErrorLevel

Text
Picture
Pic
GroupBox
Button
Checkbox
Radio
DropDownList
DDL
ComboBox
ListBox
ListView
DateTime
MonthCal
Slider
StatusBar
Tab
Tab2
TreeView
UpDown
ActiveX
Link
Custom

IconSmall
Tile
Report
SortDesc
NoSort
NoSortHdr
Grid
Hdr
AutoSize
Range

Font
Resize
Owner
Submit
NoHide
Minimize
Maximize
Restore
NoActivate
NA
Cancel
Destroy
Center
DPIScale

Margin
MaxSize
MinSize
OwnDialogs
GuiEscape
GuiClose
GuiSize
GuiContextMenu
GuiDropFiles
OnClipboardChange

TabStop
Section
AltSubmit
Wrap
HScroll
VScroll
Border
Top
Bottom
Buttons
Expand
First
ImageList
Lines
WantCtrlA
WantF2
Vis
VisFirst
Number
Uppercase
Lowercase
Limit
Password
Multi
WantReturn
Group
Background
bold
italic
strike
underline
norm
BackgroundTrans
Theme
Caption
Delimiter
MinimizeBox
MaximizeBox
SysMenu
ToolWindow
Flash
Style
ExStyle
Check3
Checked
CheckedGray
ReadOnly
Password
Hidden
Left
Right
Center
NoTab
Section
Move
Focus
Hide
Choose
ChooseString
Text
Pos
Enabled
Disabled
Visible
LastFound
LastFoundExist

AltTab
ShiftAltTab
AltTabMenu
AltTabAndMenu
AltTabMenuDismiss

NoTimers
Interrupt
Priority
WaitClose
Wait
Exist
Close

Blind
Raw
AltDown
AltUp
ShiftDown
ShiftUp
CtrlDown
CtrlUp
LWinDown
LWinUp
LWinDown
RWinUp

Unicode
ToCodePage
FromCodePage
Deref
Pow
BitNot
BitAnd
BitOr
BitXOr
BitShiftLeft
BitShiftRight

Yes
No
Ok
Cancel
Abort
Retry
Ignore
TryAgain

On
Off
All

HKEY_LOCAL_MACHINE
HKEY_USERS
HKEY_CURRENT_USER
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKLM
HKU
HKCU
HKCR
HKCC

REG_SZ
REG_EXPAND_SZ
REG_MULTI_SZ
REG_DWORD
REG_BINARY

UseUnsetLocal
UseUnsetGlobal
UseEnv
LocalSameAsGlobal

A_AhkPath
A_AhkVersion
A_AppData
A_AppDataCommon
A_AutoTrim
A_BatchLines
A_CaretX
A_CaretY
A_ComputerName
A_ControlDelay
A_Cursor
A_DD
A_DDD
A_DDDD
A_DefaultMouseSpeed
A_Desktop
A_DesktopCommon
A_DetectHiddenText
A_DetectHiddenWindows
A_EndChar
A_EventInfo
A_ExitReason
A_FileEncoding
A_FormatFloat
A_FormatInteger
A_Gui
A_GuiEvent
A_GuiControl
A_GuiControlEvent
A_GuiHeight
A_GuiWidth
A_GuiX
A_GuiY
A_Hour
A_IconFile
A_IconHidden
A_IconNumber
A_IconTip
A_Index
A_IPAddress1
A_IPAddress2
A_IPAddress3
A_IPAddress4
A_Is64bitOS
A_IsAdmin
A_IsCompiled
A_IsCritical
A_IsPaused
A_IsSuspended
A_IsUnicode
A_KeyDelay
A_Language
A_LastError
A_LineFile
A_LineNumber
A_LoopField
A_LoopFileAttrib
A_LoopFileDir
A_LoopFileExt
A_LoopFileFullPath
A_LoopFileLongPath
A_LoopFileName
A_LoopFileShortName
A_LoopFileShortPath
A_LoopFileSize
A_LoopFileSizeKB
A_LoopFileSizeMB
A_LoopFileTimeAccessed
A_LoopFileTimeCreated
A_LoopFileTimeModified
A_LoopReadLine
A_LoopRegKey
A_LoopRegName
A_LoopRegSubkey
A_LoopRegTimeModified
A_LoopRegType
A_MDay
A_Min
A_MM
A_MMM
A_MMMM
A_Mon
A_MouseDelay
A_MSec
A_MyDocuments
A_Now
A_NowUTC
A_NumBatchLines
A_OSType
A_OSVersion
A_PriorHotkey
A_PriorKey
A_ProgramFiles
A_Programs
A_ProgramsCommon
A_PtrSize
A_RegView
A_ScreenDPI
A_ScreenHeight
A_ScreenWidth
A_ScriptDir
A_ScriptFullPath
A_ScriptHwnd
A_ScriptName
A_Sec
A_Space
A_StartMenu
A_StartMenuCommon
A_Startup
A_StartupCommon
A_StringCaseSense
A_Tab
A_Temp
A_ThisFunc
A_ThisHotkey
A_ThisLabel
A_ThisMenu
A_ThisMenuItem
A_ThisMenuItemPos
A_TickCount
A_TimeIdle
A_TimeIdlePhysical
A_TimeSincePriorHotkey
A_TimeSinceThisHotkey
A_TitleMatchMode
A_TitleMatchModeSpeed
A_UserName
A_WDay
A_WinDelay
A_WinDir
A_WorkingDir
A_YDay
A_Year
A_YWeek
A_YYYY
Clipboard
ClipboardAll
ComSpec
ErrorLevel
ProgramFiles
true
false
This is ActiveWindowInfo and comes from https://github.com/fincs/SciTE4AutoHotk ... owInfo.ahk
Very useful, or you can use similar such tools, and is convenient for helping to write or troubleshoot with scripts.

Code: Select all

;
; Active Window Info
;

#NoEnv
#NoTrayIcon
#SingleInstance Ignore
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
CoordMode, Pixel, Screen

IfExist, ..\toolicon.icl ; Seems useful enough to support standalone operation.
	Menu, Tray, Icon, ..\toolicon.icl, 9

isUpd := true
txtNotFrozen := "(Win+A to freeze display)"
txtFrozen := "(Win+A to unfreeze display)"

Gui, New, hwndhGui AlwaysOnTop Resize MinSize
Gui, Add, Text,, Window Title, Class and Process:
Gui, Add, Edit, w320 r3 ReadOnly -Wrap vCtrl_Title
Gui, Add, Text,, Mouse Position:
Gui, Add, Edit, w320 r3 ReadOnly vCtrl_MousePos
Gui, Add, Text,, Control Under Mouse Position:
Gui, Add, Edit, w320 r3 ReadOnly vCtrl_MouseCur
Gui, Add, Text,, Active Window Position:
Gui, Add, Edit, w320 r2 ReadOnly vCtrl_Pos
Gui, Add, Text,, Status Bar Text:
Gui, Add, Edit, w320 r2 ReadOnly vCtrl_SBText
Gui, Add, Checkbox, vCtrl_IsSlow, Slow TitleMatchMode
Gui, Add, Text,, Visible Text:
Gui, Add, Edit, w320 r2 ReadOnly vCtrl_VisText
Gui, Add, Text,, All Text:
Gui, Add, Edit, w320 r2 ReadOnly vCtrl_AllText
Gui, Add, Text, w320 r1 vCtrl_Freeze, % txtNotFrozen
Gui, Show,, Active Window Info
GetClientSize(hGui, temp)
horzMargin := temp*96//A_ScreenDPI - 320
SetTimer, Update, 250
return

GuiSize:
Gui %hGui%:Default
if !horzMargin
	return
ctrlW := A_GuiWidth - horzMargin
list = Title,MousePos,MouseCur,Pos,SBText,VisText,AllText,Freeze
Loop, Parse, list, `,
	GuiControl, Move, Ctrl_%A_LoopField%, w%ctrlW%
return

Update:
Gui %hGui%:Default
curWin := WinExist("A")
if (curWin = hGui)
	return
WinGetTitle, t1
WinGetClass, t2
WinGet, t3, ProcessName
GuiControl,, Ctrl_Title, % t1 "`nahk_class " t2 "`nahk_exe " t3
CoordMode, Mouse, Screen
MouseGetPos, msX, msY, msWin, msCtrlHwnd, 2
CoordMode, Mouse, Relative
MouseGetPos, mrX, mrY,, msCtrl
CoordMode, Mouse, Client
MouseGetPos, mcX, mcY
GuiControl,, Ctrl_MousePos, % "Absolute:`t" msX ", " msY " (less often used)`nRelative:`t" mrX ", " mrY " (default)`nClient:`t" mcX ", " mcY " (recommended)"
PixelGetColor, mClr, %msX%, %msY%, RGB
mClr := SubStr(mClr, 3)
mText := "`nColor:`t" mClr " (Red=" SubStr(mClr, 1, 2) " Green=" SubStr(mClr, 3, 2) " Blue=" SubStr(mClr, 5) ")"
if (curWin = msWin)
{
	ControlGetText, ctrlTxt, %msCtrl%
	mText := "ClassNN:`t" msCtrl "`nText:`t" textMangle(ctrlTxt) mText
} else mText := "`n" mText
GuiControl,, Ctrl_MouseCur, % mText
WinGetPos, wX, wY, wW, wH
GetClientSize(curWin, wcW, wcH)
GuiControl,, Ctrl_Pos, % "x: " wX "`ty: " wY "`tw: " wW "`th: " wH "`nClient:`t`tw: " wcW "`th: " wcH
sbTxt := ""
Loop
{
	StatusBarGetText, ovi, %A_Index%
	if ovi =
		break
	sbTxt .= "(" A_Index "):`t" textMangle(ovi) "`n"
}
StringTrimRight, sbTxt, sbTxt, 1
GuiControl,, Ctrl_SBText, % sbTxt
GuiControlGet, bSlow,, Ctrl_IsSlow
SetTitleMatchMode, % bSlow ? "Slow" : "Fast"
DetectHiddenText, Off
WinGetText, ovVisText
DetectHiddenText, On
WinGetText, ovAllText
GuiControl,, Ctrl_VisText, % ovVisText
GuiControl,, Ctrl_AllText, % ovAllText
return

GuiClose:
ExitApp

GetClientSize(hWnd, ByRef w := "", ByRef h := "")
{
	VarSetCapacity(rect, 16)
	DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
	w := NumGet(rect, 8, "int")
	h := NumGet(rect, 12, "int")
}

textMangle(x)
{
	if pos := InStr(x, "`n")
		x := SubStr(x, 1, pos-1), elli := true
	if StrLen(x) > 40
	{
		StringLeft, x, x, 40
		elli := true
	}
	if elli
		x .= " (...)"
	return x
}

#a::
Gui %hGui%:Default
isUpd := !isUpd
SetTimer, Update, % isUpd ? "On" : "Off"
GuiControl,, Ctrl_Freeze, % isUpd ? txtNotFrozen : txtFrozen
return
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Google: floowsnaake
GitHub: floowsnaake
Contact:

Re: AHK ScriptWriter 0.31

12 Mar 2017, 14:03

Nice :D
:yawn:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Micahs, robodesign and 35 guests