1/* 2multiline comment 3msgbox(comment) 4*/ 5send, key[pgdn] 6string := "hello" . x . "world!" 7string := "hello ""world""! " 8string := "hello `"world""! " 9; single line comment1 10;;; single line comment2 11 12::stopi::viper_off() 13 14a::send, ^a 15mylabel:send, ^{space} ;; set mark 16e::send, ^e 17n:: 18 send, ^n 19 return 20!i:: 21viper("iviper") ; stdlib 22x = "viper"" " ; escaped quote 23Return 24#If WinExist("iviper" ) 25indexdir = %A_ScriptDir%\%dir% 26FileCreateDir, % indexdir 27fileindex = %indexdir%\_files 28FileSelectFile, file,,, Select an image:, Images (*.gif; *.jpg; *.bmp; *.png; *.tif; *.ico; *.cur; *.ani; *.exe; *.dll) 29 30; viper 31 32 33i::viper_off() 34#If 35 36;; keybindings 37#If WinExist("iviper") and WinActive("ahk_class Emacs") 38 39p:: 40k:: 41send, ^p 42return 43,::send, +!, ;; beginning of page 44.::send, +!. ;; end of page 45[::send, !a 46]::send, !e 47d:: ^k ;; kill line 48x:: send ^d 49\:: ^!k ;; kill next word or sexp 50 51 52#IfWinActive 53#Persistent 54 55F2:: ;; hotkey 56start: ;; label 57start2: ; label 58 ppm := ppm_new(50, 50, 255) 59 ppm_fill(ppm, 80, 90, 95) 60 msgbox % getPixel(ppm, 1, 1) 61 setPixel(90, 90, 90, ppm, 1, 1) 62 msgbox % getPixel(ppm, 1, 1) 63 ListVars ; command 64 msgbox % ppm 65 return 66 67 68 ppm_read(file) 69 { 70 fileread, ppm, % file 71 return ppm 72} 73 74::hotstring:: 75::hot3:: 76ppm_width(ppm) 77{ 78 regexmatch(ppm, "\R(\d+)\s(\d+)", dim) 79 return dim1 80} 81ppm_height(ppm) 82{ 83 regexmatch(ppm, "\R(\d+)\s(\d+)", dim) 84 return dim2 85} 86 87ppm_colors(ppm) 88{ 89regexmatch(ppm, "\R(\d+)\D*\R", colors) ; \R stands for any 90return colors1 91} 92 93ppm_data(ppm) 94{ 95pos := regexmatch(ppm, "\R(\d+)\D*\R", colors) ; \R stands for any newline 96stringtrimleft, data, ppm, pos + strlen(colors1) 97return data 98} 99ppm_header(ppm) 100{ 101pos := regexmatch(ppm, "\R(\d+)\D*\R", colors) ; \R stands for any newline 102stringleft, header, ppm, pos + strlen(colors1) 103return header 104} 105 106ppm_fill(ByRef ppm, r, g, b) 107{ 108 width := ppm_width(ppm) 109 height := ppm_height(ppm) 110 header := ppm_header(ppm) 111 headerLength := strlen(header) 112 varsetcapacity(data, width * height, 0) 113 loop, % (width * height) 114 { 115 if r 116 numput(r, data, (A_Index - 1) * 3, "uchar") 117 if g 118 numput(g, data, (A_Index - 1) * 3 + 1, "uchar") 119 if b 120 numput(b, data, (A_Index - 1) * 3 + 2, "uchar") 121} 122VarCopy(&ppm + headerLength, &data, width * height) 123 124} 125 126ppm_new(width, height, colors) 127{ 128 header = P6`n%width% %height%`n%colors%`n 129 headerLength := strlen(header) 130 varsetcapacity(ppm, width * height + headerLength, 1) 131 varsetcapacity(data, width * height, 0) 132 VarCopy(&ppm, &header, headerLength) 133 VarCopy(&ppm + headerLength, &data, width * height) 134 return ppm 135} 136 137heredoc = 138( 139 P6 140 # lasdjkf 141 87 09 142 255 143 color data... 144) 145 146; Example: Simple image viewer: 147 148Gui, +Resize 149Gui, Add, Button, default, &Load New Image 150Gui, Add, Radio, ym+5 x+10 vRadio checked, Load &actual size 151Gui, Add, Radio, ym+5 x+10, Load to &fit screen 152Gui, Add, Pic, xm vPic 153Gui, Show 154return 155 156ButtonLoadNewImage: 157FileSelectFile, file,,, Select an image:, Images (*.gif; *.jpg; *.bmp; *.png; *.tif; *.ico; *.cur; *.ani; *.exe; *.dll) 158if file = 159 return 160Gui, Submit, NoHide ; Save the values of the radio buttons. 161if Radio = 1 ; Display image at its actual size. 162{ 163 Width = 0 164 Height = 0 165} 166else ; Second radio is selected: Resize the image to fit the screen. 167{ 168 Width := A_ScreenWidth - 28 ; Minus 28 to allow room for borders and margins inside. 169 Height = -1 ; "Keep aspect ratio" seems best. 170} 171GuiControl,, Pic, *w%width% *h%height% %file% ; Load the image. 172Gui, Show, xCenter y0 AutoSize, %file% ; Resize the window to match the picture size. 173return 174 175GuiClose: 176ExitApp 177; Example: Simple text editor with menu bar. 178 179; Create the sub-menus for the menu bar: 180Menu, FileMenu, Add, &New, FileNew 181 182