Post by boiler » 24 Feb 2023, 21:49
How about these? They are largely the same as what was in the original but translated to v2 (the second one needed some additional code to get it to work since Windows' copy/paste is now slower than in older versions).
I kept the same leading two spaces before each line, which looks like is meant to help display it better in the code box.
Also, it looks like the Rosetta Code page that is linked next to those examples has some links in it that still point to v1 stuff.
Code: Select all
; hotstrings - expand 'btw' to 'By the way' as you type
::btw::By the way
; hotkeys - press winkey-z to go to Google
#z::Run "http://google.com"
Code: Select all
; copy text to the clipboard, modify it, paste it back
^+k:: ; ctrl-shift-k
{
ClipSave := ClipboardAll() ; store current clipboard
A_Clipboard := "" ; clear the clipboard
Send "^c" ; copy selected text
if ClipWait(1) ; wait up to a second for content
{
A_Clipboard := "<i>" A_Clipboard "</i>" ; wrap it in html-tags
Send "^v" ; paste
Sleep 500 ; wait for Windows to complete paste
}
A_Clipboard := ClipSave ; restore old clipboard content
ClipSave := "" ; clear variable
}
Code: Select all
; Easy to make GUIs
MyGui := Gui()
MyGui.Add("Text",, "Enter your name")
MyGui.Add("Edit", "w150 vName")
MyGui.Add("Button",, "OK").OnEvent("Click", SayHello)
MyGui.Show()
Return
SayHello(*)
{
Saved := MyGui.Submit()
MsgBox "Hello " Saved.Name
ExitApp
}
Code: Select all
; Array Objects
Colors := "Red,Green,Blue" ; string
ColorArray := StrSplit(Colors, ",") ; create array
ColorArray.Push("Purple") ; add data
for index, element in ColorArray ; Read from the array
MsgBox "Color " index " = " element
How about these? They are largely the same as what was in the original but translated to v2 (the second one needed some additional code to get it to work since Windows' copy/paste is now slower than in older versions).
I kept the same leading two spaces before each line, which looks like is meant to help display it better in the code box.
Also, it looks like the Rosetta Code page that is linked next to those examples has some links in it that still point to v1 stuff.
[code] ; hotstrings - expand 'btw' to 'By the way' as you type
::btw::By the way
; hotkeys - press winkey-z to go to Google
#z::Run "http://google.com"[/code]
[code] ; copy text to the clipboard, modify it, paste it back
^+k:: ; ctrl-shift-k
{
ClipSave := ClipboardAll() ; store current clipboard
A_Clipboard := "" ; clear the clipboard
Send "^c" ; copy selected text
if ClipWait(1) ; wait up to a second for content
{
A_Clipboard := "<i>" A_Clipboard "</i>" ; wrap it in html-tags
Send "^v" ; paste
Sleep 500 ; wait for Windows to complete paste
}
A_Clipboard := ClipSave ; restore old clipboard content
ClipSave := "" ; clear variable
}[/code]
[code] ; Easy to make GUIs
MyGui := Gui()
MyGui.Add("Text",, "Enter your name")
MyGui.Add("Edit", "w150 vName")
MyGui.Add("Button",, "OK").OnEvent("Click", SayHello)
MyGui.Show()
Return
SayHello(*)
{
Saved := MyGui.Submit()
MsgBox "Hello " Saved.Name
ExitApp
}[/code]
[code] ; Array Objects
Colors := "Red,Green,Blue" ; string
ColorArray := StrSplit(Colors, ",") ; create array
ColorArray.Push("Purple") ; add data
for index, element in ColorArray ; Read from the array
MsgBox "Color " index " = " element[/code]