├── README.md ├── GUI_Creator.text ├── lib └── Controls.xml └── GUI_Creator.ahk /README.md: -------------------------------------------------------------------------------- 1 | # GUI_Creator -------------------------------------------------------------------------------- /GUI_Creator.text: -------------------------------------------------------------------------------- 1 | 0.000.1 2 | Initial Re-Upload 3 | -------------------------------------------------------------------------------- /lib/Controls.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.000.2 4 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | -------------------------------------------------------------------------------- /GUI_Creator.ahk: -------------------------------------------------------------------------------- 1 | #SingleInstance,Force 2 | global window,conxml,v:=[],settings:=new XML("settings","lib\Settings.xml"),TreeView:=new XML("TreeView") 3 | FileCheck(),Gui() 4 | /* 5 | 6 | When adding a control from the TV make sure to check to see if it overlaps any other control 7 | if it does 8 | move it to a blank area then update its position. 9 | 10 | make a setting for GroupBoxes for dragging contents 11 | have it ask if you want things dragged into the tab (and maybe which tab) 12 | 13 | Test GUI needs to be a DynaRun and it needs to add GuiClose() and GuiEscape() 14 | 15 | re-explore the WheelDown/WheelUp to change edit modes 16 | give it a StatusBar to display the mode or window title 17 | escape de=selects all 18 | change{ 19 | first item to:{ 20 | for anything that is just Text 21 | Control Text: 22 | for anything that needs a list 23 | Control List: 24 | for Tab 25 | Control Tabs: 26 | and so on 27 | } 28 | } 29 | info window{ 30 | have the add items display the hotkeys 31 | } 32 | FORCE{ 33 | on new window force a name 34 | have it changable but make it clean 35 | } 36 | Tab Logic{ 37 | when you make a tab control 38 | 39 | 40 | if you add tabs 41 | add the per tab|dec|la|ra|tion 42 | 43 | also you know how to insert before so you don't need to re-build the tab list 44 | every time you make a new one, just insert it numerically where it belongs 45 | 46 | make the edit label into edit tabs and create a listview for adding/subtracting 47 | also make it so you can move controls from one tab to another easily 48 | maybe a treeview rather than a listview so you can show what controls are where 49 | on click of the control show the tab that it is on and "select" it 50 | 51 | if change tabs and and dec|la|ra is less than .length{ 52 | WARN! and ask what to do with the orphaned tab items 53 | if delete 54 | delete the controls 55 | else 56 | Ask where to move the tabs 57 | } 58 | } 59 | */ 60 | MakeBackground(){ 61 | ea:=settings.EA("//settings/grid"),Dot:=ea.Dot?ea.Dot:0,Grid:=ea.Grid!=""?ea.Grid:0xAAAAAA 62 | dot:=RGB(dot),Grid:=RGB(Grid) 63 | Image:=ComObjCreate("WIA.ImageFile"),vector:=ComObjCreate("WIA.Vector"),Dot+=0,Grid+=0,vector.Add(Dot) 64 | loop,99 65 | vector.Add(Grid) 66 | Image:=vector.Imagefile(10,10) 67 | FileDelete,tile.bmp 68 | Image.SaveFile("tile.bmp"),Display_Grid("removebrush") 69 | WinSet,Redraw,,% hwnd([3]) 70 | } 71 | GetInfo(hotkey){ 72 | MouseGetPos,x,y 73 | xx:=x,yy:=y 74 | ControlGetPos,cx,cy,cw,ch,,% hwnd([3]) 75 | if(x>cx&&xcy+v.Caption&&y" pos.x " and @y<" pos.y " and @y+@h>" pos.y " and @type='Tab' or @type='Tab2']") 90 | if(con){ 91 | tt:=xml.EA(con),nn:=GetClassNN(tt.hwnd) 92 | top:=window.SSN("//control[@hwnd='" tt.hwnd "']") 93 | ControlGet,tabnum,tab,,%nn%,% hwnd([3]) 94 | Gui,3:Tab,%tabnum%,% SubStr(nn,16) 95 | if !tb:=SSN(top,"tab[@tab='" tabnum "']") 96 | tb:=window.Under(top,"tab",{tab:tabnum,hwnd:tt.hwnd}) 97 | tb.SetAttribute("hwnd",tt.hwnd) 98 | tb.AppendChild(control) 99 | new:=AddControl(control) 100 | }else 101 | new:=AddControl(control) 102 | Debug(),Eval(),undo.redo:=[] 103 | } 104 | Convert_Hotkey(key){ 105 | StringUpper,key,key 106 | for a,b in [{Shift:"+"},{Ctrl:"^"},{Alt:"!"}] 107 | for c,d in b 108 | key:=RegExReplace(key,"\" d,c "+") 109 | return key 110 | } 111 | RGB(c){ 112 | SetFormat,IntegerFast,H 113 | c:=(c&255)<<16|(c&65280)|(c>>16),c:=SubStr(c,1) 114 | SetFormat,IntegerFast,D 115 | return c 116 | } 117 | Display_Grid(x:=""){ 118 | Static wBrush 119 | if (x="removebrush") 120 | wBrush:="" 121 | if(A_Gui!=3) 122 | return 123 | if(settings.SSN("//options/Display_Grid").text) 124 | tile:="tile.bmp" 125 | else 126 | return 127 | If(!wBrush) 128 | wBrush:=DllCall("CreatePatternBrush",UInt,DllCall("LoadImage",Int,0,Str,"tile.bmp",Int,0,Int,0,Int,0,UInt,0x2010,"UInt"),"UInt") 129 | Return wBrush 130 | } 131 | Grid(ByRef x,ByRef y,adjust:=0){ 132 | if adjust 133 | x-=v.Border,y-=v.border+v.caption 134 | if settings.SSN("//options/Snap_To_Grid").text 135 | x:=Round(x,-1),y:=Round(y,-1) 136 | } 137 | AddControl(info){ 138 | ea:=xml.EA(info) 139 | for a,b in {x:ea.x,y:ea.y,w:ea.w,h:ea.h} 140 | if(b~="\d") 141 | pos.=a b " " 142 | if(ea.type="ListView") 143 | pos.=" -Multi" 144 | value:=ea.value~="(ComboBox|DDL|DropDownList)"?ea.value "||":ea.value 145 | notify:=(ea.type~="Tab")?"gtabnotify":"" 146 | /* 147 | ea.type:=ea.type="DropDownList"?"ComboBox":ea.type 148 | */ 149 | if(ea.font){ 150 | Gui,3:Font,% CompileFont(info),% ea.font 151 | Gui,3:Add,% ea.type,%pos% hwndhwnd %notify% %Disable%,% value 152 | Gui,3:Font 153 | }else{ 154 | Gui,3:Add,% ea.type,%pos% hwndhwnd %notify% %disable%,% value 155 | } 156 | if(ea.type="TreeView"){ 157 | Gui,3:Default 158 | TV_Add("Treeview (Placeholder)") 159 | }if(InStr(ea.type,"tab")) 160 | Gui,3:Tab 161 | ControlGetPos,x,y,w,h,,ahk_id%hwnd% 162 | wh:=!(ea.type~="(ComboBox|DDL|DropDownList)")?[["w",w],["h",h]]:[["w",w]] 163 | for a,b in wh 164 | info.SetAttribute(b.1,b.2) 165 | info.SetAttribute("hwnd",hwnd+0) 166 | WinGet,cl,ControlListHWND,% hwnd([3]) 167 | if(ea.type~="ComboBox|ListView|DropDownList|DDL"){ 168 | for a,b in StrSplit(cl,"`n") 169 | if !window.SSN("//*[@hwnd='" b+0 "']") 170 | info.SetAttribute("married",b+0) 171 | }Debug() 172 | return info 173 | } 174 | Debug(info:=""){ 175 | if(info=0) 176 | if(hwnd(55)) 177 | return hwnd({rem:55}) 178 | if(!settings.SSN("//options/Debug_Window").text) 179 | return 180 | if(!hwnd(55)){ 181 | Gui,55:Destroy 182 | Gui,55:Default 183 | Gui,+hwndhwnd +Resize 184 | hwnd(55,hwnd) 185 | Gui,Margin,0,0 186 | Gui,Add,Edit,x0 y0 w900 h300 -Wrap 187 | Gui,Show,x0 y0 NA,Debug 188 | Gui,1:+AlwaysOnTop 189 | Gui,1:-AlwaysOnTop 190 | }info:=info?info:window 191 | Loop,2 192 | info.Transform() 193 | text:=info[]?info[]:window[] 194 | ControlSetText,Edit1,%text%,% hwnd([55]) 195 | return 196 | 55GuiEscape: 197 | 55GuiClose: 198 | hwnd({rem:55}) 199 | return 200 | 55GuiSize: 201 | GuiControl,55:Move,Edit1,w%A_GuiWidth% h%A_GuiHeight% 202 | return 203 | } 204 | tv(){ 205 | tv: 206 | if(A_GuiEvent!="Normal") 207 | return 208 | if((current:=TreeView.SSN("//*[@tv='" A_EventInfo "']")).ParentNode.nodename="Add"){ 209 | GetInfo(current.nodename) 210 | }else if(tv:=TreeView.SSN("//*[@tv='" A_EventInfo "']")){ 211 | ea:=xml.EA(tv),Control:=window.SSN("//*[@hwnd='" SSN(tv.ParentNode,"@hwnd").text "']"),ItemInfo:=xml.EA(Control),undo.add() 212 | if (ea.value~="(x|y|w|h)"){ 213 | InputBox,newvalue,Enter a new value,% "Enter a new value for " conxml.SSN("//*[@value='" ea.value "']/@desc").text,,,,,,,,% ItemInfo[ea.value] 214 | if ErrorLevel 215 | return 216 | if RegExMatch(newvalue,"\D") 217 | return m("Must be an integer") 218 | Gui,2:Default 219 | if (tv.ParentNode.nodename="all"){ 220 | sel:=window.SN("//control[@selected='1']") 221 | while,Control:=sel.Item[A_Index-1]{ 222 | Control.SetAttribute(ea.value,newvalue),new:=xml.EA(Control) 223 | info:=TreeView.SSN("//*[@hwnd='" new.hwnd "']/*[@value='" ea.value "']"),info:=xml.EA(info) 224 | TV_Modify(info.tv,"",info.desc " = " newvalue) 225 | GuiControl,3:movedraw,% new.hwnd,% ea.value newvalue 226 | } 227 | }else{ 228 | Control:=window.SSN("//*[@hwnd='" SSN(tv.ParentNode,"@hwnd").text "']") 229 | info:=TreeView.SSN("//*[@hwnd='" SSN(control,"@hwnd").text "']/*[@value='" ea.value "']"),info:=xml.EA(info) 230 | TV_Modify(info.tv,"",info.desc " = " newvalue) 231 | Control.SetAttribute(ea.value,newvalue),new:=xml.EA(Control) 232 | GuiControl,3:movedraw,% new.hwnd,% ea.value newvalue 233 | } 234 | }else if(ea.value~="\b(v|g)\b"){ 235 | InputBox,newvalue,Enter a new value,% "Enter a new value for " conxml.SSN("//*[@value='" ea.value "']/@desc").text,,,,,,,,% ItemInfo[ea.value] 236 | if ErrorLevel 237 | return 238 | newvalue:=Clean(newvalue) 239 | if(ea.value="g"){ 240 | sel:=window.SN("//control[@selected='1']") 241 | while,ss:=sel.Item[A_Index-1]{ 242 | if label:=window.SSN("//label[@name='" SSN(ss,"@g").text "']"){ 243 | if(newvalue="") 244 | label.ParentNode.RemoveChild(label) 245 | else 246 | label.SetAttribute("name",newvalue) 247 | } 248 | tv:=TreeView.SSN("//*[@hwnd='" SSN(ss,"@hwnd").text "']/info[@value='g']/@tv").text 249 | if(newvalue="") 250 | ss.RemoveAttribute("g"),TV_Modify(tv,"","G-Label") 251 | else 252 | ss.SetAttribute("g",newvalue)TV_Modify(tv,"","G-Label = " newvalue) 253 | } 254 | }if(ea.value="v"){ 255 | tv:=TreeView.SSN("//*[@hwnd='" SSN(Control,"@hwnd").text "']/info[@value='v']/@tv").text 256 | if(newvalue="") 257 | Control.RemoveAttribute("v"),TV_Modify(tv,"","Variable") 258 | else 259 | Control.SetAttribute("v",newvalue)TV_Modify(tv,"","Variable = " newvalue) 260 | 261 | } 262 | }else if(ea.value="font"){ 263 | ea:=xml.EA(control) 264 | if !ea.font 265 | ea:=window.EA("//control[@selected='1']") 266 | Dlg_Font(ea,1,hwnd(1)) 267 | selected:=window.SN("//control[@selected='1']") 268 | while,Control:=selected.Item[A_Index-1]{ 269 | for a,b in ea 270 | if(a~="i)(bold|italic|strikeout|color|font|size|underline)") 271 | Control.SetAttribute(a,b) 272 | con:=xml.EA(Control) 273 | style:=CompileFont(Control),name:=ea.font 274 | Gui,3:Font 275 | Gui,3:Font,%style%,%name% 276 | GuiControl,3:Font,% con.hwnd 277 | GuiControl,% "3:+c" ea.color,% con.hwnd 278 | WinSet,Redraw,,% hwnd([3]) 279 | Gui,3:Font 280 | } 281 | }else if(ea.value="value"){ 282 | InputBox,new,Input Required,% "Input a new value for " ea.desc,,,,,,,,% ItemInfo[ea.value] 283 | if ErrorLevel 284 | return 285 | ea:=xml.EA(control),control.SetAttribute("value",new) 286 | GuiControl,3:,% ea.hwnd,% _:=ea.value~="i)tab|tab2|ComboBox|DropDownList"?"|" new:new 287 | if((iteminfo.type="ComboBox"||iteminfo.type="DropDownList")&&!InStr(new,"||")) 288 | GuiControl,3:Choose,% ea.hwnd,1 289 | }else if(ea.value="option"){ 290 | InputBox,new,Additional Options,% "Input a value for" ea.desc,,,,,,,,% ItemInfo[ea.value] 291 | if ErrorLevel 292 | return 293 | control.SetAttribute("option",new),ea:=xml.EA(control) 294 | } 295 | else if(tv.nodename="windowtitle"){ 296 | node:=window.SSN("//window") 297 | InputBox,new,Enter New Name,Please enter the new name for the window title,,,,,,,,% SSN(node,"@windowtitle").text 298 | if(ErrorLevel) 299 | return 300 | node.SetAttribute("windowtitle",new) 301 | } 302 | else if(tv.nodename="windowname"){ 303 | node:=window.SSN("//window") 304 | InputBox,new,Enter New Name,Please enter the new name for the window title,,,,,,,,% SSN(node,"@windowname").text 305 | if(ErrorLevel) 306 | return 307 | node.SetAttribute("windowname",Clean(new)) 308 | } 309 | Highlight(),DisplaySelected() 310 | SetTimer,Redraw,-100 311 | } 312 | return 313 | } 314 | Highlight(a:=""){ 315 | if(A_Gui>3&&a!="show") 316 | return 317 | hwnd({rem:99}) 318 | Gui,99:+LastFound +owner1 +E0x20 -Caption +hwndsh 319 | hwnd(99,sh) 320 | WinSet,TransColor,0xF0F0F0 100 321 | Gui,99:Color,0xF0F0F0,0xFF 322 | Gui,99:Default 323 | WinGetPos,x,y,w,h,% hwnd([3]) 324 | x+=v.Border,y+=v.border+v.Caption,h-=(v.Border*2)+(v.Caption),w-=(v.Border*2) 325 | Gui,99:Show,x%x% y%y% w%w% h%h% NoActivate 326 | ll:=window.SN("//control[@selected='1']/@hwnd") 327 | while,l:=ll.item(A_Index-1).text{ 328 | ControlGetPos,cx,cy,w,h,,ahk_id%l% 329 | if (cx&&cy&&w&&h){ 330 | pos:=WinPos(cx,cy) 331 | Gui,Add,Progress,% "c" color " x" pos.x " y" pos.y " w" w " h" h,100 332 | } 333 | } 334 | if a=0 335 | SetTimer,Redraw,-10 336 | } 337 | Redraw(win:=3){ 338 | WinSet,Redraw,,% hwnd([win]) 339 | } 340 | Exit(close:=0){ 341 | GuiClose: 342 | WinGetPos,xx,yy,w,h,% hwnd([1]) 343 | adj:=Adjust(xx,yy,w,h),att:={main:{x:xx,y:yy,w:adj.w,h:adj.h-v.menu}} 344 | for a,b in {settings:2,workarea:3}{ 345 | ControlGetPos,x,y,w,h,,% hwnd([b]) 346 | adjust:=Adjust(x,y,w,h) 347 | att[a]:={x:adjust.x,y:adjust.y-v.menu,w:adjust.w,h:adjust.h} 348 | } 349 | for a,b in att 350 | settings.Add("gui/" a,att[a]) 351 | file:=window.SSN("//filename").text 352 | settings.Add("last",,file),settings.Save(1) 353 | temp:=new XML("project",file),rem:=window.SN("//*") 354 | while,rr:=rem.Item[A_Index-1] 355 | for a,b in StrSplit("offsetx,offsety,married,hwnd,ow,oh",",") 356 | rr.RemoveAttribute(b) 357 | if !(temp[]==window[]){ 358 | MsgBox,35,File Changed,Would you like to save your GUI? 359 | if !FileExist(file) 360 | rem:=window.SSN("//filename"),rem.ParentNode.RemoveChild(rem) 361 | IfMsgBox,Yes 362 | Save() 363 | IfMsgBox,Cancel 364 | return 365 | } 366 | if(close) 367 | return New() 368 | ExitApp 369 | return 370 | } 371 | Hotkeys(state:=1){ 372 | state:=state?"On":"Off" 373 | Hotkey,IfWinActive,% hwnd([1]) 374 | hotkey:=settings.SN("//hotkeys/*[@hotkey!='']/@hotkey") 375 | while,key:=hotkey.item[A_Index-1].text 376 | Hotkey,%key%,Hotkey,%state% 377 | return 378 | Hotkey: 379 | hotkey:=settings.SSN("//*[@hotkey='" A_ThisHotkey "']").NodeName 380 | MouseGetPos,,,,Control,2 381 | if(control+0!=hwnd(3)) 382 | if(window.SSN("//*[@hwnd='" control+0 "']/@type").text~="i)Tab|Tab2|ComboBox|GroupBox"=0){ 383 | ControlSend,,{%A_ThisHotkey%},ahk_id%control% 384 | return 385 | } 386 | if(IsFunc(hotkey)) 387 | %hotkey%() 388 | else if(hotkey~="(" Menu({menu:1}).Add ")") 389 | GetInfo(hotkey) 390 | return 391 | } 392 | Edit_Hotkeys(){ 393 | static tv:=[] 394 | Gui,4:Destroy 395 | Gui,4:Default 396 | Gui,Add,TreeView,w300 r20 397 | Gui,Add,Button,gedithotkey Default,Edit Hotkey 398 | menu:=Menu({menu:1}),tv:=[],Hotkeys(0) 399 | for a,b in Menu.order{ 400 | for c,d in StrSplit(Menu[b],"|"){ 401 | if !tv[b] 402 | root:=tv[b]:=TV_Add(b) 403 | if !(settings.SSN("//hotkeys/" Clean(d))) 404 | settings.Add("hotkeys/" Clean(d),{menu:d}) 405 | tv[TV_Add(GetMenuItem(d,1),root,"Vis")]:={parent:b,xml:settings.SSN("//hotkeys/" Clean(d))} 406 | } 407 | } 408 | TV_Modify(TV_GetChild(0),"Select Vis Focus") 409 | Gui,4:Show,,Hotkeys 410 | return 411 | 4GuiEscape: 412 | Gui,4:Destroy 413 | Hotkeys() 414 | return 415 | edithotkey: 416 | Gui,4:Default 417 | value:=tv[TV_GetSelection()] 418 | oldmenu:=GetMenuItem(SSN(value.xml,"@menu").text) 419 | InputBox,new,New Hotkey,Enter a new hotkey,,,,,,,,% SSN(value.xml,"@hotkey").text 420 | if ErrorLevel 421 | return 422 | value.xml.SetAttribute("hotkey",new) 423 | newmenu:=GetMenuItem(SSN(value.xml,"@menu").text) 424 | Menu,% value.parent,Rename,%oldmenu%,%newmenu% 425 | TV_Modify(TV_GetSelection(),"",GetMenuItem(SSN(value.xml,"@menu").text,1)) 426 | return 427 | } 428 | Adjust(ByRef x,ByRef y,w:="",h:=""){ 429 | if(IsObject(x)=0&&y!=""&&x!=""&&w&&h) 430 | return {x:x-v.Border,y:y-(v.Border+v.Caption),w:w-(v.Border*2),h:h-(v.Border*2+v.Caption)} 431 | if(IsObject(x)=0&&y&&x) 432 | return {x:x-v.Border,y:y-(v.Border+v.Caption)} 433 | } 434 | New(){ 435 | Gui,3:Destroy 436 | Gui,3:+Resize +hwndhwnd -0x20000 -0x10000 +parent1 -ToolWindow 437 | hwnd(3,hwnd),ea:=settings.EA("//gui/workarea"),pos:="" 438 | Gui,3:Show,% GuiPos("//gui/workarea","x176 y5 w500 h500"),Work Area 439 | Gui,3:Margin,0,0 440 | window:=new XML("gui"),Display_Grid(),Select(0,0) 441 | WinSet,Redraw,,% hwnd([3]) 442 | } 443 | Save(filename:=""){ 444 | if(!FileExist("Projects")) 445 | FileCreateDir,Projects 446 | Loop,2 447 | window.Transform() 448 | if(!(filename)){ 449 | if !filename:=window.SSN("//filename").text 450 | FileSelectFile,filename,S16,%A_ScriptDir%\Projects,Save Project As,*.xml 451 | if ErrorLevel 452 | return 453 | filename:=InStr(filename,".xml")?filename:filename ".xml" 454 | } 455 | window.Add("filename",,filename),filename:=SubStr(filename,-3)!=".xml"?filename ".xml":filename,window.file:=filename 456 | ControlGetPos,x,y,w,h,,% hwnd([3]) 457 | att:={x:x,y:y,w:w,h:h},window.Add("workarea",att),window.Transform(),window.Save(1) 458 | SplitPath,filename,file 459 | TrayTip,GUI Creator,File '%file%' has been saved 460 | WinSetTitle,% hwnd([1]),,GUI Creator: %file% 461 | Debug() 462 | } 463 | Move(){ 464 | MouseGetPos,x,y,win,Ctrl,2 465 | pos:=WinPos(x,y),moved:=0,ctrl+=0,xx:=x,yy:=y,lastx:=x,lasty:=y 466 | if !control:=window.SSN("//*[@hwnd='" ctrl "' or @married='" ctrl "']") 467 | control:=window.SSN("//window/*[@x<" pos.x " and @y<" pos.y " and @x+@w>" pos.x " and @y+@h>" pos.y "]") 468 | if(ctrl=hwnd(3)&&control.xml="") 469 | return pos:=WinPos(x,y),Select(pos.x,pos.y) 470 | if((control.nodename!="control")||(win!=hwnd(1)||ctrl=hwnd("tv"))) 471 | return 472 | Gui,99:Destroy 473 | if(control+0=hwnd("tv")) 474 | return 475 | ea:=xml.EA(control) 476 | list:=ea.selected?window.SN("//control[@selected='1']/descendant-or-self::control"):window.SN("//control[@hwnd='" ea.hwnd "']/descendant-or-self::control") 477 | while,ll:=list.Item[A_Index-1] 478 | ea:=xml.EA(ll),ll.SetAttribute("offsetx",ea.x-pos.x),ll.SetAttribute("offsety",ea.y-pos.y) 479 | if(list.length){ 480 | while,GetKeyState("LButton"){ 481 | MouseGetPos,xx,yy 482 | if(Abs(x-xx)>3||Abs(y-yy)>3){ 483 | while,ll:=list.item[A_Index-1],ea:=xml.EA(ll) 484 | if(ea.type="DropDownList") 485 | SendMessage,0x14F,0,0,,% "ahk_id" ea.hwnd 486 | undo.add() 487 | break 488 | } 489 | } 490 | if(Abs(x-xx)=0&&Abs(y-yy)=0) 491 | return CreateSelection(window.SN("//*[@hwnd='" SSN(control,"@hwnd").text "']")) 492 | if(GetKeyState("shift")){ 493 | SetTimer,Resize,-1 494 | return 495 | } 496 | while,GetKeyState("LButton"){ 497 | MouseGetPos,xx,yy 498 | if(Abs(lastx-xx)>0||Abs(lasty-yy)>0){ 499 | pos:=WinPos(xx,yy) 500 | while,ll:=list.Item[A_Index-1],ea:=xml.EA(ll){ 501 | nx:=pos.x+ea.offsetx,ny:=pos.y+ea.offsety,Grid(nx,ny) 502 | GuiControl,3:MoveDraw,% ea.hwnd,% "x" nx " y" ny 503 | ll.SetAttribute("x",nx),ll.SetAttribute("y",ny) 504 | } 505 | } 506 | lastx:=xx,lasty:=yy 507 | } 508 | } 509 | pos:=WinPos(xx,yy),con:=window.SSN("//*[@x<" pos.x " and @x+@w>" pos.x " and @y<" pos.y " and @y+@h>" pos.y " and @type='Tab' or @type='Tab2']") 510 | if con 511 | AddToTab(con,list) 512 | UpdateTV(list),Eval(),Highlight(),Debug(),DisplaySelected() 513 | return 514 | } 515 | Select(xx,yy){ 516 | Random,Color,0xcccccc,0xeeeeee 517 | Gui,59:-Caption +AlwaysOnTop +E0x20 +hwndselect +Owner1 518 | WinGetPos,wx,wy,ww,wh,% hwnd([3]) 519 | WinGetPos,mx,my,,,% hwnd([1]) 520 | Gui,59:Color,%Color% 521 | Gui,59:Show,% "x" wx+v.border " y" wy+v.border+v.caption " w" ww-(v.border*2) " h" wh-(v.border*2)-v.Caption " noactivate hide" 522 | Gui,59:Show,NoActivate 523 | WinSet,Transparent,50,ahk_id%select% 524 | while,GetKeyState("LButton"){ 525 | MouseGetPos,x,y 526 | x:=x-(wx-mx)-v.Border,y:=y-(wy-my)-v.Border-v.Caption 527 | WinSet,Region,%xx%-%yy% %x%-%yy% %x%-%y% %xx%-%y% %xx%-%yy%,ahk_id %select% 528 | } 529 | start:={x:xx,y:yy},end:={x:x,y:y},pos:=[],pos.x:=[],pos.y:=[] 530 | for a,b in [start,end] 531 | pos.x[b.x]:=1,pos.y[b.y]:=1 532 | Gui,59:Destroy 533 | List:=window.SN("//*[@x>" pos.x.MinIndex() " and @x<" pos.x.MaxIndex() " and @y>" pos.y.MinIndex() " and @y<" pos.y.MaxIndex() "]"),CreateSelection(list) 534 | } 535 | CreateSelection(selections,toggle:=0){ 536 | if((GetKeyState("Control","P")=0&&GetKeyState("Shift","P")=0)&&toggle=0){ 537 | sel:=window.SN("//window/descendant::control[@selected]") 538 | while,ss:=sel.Item[A_Index-1] 539 | ss.RemoveAttribute("selected") 540 | } 541 | while(ss:=selections.item[A_Index-1]){ 542 | if(ss.NodeName!="control") 543 | Continue 544 | if ((GetKeyState("Control","P")||toggle)&&SSN(ss,"@selected").text) 545 | ss.RemoveAttribute("selected") 546 | else 547 | ss.SetAttribute("selected",1) 548 | } 549 | Highlight(),DisplaySelected(),Debug() 550 | } 551 | Inside(inside){ 552 | pos:=xml.EA(inside) 553 | return window.SN("//*[@x>" pos.x " and @x<" pos.x+pos.w " and @y>" pos.y " and @y<" pos.y+pos.h "]") 554 | } 555 | DisplaySelected(){ 556 | static lastselected,type:={windowname:"Window Name",windowtitle:"Window Title"} 557 | selected:=window.SN("//control[@selected='1']"),top:=TreeView.SSN("//selected") 558 | Gui,2:Default 559 | GuiControl,2:-Redraw,SysTreeView321 560 | sel:=TreeView.SN("//control") 561 | while,ss:=sel.Item[A_Index-1] 562 | if !window.SSN("//*[@hwnd='" SSN(ss,"@hwnd").text "']/@selected") 563 | TV_Delete(SSN(ss,"@tv").text),ss.ParentNode.RemoveChild(ss) 564 | if(selected.length>1){ 565 | if all:=TreeView.SSN("//all") 566 | TV_Delete(SSN(all,"@tv").text),all.ParentNode.RemoveChild(all) 567 | all:=TreeView.Under(top,"all",{tv:TV_Add("All Controls",SSN(top,"@tv").text,"First")}) 568 | constants:=conxml.SN("//constants/info") 569 | while,cc:=constants.Item[A_Index-1] 570 | if !SSN(all,"*[@value='" SSN(cc,"@value").text "']") 571 | TreeView.Under(all,"allset",{value:SSN(cc,"@value").text,tv:TV_Add(SSN(cc,"@desc").text,SSN(all,"@tv").text)}) 572 | while,ss:=selected.Item[A_Index-1]{ 573 | ea:=xml.EA(ss),info:=xml.EA(conxml.SSN("//" ea.type)),info.v:=1,info.value:=1 574 | for a in info 575 | if rem:=TreeView.SSN("//allset[@value='" a "']") 576 | TV_Delete(SSN(rem,"@tv").text),rem.ParentNode.RemoveChild(rem) 577 | } 578 | TV_Modify(SSN(all,"@tv").text,"Expand") 579 | }else if(selected.length<=1) 580 | if all:=TreeView.SSN("//all") 581 | TV_Delete(SSN(all,"@tv").text),all.ParentNode.RemoveChild(all) 582 | /* 583 | Work on: 584 | -Add all of the main info to the control itself 585 | --Add optional stuff below it like all of the extra settings for the controls 586 | -Fix the "All" edits in the tv 587 | --make it move all the selected stuff. 588 | */ 589 | while,ss:=selected.Item[A_Index-1],ea:=xml.EA(ss){ 590 | if !tvi:=TreeView.SSN("//control[@hwnd='" SSN(ss,"@hwnd").text "']"){ 591 | constants:=conxml.SN("//" ea.type "/constants|//constants/*"),rem:=xml.EA(conxml.SSN("//" ea.type)) 592 | next:=TreeView.Under(top,"control",{hwnd:ea.hwnd,tv:TV_Add(ea.type,SSN(top,"@tv").text,"Vis")}) 593 | while,cc:=constants.Item[A_Index-1],cea:=xml.EA(cc) 594 | if !rem[cea.value] 595 | value:=(vv:=SSN(ss,"@" cea.value).text)?cea.desc " = " vv:cea.desc,TreeView.Under(next,"info",{tv:TV_Add(value,SSN(next,"@tv").text),value:cea.value,desc:cea.desc}) 596 | TV_Modify(SSN(next,"@tv").text,"Expand") 597 | }else{ 598 | set:=SN(tvi,"descendant::*") 599 | while,sc:=set.item[A_Index-1],sa:=xml.EA(sc) 600 | TV_Modify(sa.tv,"",sa.desc _:=ea[sa.value]?" = " ea[sa.value]:"") 601 | } 602 | } 603 | ea:=xml.EA(window.SSN("//window")) 604 | for a,b in ea{ 605 | text:=b?type[a] " = " b:type[a] 606 | node:=TreeView.SSN("//" a) 607 | TV_Modify(SSN(node,"@tv").text,"",text) 608 | } 609 | GuiControl,2:+Redraw,SysTreeView321 610 | TV_Modify(TreeView.SSN("//Add/@tv").text,selected.length?"-Expand":"Expand"),Highlight() 611 | } 612 | KillSelect(){ 613 | Gui,99:Destroy 614 | } 615 | Select_All(){ 616 | SelectAll: 617 | all:=window.SN("//window/descendant::control") 618 | while,aa:=all.Item[A_Index-1],ea:=xml.EA(aa){ 619 | if InStr(A_ThisHotkey,"+") 620 | ea.selected?aa.RemoveAttribute("selected"):aa.SetAttribute("selected",1) 621 | else 622 | aa.SetAttribute("selected",1) 623 | } 624 | Highlight(),DisplaySelected() 625 | return 626 | } 627 | Save_As(){ 628 | filename:=window.SSN("//filename").text 629 | SplitPath,filename,,dir 630 | FileSelectFile,filename,,%dir%,Save Window As,*.xml 631 | if !(ErrorLevel){ 632 | window.SSN("//filename").text:=filename 633 | Save() 634 | } 635 | } 636 | LButton(){ 637 | MouseGetPos,x,y,,ctrl,2 638 | node:=window.SSN("//*[@hwnd='" ctrl+0 "']") 639 | ea:=xml.EA(node) 640 | if(SSN(node,"@type").text~="Tab"){ 641 | Sleep,200 642 | if(v.tabbutton) 643 | return v.tabbutton:=0 ;#[Fix This Please] 644 | } 645 | Sleep,40 646 | SetTimer,move,-1 647 | } 648 | Edit_GLabels(){ 649 | if !window.SN("//*[@g!='']").length 650 | return m("This project does not have any labels associated with any of the controls","Please add label associations first") 651 | Gui,99:Destroy 652 | Gui,5:Destroy 653 | Gui,5:Default 654 | Gui,5:+hwndhwnd 655 | hwnd(5,hwnd) 656 | Gui,Add,ListView,w100 h400 AltSubmit gegl,Labels 657 | Gui,Add,Edit,x+10 w500 h400 geditgl 658 | labels:=window.SN("//@g") 659 | while,ll:=labels.item[A_Index-1]{ 660 | if !window.SSN("//labels/label[@name='" ll.text "']") 661 | window.Add("labels/label",{name:ll.text},,1) 662 | } 663 | labels:=window.SN("//labels/label") 664 | while,ll:=labels.Item[A_Index-1]{ 665 | if !window.SSN("//*[@g='" SSN(ll,"@name").text "']") 666 | ll.ParentNode.RemoveChild(ll) 667 | else 668 | LV_Add("",SSN(ll,"@name").text) 669 | } 670 | WinGetPos,x,y,w,h,% hwnd([1]) 671 | Gui,5:Show,% Center(5),Label Editor 672 | LV_Modify(1,"Select Vis Focus") 673 | return 674 | editgl: 675 | if !LV_GetNext() 676 | return 677 | LV_GetText(label,LV_GetNext()) 678 | if !info:=window.SSN("//labels/label[@name='" label "']") 679 | info:=window.Add("labels/label",{name:label},,1) 680 | ControlGetText,text,Edit1,% hwnd([5]) 681 | info.text:=text 682 | return 683 | egl: 684 | if !LV_GetNext() 685 | return 686 | LV_GetText(label,LV_GetNext()) 687 | text:=window.SSN("//label[@name='" label "']").text 688 | ControlSetText,Edit1,% RegExReplace(text,"\R","`r`n"),% hwnd([5]) 689 | return 690 | 5GuiClose: 691 | 5GuiEscape: 692 | Gui,5:Destroy 693 | Highlight("show") 694 | return 695 | } 696 | Center(hwnd){ 697 | Gui,%hwnd%:Show,Hide 698 | WinGetPos,x,y,w,h,% hwnd([1]) 699 | WinGetPos,xx,yy,ww,hh,% hwnd([hwnd]) 700 | centerx:=(Abs(w-ww)/2),centery:=Abs(h-hh)/2 701 | return "x" x+centerx " y" y+centery 702 | } 703 | Grid_Dot_Color(){ 704 | color:=settings.Add("grid") 705 | dot:=Dlg_Color(SSN(color,"@dot").text,hwnd(1)),color.SetAttribute("dot",dot),MakeBackground(),settings.Add("options/Grid",,1) 706 | } 707 | Grid_Background(){ 708 | color:=settings.Add("grid") 709 | dot:=Dlg_Color(SSN(color,"@grid").text,hwnd(1)),color.SetAttribute("grid",dot),MakeBackground(),settings.Add("options/Grid",,,1) 710 | } 711 | Resize(){ 712 | static wia:=ComObjCreate("wia.imagefile") 713 | MouseGetPos,x,y,win,Ctrl,2 714 | pos:=WinPos(x,y),moved:=0,ctrl+=0,xx:=x,yy:=y,lastx:=x,lasty:=y 715 | if !control:=window.SSN("//*[@hwnd='" ctrl "' or @married='" ctrl "']") 716 | control:=window.SSN("//window/*[@x<" pos.x " and @y<" pos.y " and @x+@w>" pos.x " and @y+@h>" pos.y "]") 717 | ea:=xml.EA(control) 718 | list:=ea.selected?window.SN("//control[@selected='1']"):window.SN("//control[@hwnd='" ea.hwnd "']") 719 | while,ll:=list.Item[A_Index-1],ea:=xml.EA(ll){ 720 | ControlGetPos,,,w,h,,% "ahk_id" ea.hwnd 721 | ll.SetAttribute("ow",w),ll.SetAttribute("oh",h) 722 | if(ea.width=""&&ea.height=""&&ea.type="Picture"){ 723 | wia.loadfile(ea.value) 724 | for a,b in {width:wia.width,height:wia.height} 725 | ll.SetAttribute(a,b) 726 | } 727 | } 728 | while,GetKeyState("LButton"){ 729 | MouseGetPos,x,y 730 | if(lastx=x&&lasty=y) 731 | Continue 732 | break 733 | } 734 | while,GetKeyState("LButton"){ 735 | MouseGetPos,x,y 736 | if(lastx=x&&lasty=y) 737 | Continue 738 | while,ll:=list.Item[A_Index-1],ea:=xml.EA(ll){ 739 | nw:=x-xx,nh:=y-yy,Grid(nw,nh),command:="Move" 740 | if(ea.type="Picture") 741 | nh:=Round(nw*ea.height/ea.width),command:="MoveDraw" 742 | GuiControl,3:%command%,% ea.hwnd,% "w" ea.ow+nw " h" ea.oh+nh 743 | ll.SetAttribute("w",ea.ow+nw),ll.SetAttribute("h",ea.oh+nh) 744 | lastx:=x,lasty:=y 745 | } 746 | } 747 | Highlight(),Eval(),DisplaySelected() 748 | SetTimer,Redraw,-10 749 | } 750 | Update_Program(){ 751 | if(FileExist("gui.ahk")) 752 | return m("NO!") 753 | FileMove,%A_ScriptName%,deleteme.ahk,1 754 | UrlDownloadToFile,https://raw.githubusercontent.com/maestrith/GUI_Creator/master/GUI_Creator.ahk,%A_ScriptName% 755 | FileDelete,deleteme.ahk 756 | Reload 757 | ExitApp 758 | } 759 | Dlg_Font(ByRef Style,Effects=1,window=""){ 760 | VarSetCapacity(LOGFONT,60),StrPut(style.font,&logfont+28,32,"CP0"),LogPixels:=DllCall("GetDeviceCaps","uint",DllCall("GetDC","uint",0),"uint",90),Effects:=0x041+(Effects?0x100:0) 761 | for a,b in font:={16:"bold",20:"italic",21:"underline",22:"strikeout"} 762 | if style[b] 763 | NumPut(b="bold"?700:1,logfont,a) 764 | style.size?NumPut(Floor(style.size*logpixels/72),logfont,0):NumPut(16,LOGFONT,0) 765 | VarSetCapacity(CHOOSEFONT,60,0),NumPut(60,CHOOSEFONT,0),NumPut(&LOGFONT,CHOOSEFONT,12),NumPut(Effects,CHOOSEFONT,20),NumPut(RGB(style.color),CHOOSEFONT,24),NumPut(window,CHOOSEFONT,4) 766 | if !r:=DllCall("comdlg32\ChooseFontA","uint",&CHOOSEFONT) 767 | return 768 | Color:=NumGet(CHOOSEFONT,24),bold:=NumGet(LOGFONT,16)>=700?1:0 769 | style:={size:NumGet(CHOOSEFONT,16)//10,font:StrGet(&logfont+28,"CP0"),color:RGB(color)} 770 | for a,b in font 771 | style[b]:=NumGet(LOGFONT,a,"UChar")?1:0 772 | style["bold"]:=bold 773 | return 1 774 | } 775 | CompileFont(XMLObject,text:=1){ 776 | ea:=xml.EA(XMLObject),style:=[],name:=ea.name,styletext:="norm" 777 | for a,b in {bold:"",color:"c",italic:"",size:"s",strikeout:"",underline:""} 778 | if ea[a] 779 | styletext.=" " _:=b?b ea[a]:a 780 | style:=text?styletext:style 781 | if(style="norm") 782 | return 783 | return style 784 | } 785 | Delete(){ 786 | all:=window.SN("//window/descendant::*[@selected='1']"),undo.Add() 787 | while,aa:=all.item[A_Index-1],ea:=xml.EA(aa) 788 | DllCall("DestroyWindow",ptr,ea.hwnd),aa.ParentNode.RemoveChild(aa) 789 | Select(0,0) 790 | } 791 | Eval(){ 792 | tab:=window.SN("descendant::control[@type='Tab' or @type='Tab2']") 793 | list:=window.SN("//*[contains(@type,'Tab')]/descendant::control") 794 | while,ll:=list.item[A_Index-1]{ 795 | parent:=SSN(ll,"ancestor::control[contains(@type,'Tab')]"),pa:=xml.EA(parent),ea:=xml.EA(ll) 796 | if !(ea.x>pa.x&&ea.xpa.y&&ea.y" ea.x " and @y<" ea.y " and @y+@h>" ea.y "]"){ 798 | tt:=xml.EA(new),nn:=GetClassNN(tt.hwnd),top:=window.SSN("//control[@hwnd='" tt.hwnd "']") 799 | ControlGet,tabnum,tab,,%nn%,% hwnd([3]) 800 | Gui,3:Tab,%tabnum%,% SubStr(nn,16) 801 | if !tb:=SSN(new,"tab[@tab='" tabnum "']") 802 | tb:=window.Under(top,"tab",{tab:tabnum}) 803 | tb.AppendChild(ll),new:=AddControl(ll) 804 | DllCall("DestroyWindow",ptr,ea.hwnd) 805 | }else{ 806 | window.SSN("//window").AppendChild(ll) 807 | Gui,3:Tab 808 | DllCall("DestroyWindow",ptr,ea.hwnd),AddControl(ll) 809 | } 810 | } 811 | } 812 | gb:=window.SN("descendant::control[@type='GroupBox']"),inside:=[] 813 | while,gg:=gb.item[A_Index-1]{ 814 | while,in:=Inside(gg).item[A_Index-1],ea:=xml.EA(in){ 815 | if(gg.xml!=in.ParentNode.xml&&gg.ParentNode.xml=in.ParentNode.xml) 816 | gg.AppendChild(in) 817 | inside[ea.hwnd]:=1 818 | } 819 | } 820 | ngb:=window.SN("//descendant::control[@type!='GroupBox' and @type!='Tab' and @type!='Tab2']") 821 | while,move:=ngb.item[A_Index-1],ea:=xml.EA(move){ 822 | if(inside[ea.hwnd]!=1&&SSN(move.ParentNode,"@type").text="GroupBox") 823 | move.ParentNode.ParentNode.AppendChild(move) 824 | } 825 | Debug() 826 | } 827 | GetClassNN(ctrl){ 828 | WinGet,list,ControlList,% hwnd([3]) 829 | for a,b in StrSplit(list,"`n"){ 830 | ControlGet,hwnd,hwnd,,%b%,% hwnd([3]) 831 | if(hwnd=ctrl) 832 | return b 833 | } 834 | } 835 | UpdateTV(list){ 836 | while,ll:=list.Item[A_Index-1]{ 837 | if tv:=TreeView.SSN("//*[@hwnd='" SSN(ll,"@hwnd").text "']"){ 838 | x:=xml.EA(SSN(tv,"*[@value='x']")),y:=xml.EA(SSN(tv,"*[@value='y']")) 839 | Gui,2:Default 840 | for a,b in {x:[x.tv,x.desc],y:[y.tv,y.desc]} 841 | TV_Modify(b.1,"",b.2 " = " SSN(ll,"@" a).text) 842 | } 843 | } 844 | } 845 | AddToTab(tab,list){ 846 | tt:=xml.EA(tab),nn:=GetClassNN(tt.hwnd) 847 | top:=window.SSN("//control[@hwnd='" tt.hwnd "']") 848 | ControlGet,tabnum,tab,,%nn%,% hwnd([3]) 849 | Gui,3:Tab,%tabnum%,% SubStr(nn,16) 850 | while,ll:=list.item[A_Index-1],ea:=xml.EA(ll){ 851 | if(InStr(ea.type,"tab")) 852 | Continue 853 | if(SSN(ll,"ancestor::control[@type='Tab' or @type='Tab2']")) 854 | Continue 855 | if !tb:=SSN(top,"tab[@tab='" tabnum "']") 856 | tb:=window.Under(top,"tab",{tab:tabnum}) 857 | tb.AppendChild(ll) 858 | DllCall("DestroyWindow",ptr,ea.hwnd) 859 | AddControl(ll) 860 | }Debug() 861 | } 862 | UpdatePos(ctrl){ 863 | ControlGetPos,x,y,w,h,,% "ahk_id" xml.EA(ctrl).hwnd 864 | pos:=WinPos(x,y) 865 | for a,b in {x:pos.x,y:pos.y,w:w,h:h} 866 | ctrl.SetAttribute(a,b) 867 | window.Transform(1) 868 | } 869 | Export(return:=0){ 870 | glabel:=[],winname:=window.SSN("//window/@name").text,program:=winname?"Gui," winname ":Default`n":"",main:=window.SN("//window/control"),top:=window.SSN("//window"),obj:=[] 871 | while,mm:=main.item[A_Index-1],ea:=xml.EA(mm) 872 | obj[ea.y,ea.x,ea.hwnd]:=mm 873 | for a,b in obj 874 | for c,d in b 875 | for e,f in d 876 | top.AppendChild(f) 877 | obj:=[],gb:=window.SN("//*[@type='GroupBox']/*") 878 | while,gg:=gb.item[A_Index-1],ea:=xml.EA(gg) 879 | obj[ea.y,ea.x,ea.hwnd]:={parent:gg.ParentNode,item:gg} 880 | for a,b in obj 881 | for c,d in b 882 | for e,f in d 883 | f.parent.AppendChild(f.item) 884 | tab:=[],tabs:=window.SN("//window/control[@type='Tab' or @type='Tab2']") 885 | while,tt:=tabs.item[A_Index-1],ea:=xml.EA(tt) 886 | tab[ea.y,ea.x,ea.hwnd]:=tt 887 | for a,b in tab 888 | for c,d in b 889 | for e,f in d 890 | top.AppendChild(f) 891 | tabs:=window.SN("//*[@type='Tab' or @type='Tab2']/tab") 892 | while,tt:=tabs.item[A_Index-1]{ 893 | items:=[],ctrls:=SN(tt,"control") 894 | while,cc:=ctrls.item[A_Index-1],ea:=xml.EA(cc) 895 | items[ea.y,ea.x,ea.hwnd]:=cc 896 | for a,b in items 897 | for c,d in b 898 | for e,f in d 899 | tt.AppendChild(f) 900 | } 901 | all:=window.SN("//window/descendant::*") 902 | while,aa:=all.item[A_Index-1],ea:=xml.EA(aa){ 903 | if(aa.NodeName="tab"){ 904 | line:="Gui,Tab," ea.tab "`n" 905 | program.=line 906 | Continue 907 | } 908 | font:=CompileFont(aa) 909 | if(ea.g) 910 | glabel[ea.g]:=1 911 | if(font!=lastfont&&font) 912 | Program.="Gui,Font," font "," ea.font "`n" 913 | if(font!=lastfont&&!font) 914 | program.="Gui,Font`n" 915 | Program.=CompileItem(aa) "`n",lastfont:=font 916 | } 917 | ;/Compile GUI 918 | pos:=WinPos(),title:=window.SSN("//window/@windowtitle").text,title:=title?title:"Created with GUI Creator by maestrith" 919 | Program.="Gui,Show,w" pos.w " h" pos.h "," title "`r`nreturn" 920 | for a in glabel 921 | program.="`n" a ":`n" window.SSN("//labels/label[@name='" a "']").text "`nreturn" 922 | if(return) 923 | return program 924 | /* 925 | /yea, above thing 926 | */ 927 | m("Text copied to your clipboard:",Clipboard:=RegExReplace(program,"\R","`r`n")) 928 | return 929 | 930 | 931 | 932 | 933 | /* 934 | ControlGetPos,,,w,h,,% hwnd([3]) 935 | 936 | program.="Gui,Show,w" w-(v.Border*2) " h" h-(v.Border*2+v.Caption) ",Created with GUI Creator by Maestrith :)`nreturn" 937 | */ 938 | StringReplace,program,program,`n,`r`n,All 939 | if(return) 940 | return program 941 | Clipboard:=program 942 | TrayTip,GUI Creator,GUI Copied to the Clipboard 943 | return 944 | control: 945 | ff:="Gui,Font," cf "," ea.font,_:=(cf="norm"&&lastfont="")?ff:="":(cf="norm"&&lastfont!="")?(ff:="Gui,Font",lastfont:="",program.=ff "`n"):(cf!="norm"&&ff!=lastfont)?(lastfont:=ff:="Gui,Font," cf "," ea.font,program.=ff "`n") 946 | add:="" 947 | for a,b in {v:ea.v,g:ea.g} 948 | if(b) 949 | add.=" " a b 950 | program.="Gui,Add," ea.type ",x" ea.x " y" ea.y " w" ea.w " h" ea.h add "," ea.value "`n" 951 | if ea.g 952 | glabel[ea.g]:=1 953 | return 954 | } 955 | Help(){ 956 | MsgBox,262176,Help,Left Click and drag to create a selection`n-Shift+Left Click to add items to the selection`n-Ctrl+Left Click to toggle the items selected state`n`nShift+Click and drag to Resize selected controls`n`nCtrl+A to Select All and Ctrl+Shift+A to Toggle Select All`n`nTo delete selected controls press Delete 957 | } 958 | Test_GUI(){ 959 | DynaRun(Export(1)) 960 | } 961 | DynaRun(Script,debug=0){ 962 | static exec 963 | exec.Terminate() 964 | Name:="GUI Creator Test",Pipe:=[],cr:= Chr(34) Chr(96)"n" Chr(34) 965 | script:="#SingleInstance,Force`n" script 966 | script.="`nreturn`nGuiEscape:`nGuiClose:`nExitApp`nreturn" 967 | Loop, 2 968 | Pipe[A_Index]:=DllCall("CreateNamedPipe","Str","\\.\pipe\" name,"UInt",2,"UInt",0,"UInt",255,"UInt",0,"UInt",0,"UPtr",0,"UPtr",0,"UPtr") 969 | Call:=Chr(34) A_AhkPath Chr(34) " /ErrorStdOut /CP65001 " Chr(34) "\\.\pipe\" Name Chr(34),Shell:=ComObjCreate("WScript.Shell"),Exec:=Shell.Exec(Call) 970 | for a,b in Pipe 971 | DllCall("ConnectNamedPipe","UPtr",b,"UPtr",0) 972 | FileOpen(Pipe[2],"h","UTF-8").Write(Script) 973 | for a,b in Pipe 974 | DllCall("CloseHandle","UPtr",b) 975 | return exec 976 | } 977 | Undo(){ 978 | undo.undogo() 979 | } 980 | Redo(){ 981 | undo.redogo() 982 | } 983 | Testing(){ 984 | 985 | } 986 | WinPos(x:="",y:=""){ 987 | ControlGetPos,xx,yy,ww,hh,,% hwnd([3]) 988 | VarSetCapacity(rect,16),DllCall("GetClientRect",ptr,hwnd(3),ptr,&rect),x-=xx+v.Border,y-=yy+v.Border+v.Caption,w:=NumGet(rect,8),h:=NumGet(rect,12) 989 | return {x:x,y:y,w:w,h:h} 990 | } 991 | CompileItem(node){ 992 | ea:=xml.EA(node),index:=0 993 | item:="Gui,Add," ea.type "," 994 | for a,b in StrSplit("x,y,w,h,g,v",",") 995 | if(ea[b]!="") 996 | item.=(index=0?"":" ") b ea[b],index++ 997 | if(ea.option) 998 | item.=" " ea.option 999 | item.="," ea.value 1000 | return item 1001 | } 1002 | Escape(){ 1003 | all:=window.SN("//*[@selected]") 1004 | while,aa:=all.item[A_Index-1] 1005 | aa.RemoveAttribute("selected") 1006 | Highlight() 1007 | } 1008 | TabNotify(){ 1009 | v.tabbutton:=1 1010 | } 1011 | FileCheck(){ 1012 | if(!FileExist("lib")) 1013 | FileCreateDir,lib 1014 | conxml:=new XML("controls","lib\controls.xml") 1015 | if(conxml.SSN("//version").text!="0.000.2") 1016 | FileDelete,lib\controls.xml 1017 | if(!FileExist("lib\controls.xml")) 1018 | ctrl:=URLDownloadToVar("https://raw.githubusercontent.com/maestrith/GUI_Creator/master/lib/Controls.xml"),conxml:=new XML("control","lib\Controls.xml"),conxml.xml.LoadXML(ctrl),conxml.Save(1) 1019 | if(!FileExist("tile.bmp")) 1020 | MakeBackground() 1021 | } 1022 | URLDownloadToVar(url){ 1023 | http:=ComObjCreate("WinHttp.WinHttpRequest.5.1") 1024 | http.Open("GET",url),http.Send() 1025 | return http.ResponseText 1026 | } 1027 | Class XML{ 1028 | keep:=[] 1029 | __Get(x=""){ 1030 | return this.xml.xml 1031 | }__New(param*){ 1032 | if(!FileExist(A_ScriptDir "\lib")) 1033 | FileCreateDir,%A_ScriptDir%\lib 1034 | root:=param.1,file:=param.2,file:=file?file:root ".xml",temp:=ComObjCreate("MSXML2.DOMDocument"),temp.setProperty("SelectionLanguage","XPath"),this.xml:=temp,this.file:=file,xml.keep[root]:=this ;temp.preserveWhiteSpace:=1 1035 | if(FileExist(file)){ 1036 | FileRead,info,%file% 1037 | if(info=""){ 1038 | this.xml:=this.CreateElement(temp,root) 1039 | FileDelete,%file% 1040 | }else 1041 | temp.LoadXML(info),this.xml:=temp 1042 | }else 1043 | this.xml:=this.CreateElement(temp,root) 1044 | }Add(path,att:="",text:="",dup:=0){ 1045 | p:="/",add:=(next:=this.SSN("//" path))?1:0,last:=SubStr(path,InStr(path,"/",0,0)+1) 1046 | if(!next.xml){ 1047 | next:=this.SSN("//*") 1048 | for a,b in StrSplit(path,"/") 1049 | p.="/" b,next:=(x:=this.SSN(p))?x:next.AppendChild(this.xml.CreateElement(b)) 1050 | }if(dup&&add) 1051 | next:=next.ParentNode.AppendChild(this.xml.CreateElement(last)) 1052 | for a,b in att 1053 | next.SetAttribute(a,b) 1054 | next.text:=text 1055 | return next 1056 | }CreateElement(doc,root){ 1057 | return doc.AppendChild(this.xml.CreateElement(root)).ParentNode 1058 | }EA(path,att:=""){ 1059 | list:=[] 1060 | if(att) 1061 | return path.NodeName?SSN(path,"@" att).text:this.SSN(path "/@" att).text 1062 | nodes:=path.NodeName?path.SelectNodes("@*"):nodes:=this.SN(path "/@*") 1063 | while,n:=nodes.item(A_Index-1) 1064 | list[n.NodeName]:=n.text 1065 | return list 1066 | }Find(info*){ 1067 | static last:=[] 1068 | doc:=info.1.NodeName?info.1:this.xml 1069 | if(info.1.NodeName) 1070 | node:=info.2,find:=info.3,return:=info.4!=""?"SelectNodes":"SelectSingleNode",search:=info.4 1071 | else 1072 | node:=info.1,find:=info.2,return:=info.3!=""?"SelectNodes":"SelectSingleNode",search:=info.3 1073 | if(InStr(info.2,"descendant")) 1074 | last.1:=info.1,last.2:=info.2,last.3:=info.3,last.4:=info.4 1075 | if(InStr(find,"'")) 1076 | return doc[return](node "[.=concat('" RegExReplace(find,"'","'," Chr(34) "'" Chr(34) ",'") "')]/.." (search?"/" search:"")) 1077 | else 1078 | return doc[return](node "[.='" find "']/.." (search?"/" search:"")) 1079 | }Get(Path,Default){ 1080 | text:=this.SSN(path).text 1081 | return text?text:Default 1082 | }Save(x*){ 1083 | if(x.1=1) 1084 | this.Transform() 1085 | if(this.xml.SelectSingleNode("*").xml="") 1086 | return m("Errors happened while trying to save " this.file ". Reverting to old version of the XML") 1087 | filename:=this.file?this.file:x.1.1,ff:=FileOpen(filename,0),text:=ff.Read(ff.length),ff.Close() 1088 | if(!this[]) 1089 | return m("Error saving the " this.file " xml. Please get in touch with maestrith if this happens often") 1090 | if(text!=this[]) 1091 | file:=FileOpen(filename,"rw"),file.seek(0),file.write(this[]),file.length(file.position) 1092 | }SSN(path){ 1093 | Try 1094 | node:=this.xml.SelectSingleNode(path) 1095 | Catch,e 1096 | t(path,e.message) 1097 | return node 1098 | }SN(path){ 1099 | return this.xml.SelectNodes(path) 1100 | }Transform(){ 1101 | static 1102 | if(!IsObject(xsl)) 1103 | xsl:=ComObjCreate("MSXML2.DOMDocument"),xsl.loadXML("`n`n`n"),style:=null 1104 | this.xml.TransformNodeToObject(xsl,this.xml) 1105 | }Under(under,node,att:="",text:="",list:=""){ 1106 | new:=under.AppendChild(this.xml.CreateElement(node)),new.text:=text 1107 | for a,b in att 1108 | new.SetAttribute(a,b) 1109 | for a,b in StrSplit(list,",") 1110 | new.SetAttribute(b,att[b]) 1111 | return new 1112 | } 1113 | } 1114 | SSN(node,path){ 1115 | return node.SelectSingleNode(path) 1116 | } 1117 | SN(node,path){ 1118 | return node.SelectNodes(path) 1119 | } 1120 | m(x*){ 1121 | for a,b in x 1122 | list.=b "`n" 1123 | MsgBox,0,GUI Creator,%list% 1124 | } 1125 | t(x*){ 1126 | for a,b in x 1127 | list.=b "`n" 1128 | ToolTip %list% 1129 | } 1130 | Gui(){ 1131 | static 1132 | Gui,+Resize +hwndmain 1133 | hwnd(1,main),OnMessage(0x136,"Display_Grid"),OnMessage(0x231,"KillSelect"),OnMessage(0x232,"highlight") 1134 | DetectHiddenWindows,On 1135 | Gui,1:Menu,% Menu() 1136 | Gui,1:Add,StatusBar 1137 | Gui,2:+parent1 +Resize +hwndhwnd -0x20000 -0x10000 0x400 -ToolWindow 1138 | Gui,2:Add,TreeView,x0 y0 w150 h500 gtv AltSubmit hwndtv 1139 | Gui,2:Default 1140 | add:=TreeView.Add("Add",{tv:TV_Add("Add Control")}),ea:=TreeView.EA(add),hwnd("tv",tv) 1141 | for a,b in StrSplit(Menu({menu:1}).Add,"|") 1142 | TreeView.Under(add,b,{tv:TV_Add(b,ea.tv,"Vis")}) 1143 | TreeView.Add("displaypos",{tv:TV_Add("Display Positions")}) 1144 | TreeView.Add("selected",{tv:TV_Add("Selected")}) 1145 | TreeView.Add("windowtitle",{tv:TV_Add("Window Title")}) 1146 | TreeView.Add("windowname",{tv:TV_Add("Window Name")}) 1147 | hwnd(2,hwnd),ea:=settings.EA("//gui/settings") 1148 | if (ea.w) 1149 | ControlMove,SysTreeView321,,,% ea.w,% ea.h,% hwnd([2]) 1150 | Gui,2:Show,% GuiPos("//gui/settings","x5 y5 w150 h500"),Settings 1151 | Gui,3:+Resize +hwndhwnd -0x20000 -0x10000 +parent1 -ToolWindow 1152 | hwnd(3,hwnd),ea:=settings.EA("//gui/workarea"),pos:="" 1153 | Gui,3:Show,% GuiPos("//gui/workarea","x176 y5 w500 h500"),Work Area 1154 | Gui,3:Margin,0,0 1155 | for a,b in {Border:33,Caption:4,Menu:15}{ 1156 | SysGet,value,%b% 1157 | v[a]:=value 1158 | } 1159 | Gui,1:Show,% GuiPos("//gui/main","w700 h550"),GUI Creator 1160 | Hotkey,IfWinActive,% hwnd([1]) 1161 | Hotkey,^a,SelectAll,On 1162 | Hotkey,+^a,SelectAll,On 1163 | Hotkey,^z,Undo,On 1164 | Hotkey,^y,Redo,On 1165 | Hotkey,~Escape,Escape,On 1166 | Hotkey,~*LButton,LButton,On 1167 | Hotkey,Delete,Delete,On 1168 | WinSet,Redraw,,% hwnd([3]) 1169 | Hotkeys(),Options(1),New() 1170 | if(last:=settings.SSN("//last/@file").text) 1171 | Open(last),DisplaySelected() 1172 | new Undo() 1173 | return 1174 | 2GuiSize: 1175 | ControlMove,SysTreeView321,,,A_GuiWidth,A_GuiHeight,% hwnd([2]) 1176 | return 1177 | 2GuiClose: 1178 | 3GuiClose: 1179 | Exit(1) 1180 | return 1181 | } 1182 | hwnd(win,hwnd=""){ 1183 | static winkeep:=[] 1184 | if (win.rem){ 1185 | Gui,% win.rem ":Destroy" 1186 | return winkeep.remove(win.rem) 1187 | } 1188 | if IsObject(win) 1189 | return "ahk_id" winkeep[win.1] 1190 | if !hwnd 1191 | return winkeep[win] 1192 | winkeep[win]:=hwnd 1193 | return % "ahk_id" hwnd 1194 | } 1195 | Menu(info:=""){ 1196 | static menu:={order:["File","Edit","Options","Add","Help"],File:"&New|&Save|S&ave As|&Open|Ex&port|&Test GUI|E&xit|&Update Program",Add:"Button|Checkbox|ComboBox|DateTime|DropDownList|Edit|GroupBox|Hotkey|ListBox|ListView|MonthCal|Picture|Progress|Radio|Slider|Tab|Text|TreeView|UpDown",Options:"&Snap To Grid|Display &Grid|Grid &Dot Color|Grid &Background|Debug &Window",Edit:"Edit GLabels|Select All|Invert Selection|Edit &Hotkeys|Redraw",Help:"Help|Online Help"} 1197 | if info.menu 1198 | return menu 1199 | for a,b in Menu.order{ 1200 | for c,d in StrSplit(Menu[b],"|"){ 1201 | HotkeyXML({check:d}) 1202 | Menu,%b%,Add,% GetMenuItem(d),menucmd 1203 | } 1204 | } 1205 | for a,b in Menu.order 1206 | Menu,Main,Add,&%b%,:%b% 1207 | return "main" 1208 | menucmd: 1209 | MenuItem:=Clean(A_ThisMenuItem) 1210 | if(A_ThisMenu="options"&&MenuItem~="(Snap_To_Grid|Display_Grid|Debug_Window)") 1211 | return Options(MenuItem) 1212 | if(A_ThisMenuItem="Debug Window") 1213 | m("here") 1214 | if(IsFunc(MenuItem)) 1215 | %MenuItem%() 1216 | else if(A_ThisMenu="Add") 1217 | GetInfo(MenuItem) 1218 | else 1219 | m("Feature not implemented yet. Coming Soon") 1220 | return 1221 | } 1222 | HotkeyXML(item){ 1223 | if item.check 1224 | if !settings.SSN("//hotkeys/*[@menu='" item.check "']") 1225 | settings.Add("hotkeys/" Clean(item.check),{menu:item.check}) 1226 | } 1227 | Clean(info,type:=0){ 1228 | if(InStr(info,"`t")) 1229 | info:=RegExReplace(info,"(\t.*)") 1230 | if(type=1) 1231 | info:=RegExReplace(info,"_"," ") 1232 | else if(type=2) 1233 | info:=RegExReplace(info,"&") 1234 | else if(type=0) 1235 | info:=RegExReplace(RegExReplace(info," ","_"),"&") 1236 | return info 1237 | } 1238 | GuiPos(path,default){ 1239 | ea:=settings.EA(path) 1240 | for a,b in ea 1241 | if (b!="") 1242 | pos.=a b " " 1243 | return pos:=pos?pos:default 1244 | } 1245 | Open(filename=""){ 1246 | last:=settings.SSN("//last/@file").text,tabcount:=0 1247 | SplitPath,last,,dir 1248 | if(!filename) 1249 | FileSelectFile,filename,,%dir%,Select a Saved GUI,*.xml 1250 | if(ErrorLevel||!FileExist(filename)) 1251 | return 1252 | New(),window.xml.load(filename),list:=window.SN("//*[@type]") 1253 | while,ll:=list.Item[A_Index-1] 1254 | ll.RemoveAttribute("hwnd") 1255 | while,ll:=window.SN("//window/descendant::*").Item[A_Index-1],ea:=xml.EA(ll){ 1256 | if(InStr(ea.type,"tab")) 1257 | tabcount++ 1258 | if(ll.nodename="tab"){ 1259 | Gui,3:Tab,% ea.tab,% SubStr(GetClassNN(SSN(ll,"ancestor::control[@type='Tab' or @type='Tab2']/@hwnd").text),16) 1260 | ll.SetAttribute("hwnd",SSN(ll.ParentNode,"@hwnd").text) 1261 | Continue 1262 | } 1263 | if(!SSN(ll,"ancestor::control[@type='Tab' or @type='Tab2']")) 1264 | Gui,3:Tab 1265 | AddControl(ll) 1266 | } 1267 | ea:=window.EA("//workarea") 1268 | ControlMove,,% ea.x,% ea.y,% ea.w,% ea.h,% hwnd([3]) 1269 | settings.Add("last",{file:filename}),Highlight(),Eval() 1270 | Gui,3:Tab 1271 | } 1272 | GetMenuItem(menu,tv:=0){ 1273 | hotkey:=settings.SSN("//hotkeys/" Clean(menu) "/@hotkey").text 1274 | space:=tv?" = ":"`t",menu:=tv?RegExReplace(menu,"&"):menu 1275 | hotkey:=hotkey?menu space Convert_Hotkey(hotkey):menu 1276 | return hotkey 1277 | } 1278 | Options(x:=""){ 1279 | if (x=1){ 1280 | for a,b in StrSplit(Menu({menu:1}).options,"|"){ 1281 | if settings.SSN("//options/" Clean(b)).text 1282 | Menu,options,Check,%b% 1283 | else 1284 | Menu,options,UnCheck,%b% 1285 | } 1286 | func:=Clean(b) 1287 | if(IsFunc(func)) 1288 | %func%() 1289 | WinSet,Redraw,,% hwnd([3]) 1290 | return 1291 | } 1292 | settings.Add("options/" Clean(x),,(settings.SSN("//options/" Clean(x)).text?0:1)),Options(1) 1293 | if(Clean(x)="debug_window") 1294 | Debug(0) 1295 | } 1296 | Dlg_Color(Color,hwnd:=""){ 1297 | static 1298 | VarSetCapacity(cccc,16*A_PtrSize,0),cc:=1,size:=VarSetCapacity(CHOOSECOLOR,9*A_PtrSize,0) 1299 | Loop,16 1300 | NumPut(settings.SSN("//colors/@color" A_Index).text,cccc,(A_Index-1)*4,"UInt") 1301 | NumPut(size,CHOOSECOLOR,0,"UInt"),NumPut(hwnd,CHOOSECOLOR,A_PtrSize,"UPtr"),NumPut(Color,CHOOSECOLOR,3*A_PtrSize,"UInt"),NumPut(3,CHOOSECOLOR,5*A_PtrSize,"UInt"),NumPut(&cccc,CHOOSECOLOR,4*A_PtrSize,"UPtr") 1302 | ret:=DllCall("comdlg32\ChooseColorW","UPtr",&CHOOSECOLOR,"UInt") 1303 | colors:=[] 1304 | Loop,16 1305 | colors["color" A_Index]:=NumGet(cccc,(A_Index-1)*4,"UInt") 1306 | settings.Add("colors",colors) 1307 | if !ret 1308 | exit 1309 | return NumGet(CHOOSECOLOR,3*A_PtrSize) 1310 | } 1311 | class undo{ 1312 | undo:=[],redo:=[] 1313 | __New(){ 1314 | undo.undo:=[],undo.redo:=[] 1315 | } 1316 | Add(){ 1317 | undo.undo.Insert(window.SSN("//*").clonenode(1)) 1318 | } 1319 | Fix(in,out){ 1320 | last:=undo[in].Pop(),list1:=window.SN("//control"),list2:=SN(last,"//control"),undo[out].Insert(window.SSN("//*").CloneNode(1)) 1321 | while,ll:=list1.item[A_Index-1],ea:=xml.EA(ll) 1322 | if !SSN(last,"//*[@hwnd='" ea.hwnd "']") 1323 | DllCall("DestroyWindow",ptr,ea.hwnd),ll.ParentNode.RemoveChild(ll),action:=1 1324 | while,ll:=list2.item[A_Index-1],ea:=xml.EA(ll) 1325 | if !window.SSN("//*[@hwnd='" ea.hwnd "']") 1326 | top:=ll.ParentNode.NodeName="window"?window.SSN("//window"):window.SSN("//*[@hwnd='" SSN(ll.ParentNode,"@hwnd").text "']"),top.AppendChild(ll),AddControl(ll),action:=1 1327 | while,ll:=list2.item[A_Index-1],ea:=xml.EA(ll){ 1328 | ctrl:=window.SSN("//*[@hwnd='" ea.hwnd "']"),cea:=xml.EA(ctrl),move:="" 1329 | for a,b in ea{ 1330 | if(ea[a]!=cea[a]&&a~="\b(x|y|w|h)") 1331 | move.=a b " " 1332 | ctrl.SetAttribute(a,b) 1333 | } 1334 | if move 1335 | GuiControl,3:MoveDraw,% ea.hwnd,%move% 1336 | } 1337 | Highlight(),DisplaySelected() 1338 | SetTimer,Redraw,-10 1339 | } 1340 | RedoGo(){ 1341 | undo.redo.1?undo.Fix("redo","undo"):m("Nothing more to redo") 1342 | } 1343 | UndoGo(){ 1344 | undo.undo.1?undo.Fix("undo","redo"):m("Nothing more to undo") 1345 | } 1346 | } 1347 | f1:: 1348 | file:=window.SSN("//filename").text 1349 | ;SplitPath,file,,dir 1350 | Run,%file% 1351 | return --------------------------------------------------------------------------------