jaberwacky

GuiBuilderNxt - Reboot [08/18/2016]

151 posts in this topic

#1 ·  Posted (edited)

This is an update to GuiBuilder (CyberSlug, Roy, TheSaint, and many others) to run on the latest AutoIt Beta release.
 
For a chronological history of GuiBuilder and other GUI designers see: >AutoIt GUI Creators (Designers).

The seed of this effort is >here.

Note: This is early stage software.  Please help by reporting issues.

-----------------------------------------------------

Now for the latest exciting installment!  Tabs are now available!  One tab can be added to the GUI.  Move it, resize it, and right click to add a new tab item!  More context menu items on the way.  Also upcoming is the ability to be able to add controls to each tab item.

---------------------------------------------------------

GUIBuilderNxt - Reboot.zip - Exe included.

dl: 4286

Changelog:

Spoiler

[08/18/2016]

1) Tabs can now be added, resized, and moved.  Right click context menu allows the addition of new tab items.

[07/08/2015]

A 1) Worked out some silly bugs which caused crashes.

[03/7/2015]
    A 1) Shift + Drag now works for multiple selected controls.
      2) The text, left, top, width, and height of multiple selected
         controls can now be adjusted via the properties window.
      3) Better code generation.
      4) The issues with the Main tab in the properties window have been sorted out.
      5) General UI improvements and bug fixes.

[02/26/2015]
        A 1) Updown control seems to be fully supported now.  Now I just gotta work on tab controls.
                    2) Worked out some more control selection issues.
                    3) New feature: copy a control by holding shift while dragging.  May have a few issues.
        B 1) Shift + Drag to copy should be more consistent now.

[02/25/2015]
    A 1) Changed selection code per mLipok's request.
            2) Hopefully fixed as reported by Andreik.

    Thanks to everyone for their reports and input!

[02/23/2015]
    A 1) Grid background is now a graphic control.  Now it resizes to fit the gui. Thanks to UEZ for the >code!
            2) Drag and drop code replaced with Melba23's >code.
      3) Pasting multiple controls seem to work consistently now.
    B 1) Right clicking listviews should work correctly now.
      2) Right clicking controls should work in general now.

[02/20/2015]
    D 1) Syntax error per mLipok.
    C 1) Minor issue.
    B 1) Bug fix per mLipok.  Hard crash when deleting multiple controls.
    A 1) Copy, Paste and Delete multiple controls at once.
       2) Other multiple selection bugfixes, and I should start keeping track of specifics.

[02/13/2015]
    A - 1) Double click a group to select the group and its contents!  Thanks to MrCreatoR for his >MouseSetOnEvent UDF.
    B - 1) Double clicking should work consistently now.  I had messed up while trying to strip MouseSetOnEvent to only what I needed.

[02/12/2015]
    A - 1) Fixed more multiple selection bugs.
        2) Fixed paste issue where control is not at proper location.
        3) Rearranged control properties tab.  Tell me what you think.
    B - 1) Fixed issue with wiping the gui clean.
    C - 1) Fixed issue with selected control.
    D - 1) Fixed some issues because I forgot to run Au3Check.  Used AU3Stripper for a smaller exe.
    E - 1) Fixed an issue with window resizing.
    F - 1) Fixed an issue with selecting a group and its controls.
                2) Snap to grid is back to ten again.
    G - 1) Fixed issue with checkbox and radio controls being 1 pixel tall.

[02/10/2015]
    A - 1) Implemented a method of selecting multiple controls by using a selection rectangle.
                2) Moving the properties window into the toolbar window.
                3) Fixed several bugs here and there.
                4) Leaving the Text field blank in the Main tab of the properties tab will not create a
                     variable for that control during code generation.

[02/08/2015]
    A - Worked out a lot of individual and multiple control selection, moving, resize bugs.  Made some (very) small progress on tab controls.
    B - More multiple selection bugs squashed.  Fit to width customized to more controls.
    C - Resizing the window will snap to nearest fifth.

[02/05/2015]
    A - Ability to select and move multiple controls at once.  Buggy but workable. Let me know of any problems. Select multiple controls by holding
                down Ctrl and left clicking controls.
    B - Move a Group to move all controls contained therein.  Hold down Ctrl when selecting the group.
                Press Esc to close the Control Properties window (mLipok).
    C - Fixed some issues regarding moving controls with a Group.
    D - Fixed issues with selecting multiple controls.
    E - More multiple selection bugfixes.

New Features and fixes:
1) Show or hide control while moving or resizing control. *Currently bugged out*
2) Option to show controls which have had their state set to hidden.
3) Properties window for each control as they are selected.  This makes fine tuning a control easier.
4) A button which will resize a control's width to fit the text.  Uses Melba23's _StringSize library.
5) Remembers settings from the last session.
6) GuiOnEvent mode.  CyberSlug made mention of wanting to do this in the early days of GuiBuilder.
7) Maps rather than multidimensional arrays.
8) Consistent control naming, (i.e., instead of Group1, Button2, Button3, Radio4 it would now be Group1, Button1, Button2, Radio1).
9) Restructured the menubar layout per GuiBuilder Resurrected.
10) Hotkeys switched to accelerators.
11) Option to wipe the gui clear to the Edit menu.
12) Select and move multiple controls at once by holding down Ctrl or using a selection rectangle.
13) Copy, Paste and Delete multiple controls at once.
14) Solid grid background that now resizes to fit the GUI.
 
Roadmap:
1) Get the Tab control to work correctly. *Still in progress*
2) Finish adding properties settings to the control properties window.
3) Make the code generation produce code with a better layout.
4) Common GUI templates.  Ability to make your own templates too.
5) Select multiple controls and use arrow keys (or other method?) to snap the selected controls to align to the chosen edge.
6) Visual hints to tell you when you're within so many pixels from the edge of the window or control.  Mimics the gui designer of Visual Basic.
7) Double click a control to edit the text.
8) Visual hints to indicate selected controls, etc.
9) Ability to create and store custom controls.
 
Known issues:
1)Many!

Edited by jaberwacky
3 people like this

Share this post


Link to post
Share on other sites



No worries, will check it out. :thumbsup:

I had started to change the indents to proper tabs, but didn't get far yet .... no further than in the last one you've modified, probably.

I won't do anything more now (checking etc), until I've finished doing some tests with another program I'm working on. ;)

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

For those who may have missed it, this topic was a split-off from a discussion >here.

(see the bottom few entries of the prior page, for the beginning of the discussion)

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OK.  I have spent some more time refactoring this script.  In most peoples eyes this would no longer be a simple script but if you hear me out, it isn't that bad.  I have broken the script into three modules.  The main GUIBuilder, a view, and a model.  GUIBuilder is where the main message loop lives.  It determines the users actions and then behaves accordingly.  The view contains the variables and functions that are necessary to maintaining the GUI.  The model contains the variables and functions necessary to maintain the program's state.  I have also moved the changelog comments to a readme.

There is an error that occurs for me when I click on the Group control creation button on the left.  The program will hardcrash.  I believe I have located the source of the error to _CreateCtrl function.  I haven't dug deeper than that yet.

attachment=45949:GUIBuilder.zip 8 downloads

Edited by jaberwacky

Share this post


Link to post
Share on other sites

I think you can change this line:

MsgBox(64, "About " & $program_name, $program_version & " - created by CyberSlug, " & @LF & "and modified by Roy and TheSaint!")

btw.

How you Tidy your script in this way:

Global $menu_settings = GUICtrlCreateMenu("Settings")
Global $showGrid      = GUICtrlCreateMenuItem("Show grid",               $menu_settings)
Global $gridSnap      = GUICtrlCreateMenuItem("Snap to grid",            $menu_settings)
Global $pastePos      = GUICtrlCreateMenuItem("Paste at mouse position", $menu_settings)
Global $showHidden    = GUICtrlCreateMenuItem("Show hidden controls",    $menu_settings)

Global $menu_properties      = GUICtrlCreateMenuitem("Properties",     -1)
Global $menu_exit            = GUICtrlCreateMenuitem("Exit",           -1)
Global $menu_about           = GUICtrlCreateMenuitem("About",          -1) ; ADDED by TheSaint
Global $menu_save_definition = GUICtrlCreateMenuitem("SaveDefinition", -1) ; Roy add-on
Global $menu_load_definition = GUICtrlCreateMenuitem("LoadDefinition", -1) ; Roy add-on
Global $menu_info            = GUICtrlCreateMenuitem("Info",           -1) ; ADDED by TheSaint
Global $menu_vals            = GUICtrlCreateMenuitem("Vals",           -1) ; ADDED by TheSaint

Global $firstControl = 1 + $background

GuiCtrlSetState($contype[1], $GUI_CHECKED) ; initial selection

GUICtrlSetState($showGrid,   $GUI_CHECKED)
GUICtrlSetState($gridSnap,   $GUI_CHECKED)
GUICtrlSetState($pastePos,   $GUI_CHECKED)
GUICtrlSetState($showHidden, $GUI_CHECKED)

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

 

I think you can change this line:

MsgBox(64, "About " & $program_name, $program_version & " - created by CyberSlug, " & @LF & "and modified by Roy and TheSaint!")

There is no word on whether my changes will become official.  I consider TheSaint to be the main authority on GUIBuilder due to his continued interest and his status as an MVP. 

Share this post


Link to post
Share on other sites

A program called ByHand.exe.  :P

:lmao:


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

There is no word on whether my changes will become official.  I consider TheSaint to be the main authority on GUIBuilder due to his continued interest and his status as an MVP. 

Just because I'm likely the only one still using it, doesn't mean I'm any kind of authority or expert ... and my interest is probably unhealthy or hillbillyish ... backward. Still, I like what you say ... so you can be my friend any day.

I haven't really had the time to look at it properly yet, this time around, and when last I did (many years ago) it was a headache, but I persevered and got it to what it needed to be back then.

If you have done anything significant, then you should add your name as a contributor, just as Roy and I did.

If you can get it working in WIN 7 and beyond, then I for one will be grateful, as it would be something I would eventually need to address myself ... and I probably have enough projects happening. If I did address it though, this time around, being wiser and smarter and more experienced, I'd probably rewrite it the way I code now ... if just to help me better understand what is going on.

Working with most other people's code, is not one of my strong points, and up until now (as messy as it is) I have tried to stay faithful to its original state as conceived by the legendary CyberSlug ... somewhat like you would with a vintage car etc.

At the time CyberSlug wrote the program, it was pretty revolutionary and very well received, but no doubt needs more than a grease and oil change now.

P.S. Have you checked out the other versions and spinoffs? Some of those got quite complex and added missing features etc. I always had trouble getting them to run ... memory hungry for the time, I think.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

If you have done anything significant, then you should add your name as a contributor, just as Roy and I did.
Done.
 
I'd probably rewrite it the way I code now ... if just to help me better understand what is going on.

Me too.  Also, I have decided that whatever code I bundle with SciTECustomizationGUI has to meet certain standards and best practices.

Working with most other people's code, is not one of my strong points

Is that your fault or the fault of the code writer?

Have you checked out the other versions and spinoffs?

Nah.  I might when I work out the current issues.

 

Without furthur adieu, the latest version is now better structured.  More things are in functions.  $grippy[1 - 8] have been replaced with $NorthWest_Grippy, etc. Also, fixed the issue that caused a crash when selecting certain control creation buttons by upping the $MCL array to its maximum amount of elements.  It is a hack though.

My ultimate goal for this version is to modularize every aspect.  I want me and others to be able to go into the code, find what they are looking for and not have to wade through a bunch of other unrelated code.

Here is the very brief changelog: Major structural rearrangements and code refactoring.  Fixed labels displaying "foo" to now display the proper names. Fewer magic numbers.  Less global variables. Converted from HotKeys to Accelerators. Resized the GUI and changed the starting location.

Edit: OOPS, turns out I haven't been zipping up everything else!

attachment=45956:GUIBuilder.zip

prev: 19

Edited by jaberwacky

Share this post


Link to post
Share on other sites

 

Is that your fault or the fault of the code writer?

Wouldn't I like to just say the other coder.

The truth is, it could be either or .... or both.

I can lack understanding, due to my lack of skill.

I can lack willingness to do the hard yards ... I may suspect I lack the skill ... but it could just be laziness or lack of drive.

The lack of willingness, could also be because of messiness of the other coder or just the difficulty in understanding the way the other coder thinks or formats things. I may even disagree with their formatting, variable naming etc, which could then put me off.

I'll put the effort in (eventually) if i really need to, regardless.

At the end of the day, it can just be whether I'm in the mood for a challenge or feel like learning something.

I do predominantly code for practical reasons, then perhaps because of boredom and maybe even fun.

I'm also always doing some kind of programming, if just a little update to the large stable of programs I now maintain and regularly use. They will generally always take precedence over the troubleshooting of somebody else's code.

Thanks for your effort.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Latest version.  Made very decent progress, you could probably use this though I'm sure the menu functions and the hotkeys aren't working correctly yet.

Includes an exe for those of you without the latest beta.

attachment=45981:GUIBuilder.zip

dl: 29

Edited by jaberwacky

Share this post


Link to post
Share on other sites
Includes an exe for those of you without the latest beta.

That would be me.

Thanks.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

@jaberwacky - Just had a little play with the EXE, finally, and found it crashes when I try to use Properties to rename the text of a control.

Did you look at the changes in my last upload here, where I fixed that?

I just re-tested mine, and they work fine.

P.S. That was the version I uploaded >here, back at the original topic, before the split-off. I don't recall commenting everything I did, so you may need to check using a program like FileCompare. I'd been meaning to get back to things before now, but you seemed to have it all in hand, and I've been distracted by other things.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Ok as far as I can tell this version has all of the original features but now works on W7. 

exe included: attachment=45998:GUIBuilder.zip dl: 3

Edited by jaberwacky

Share this post


Link to post
Share on other sites

Very good. :thumbsup:

Simple quick test worked for me. :D

Thanks! :bye:

P.S. Of course, now that you've done all that, and are still enthused, you could look at adding the missing and/or disabled elements. ;) ;)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Very good. :thumbsup:

Simple quick test worked for me. :D

Thanks! :bye:

P.S. Of course, now that you've done all that, and are still enthused, you could look at adding the missing and/or disabled elements. ;) ;)

Nice!  Thanks.

I will look into it but I will break from it for a while though.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Got a working proof of concept working for tab controls.  Very basic, can't move or resize the control.  I'm thinking about making it so that tab items can be added to a tab control by right clicking the control and choosing to add a tab item.  I got even just this far by studying '?do=embed' frameborder='0' data-embedContent>>.

attachment=46008:GUIBuilder.zip dl: 22

Edited by jaberwacky
1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • davidacrozier
      By davidacrozier
      Hello all ~
      I am running an autoit script on Windows 10 inside VMware Workstation 12 Pro version 12.5.2.  Technically I am remoting into ESXi which has a Domain Controller (DC), WebServer, FilServer, Windows 10, etc.  Using the GUI (i.e. running explorer.exe) I am able to open several different folders successfully.  The desktop, documents, USB external all open without issue.  The network share opening gives me issues.  Whenever I attempt to open \\filserver\users\user\sharedfolder I get the documents folder instead.  I understand that the documents folder is the default for explorer.  I have also attempted to use the letter drive mapped to the network share (Z:) and receive the same result.  When I run this script on Windows 10 alone without  the VM or the ESXi I am able to open the network share without problems.  I have tried to use the net use command to designate a letter M: to the network share folder prior to running the script.  This did not work for me.  
      One additional avenue I think might work is to use the systreeview321 and _GUICtrlTreeView_FindItem to step through the tree looking for the network share.  Once found,  double click on it and see if that opens the shared network folder.  I can click inside the VM with my mouse on the network share and it opens just fine.  Not sure if running up against GUI issues, or permission issues, or what?
      Thanks in advance,
      Davida Crozier
      TestNetworkShare.au3
      This script is a subset of a much larger program, but it illustrates what I am dealing with.

    • superflq
      By superflq
      Hi everyone,
      GUICtrlSetState Function example ,i found $GUI_DROPACCEPTED isn't working in windows10 x64(windows_10_enterprise_2016_ltsb_x64).
      if the example put to windows10 x86 or windows xp, the $GUI_DROPACCEPTED is effective,
      the AutoIt Edition is v3.3.14.2.
      any ideas? thanks you.
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 420, 200, -1, -1, -1, $WS_EX_ACCEPTFILES) ; Create a label and set the state as drop accepted. Local $idLabel = GUICtrlCreateLabel("Drop a file on this label.", 10, 10, 400, 40, $WS_BORDER) GUICtrlSetState($idLabel, $GUI_DROPACCEPTED) ; Create an input and set the state as drop accepted. Local $idInput = GUICtrlCreateInput("", 10, 60, 400, 22) GUICtrlSetState($idInput, $GUI_DROPACCEPTED) Local $idOK = GUICtrlCreateButton("OK", 310, 170, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop Case $GUI_EVENT_DROPPED ; If the value of @GUI_DropId is $idLabel, then set the label of the dragged file. If @GUI_DropId = $idLabel Then GUICtrlSetData($idLabel, @GUI_DragFile) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
    • MrCheese
      By MrCheese
      Hey Guys,
       
      So, the functions work, where primarygui() accurately determines the evaluation of the status of the checkboxes - the msgbox picks this up.
       
      However, later on, when we re-enter a 'for $i = 0 to ubound($checkbox)' loop, then in the 'batchinitial' function it doesn't picked up that the status&$i = 1, so it jumps out, then within the While 1 loop, it exits the loop in the first row, again because the status& $i= 0
      The "assign" line within the primarygui funtion, is this only a local assignment? if so, how can I make it cross function?
       
      Thank in adv for your help
       
       
      Func excelsheetlist() $i = 0 Global $aWorkSheets = _Excel_SheetList($oWorkbook1) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example 1", "Error listing Worksheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;_ArrayDisplay($aWorkSheets, "Excel UDF: _Excel_SheetList Example 1") ;_ArrayDisplay($aWorkSheets, "Array") Global $iRows = UBound($aWorkSheets, $UBOUND_ROWS) ; Total number of rows. In this example it will be 10. Global $iCols = UBound($aWorkSheets, $UBOUND_COLUMNS) ; Total number of columns. In this example it will be 20. Global $iDimension = UBound($aWorkSheets, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional. MsgBox($MB_SYSTEMMODAL, "", "The array is a " & $iDimension & " dimensional array with " & _ $iRows & " row(s) & " & $iCols & " column(s).") Dim $checkbox[$iRows] EndFunc ;==>excelsheetlist Func primarygui() ; Create a GUI with various controls. Local $hGUI = GUICreate("Script Controller", 300, ($iRows * 24)) ; Create a checkbox control. ;Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25) Local $Button2 = GUICtrlCreateButton("Close", 210, 200, 85, 25) Local $Button3 = GUICtrlCreateButton("Run", 210, 170, 85, 25) Local $Button1 = GUICtrlCreateButton("Discharge", 210, 140, 85, 25) For $i = 0 To UBound($checkbox) - 1 $checkbox[$i] = GUICtrlCreateCheckbox($aWorkSheets[$i][0], 8, 0 + ($i * 24)) ;, 81, 17) Next ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button2 ;Close Exit Case $nMsg = $Button1 MsgBox(0, "Discharge Button not configured", "Now Exiting") Exit Case $nMsg = $Button3 ;Run $fSelection = False For $i = 0 To UBound($checkbox) - 1 If BitAND(GUICtrlRead($checkbox[$i]), $GUI_CHECKED) Then $fSelection = True ExitLoop EndIf Next If $fSelection Then For $i = 0 To UBound($checkbox) - 1 Assign("status" & $i, GUICtrlRead($checkbox[$i])) Next $batchcount = 0 For $i = 0 To UBound($checkbox) - 1 If Eval("status" & $i) = 1 Then $batchcount = $batchcount + 1 ;Call ("o" & $i & "copy") ; if you want to call the functions directly, remove ; before the call and comment or delete the following DirCopy statement MsgBox(0, "Checking", "Checking that: " & $checkbox[$i] & " no, with title: " & $aWorkSheets[$i][0] & " was selected, Batch count: " & $batchcount) ; if you need only the DirCopy EndIf Next ExitLoop Else MsgBox(48, 'No Items Selected', 'You have not selected any Patients to Load, Please select from the list') EndIf EndSelect WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>primarygui Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func batchinitial() If Eval("status" & $i) = 1 Then debugbox() $oWorkbook1.Sheets(1).Activate $bigloop = $bigloop + 1 $sheet = $aWorkSheets[$i][0] $oWorkbook1.Sheets($sheet).Activate debugbox() EndIf EndFunc ;==>batchinitial OpenExcel() excelsheetlist() primarygui() For $i = 0 To UBound($checkbox) - 1 batchinitial() While 1 If Eval("status" & $i) = 0 Then ExitLoop ;all the rest of my script loops etc WEnd Next  
    • hcI
      By hcI
      Hello everyone !
      While writing a sample of code to test ping to my internet box, I got stuck..
      While the code is Pinging with let say.. 5000ms of timeout, I need to update a progress bar from 0 to 5000 ms at the same time but I don't know how could I do this..
      Is there a way or something that could get around the pause of the ping like in InetGet -> InetGetInfo?
    • tcurran
      By tcurran
      Here are two functions to provide pixel-accurate height and width dimensions for a given string.
      The more commonly-used _GDIPlus_GraphicsMeasureString built-in UDF is problematic because it returns the width padded by roughly one en-space (for reasons related to the various ways Windows produces anti-aliased fonts).
      These are AutoIt translations of Pierre Arnaud's C# functions, described in his CodeProject article "Bypass Graphics.MeasureString limitations"
      The first is an all-purpose version that takes a window handle, string, font family, font size (in points), style, and (optionally) width of the layout column (in pixels) as parameters.
      The second, more efficient version is intended for applications where GDI+ fonts are already in use, and takes handles to the existing graphics context, string, font, layout and format as parameters.
      Both functions return a two-row array with the exact width [0] and height [1] of the string (in pixels).
      EDIT: (Note that some of the same anti-aliasing measurement issues still apply. I did my best to work around them, but the output of the function may still be off by a pixel or two. Buyer beware.)
      #include <GDIPlus.au3> #include <GUIConstantsEx.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringInPixels ; Description ...: Returns a pixel-accurate height and width for a given string using a given font, style and size. ; Syntax ........: _StringInPixels($hGUI, $sString, $sFontFamily, $fSize, $iStyle[, $iColWidth = 0]) ; Parameters ....: $hGUI - Handle to the window. ; $sString - The string to be measured. ; $sFontFamily - Full name of the font to use. ; $fSize - Font size in points (half-point increments). ; $iStyle - Combination of 0-normal, 1-bold, 2-italic, 4-underline, 8-strikethrough ; $iColWidth - [optional] If word-wrap is desired, column width in pixels ; Return values .: 2-row array. [0] is width in pixels; [1] is height in pixels. ; Author ........: Tim Curran; adapted from Pierre Arnaud's C# function ; Modified ......: ; Remarks .......: This version is longer and less efficient but works for all purposes. ; Related .......: <https://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations> ; Link ..........: ; Example .......: Example-StringInPixels.au3 ; =============================================================================================================================== #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Func _StringInPixels($hGUI, $sString, $sFontFamily, $fSize, $iStyle, $iColWidth = 0) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle Local $aRanges[2][2] = [[1]] $aRanges[1][0] = 0 ;Measure first char (0-based) $aRanges[1][1] = StringLen($sString) ;Region = String length Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFontFamily) Local $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges Local $aWinClient = WinGetClientSize($hGUI) If $iColWidth = 0 Then $iColWidth = $aWinClient[0] Local $tLayout = _GDIPlus_RectFCreate(10, 10, $iColWidth, $aWinClient[1]) Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions Local $aBounds = _GDIPlus_RegionGetBounds($aRegions[1], $hGraphic) Local $aWidthHeight[2] = [$aBounds[2], $aBounds[3]] ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_RegionDispose($aRegions[1]) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Return $aWidthHeight EndFunc ;==>_StringInPixels ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringInPixels_gdip ; Description ...: Returns a pixel-accurate height and width for a given string using a GDI+ font, layout and format ; Syntax ........: _StringInPixels_gdip($hGraphic, $sString, $hFont, $tLayout, $hFormat) ; Parameters ....: $hGraphic - Handle to a GDI+ graphics object. ; $sString - The string to be measured. ; $hFont - Handle to a GDI+ font. ; $tLayout - A $tagGDIPRECTF structure that bounds the string. ; $hFormat - Handle to a GDI+ string format. ; Return values .: 2-row array. [0] is width in pixels; [1] is height in pixels. ; Author ........: Tim Curran; adapted from Pierre Arnaud's C# function ; Modified ......: ; Remarks .......: This much more efficient version is for use with GDI+ fonts ; Related .......: ; Link ..........: <https://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations> ; Example .......: Example-StringInPixels.au3 ; =============================================================================================================================== #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Func _StringInPixels_gdip($hGraphic, $sString, $hFont, $tLayout, $hFormat) Local $aRanges[2][2] = [[1]] $aRanges[1][0] = 0 ;Measure first char (0-based) $aRanges[1][1] = StringLen($sString) ;Region = String length _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_CLEARTYPEGRIDFIT) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions Local $aBounds = _GDIPlus_RegionGetBounds($aRegions[1], $hGraphic) Local $aWidthHeight[2] = [$aBounds[2], $aBounds[3]] _GDIPlus_RegionDispose($aRegions[1]) Return $aWidthHeight EndFunc ;==>_StringInPixels_gdip  
      _StringInPixels.au3
      Example-StringInPixels.au3