Jump to content

How to convert GUI scripts to v3.2.12.0


Jon
 Share

Recommended Posts

  • Administrators

In v3.2.12.0 a number of changes were made to the include files used for the GUI:

  • GUIConstants.au3 is identical to GUIConstantsEx.au3. This means that many scripts using advanced GUI functionality will need to use additional #include statements to include files containing constants that were previously and erroneously included.
  • GUIDefaultConstants.au3 no longer exists. You must now #include the corresponding individual constants file for the control type you need.

Needs some more detail, and maybe a step by step guide of how to convert a couple of scripts - please reply to this thread with suggestions/drafts of how this post should look and I'll update. This is to help with the inevitable flood of questions when 3.2.12.0 is released.

Link to comment
Share on other sites

  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I just made a small "updater" which will search through your scripts and add appropriate includes.

Feel free to change it since it's not very optimized and it could have some problems (Tested on one of my old projects with 400+ lines and worked flawless though)

#include <Array.au3>
#include <File.au3>
$script=FileOpenDialog("Choose script that will be fixed",@ScriptDir,"au3 (*.au3)")
$autoitdir=FileSelectFolder("Autoit Include folder","")
If $autoitdir="" Then Exit
If $script="" Then Exit
Global  $includelines, $scriptdata
Global $includestoadd[1], $count=0
$scriptdata=FileRead($script)
$includes=_FileListToArray($autoitdir,"*Constants*.au3")
For $i=1 To Ubound($includes)-1
    _FileReadToArray($autoitdir&"\"&$includes[$i],$includelines)
    For $j=1 To Ubound($includelines)-1
        If StringLeft($includelines[$j],12)="Global Const" Then
            $const=StringMid($includelines[$j],StringInStr($includelines[$j],"$"),StringInStr($includelines[$j],'=')-StringInStr($includelines[$j],"$")-1)
            If StringInStr($scriptdata,$const) Then
                _ArrayAdd($includestoadd,$includes[$i])
                ExitLoop
            EndIf
            
        EndIf
    Next
Next
For $a=1 To UBound($includestoadd)-1
    If StringInStr($scriptdata,"#include <"&$includestoadd[$a]&">")=0 And StringInStr($scriptdata,"#include<"&$includestoadd[$a]&">")=0 And $includestoadd[$a]<>"GUIConstants.au3" Then
        _FileWriteToLine($script,1,"#include <"&$includestoadd[$a]&">")
        $count+=1
    EndIf
Next
MsgBox(0,"Result",$count&" include(s) were added")

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Very handy tool for this migration process is Organize Includes from Xenobiologist

Link: http://www.autoitscript.com/forum/index.php?showtopic=55368

Too bad that doesn't work without Scite.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Odd why now lines in a script of mine like this: ( problem lies around $icon16= )

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Edugeek's Admin's Admin Bar 1.7.1", 465, 160, 64, 34)
$helpmenu = GUICtrlCreateMenu("Help")
$support_sites_menu = GUICtrlCreateMenu("Support Sites")
$infoitem = GUICtrlCreateMenuItem("About", $helpmenu)
$infoitem2 = GUICtrlCreateMenuItem("Support Sites", $support_sites_menu)
GUISetBkColor(0x0066FF)
$Icon16 = GUICtrlCreateIcon(@SystemDir & "\eventvwr.exe", 0, 380, 7, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP))
GUICtrlCreateLabel("Event", 381, 35)
GUICtrlCreateLabel("Viewer", 381, 48)
GUICtrlSetTip(-1, "Launch Event Viewer")

Is showing errors:

C:\COOL\test.au3(10,94) : WARNING: $SS_NOTIFY: possibly used before declaration.

$Icon16 = GUICtrlCreateIcon(@SystemDir & "\eventvwr.exe", 0, 380, 7, 32, 32, BitOR($SS_NOTIFY,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\COOL\test.au3(10,105) : WARNING: $WS_GROUP: possibly used before declaration.

$Icon16 = GUICtrlCreateIcon(@SystemDir & "\eventvwr.exe", 0, 380, 7, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~^

C:\COOL\test.au3(10,94) : ERROR: $SS_NOTIFY: undeclared global variable.

$Icon16 = GUICtrlCreateIcon(@SystemDir & "\eventvwr.exe", 0, 380, 7, 32, 32, BitOR($SS_NOTIFY,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\COOL\test.au3 - 1 error(s), 2 warning(s)

I have put in the new #include <GUIConstantsEx.au3> but why the variable errors when it worked ok before ?

Link to comment
Share on other sites

In v3.2.12.0 a number of changes were made to the include files used for the GUI:

  • GUIConstants.au3 is identical to GUIConstantsEx.au3. This means that many scripts using advanced GUI functionality will need to use additional #include statements to include files containing constants that were previously and erroneously included.
  • GUIDefaultConstants.au3 no longer exists. You must now #include the corresponding individual constants file for the control type you need.

Needs some more detail, and maybe a step by step guide of how to convert a couple of scripts - please reply to this thread with suggestions/drafts of how this post should look and I'll update. This is to help with the inevitable flood of questions when 3.2.12.0 is released.

Link to comment
Share on other sites

Monoceres, that is a GREAT script, once I figured it out. Love it. Ran two scripts and it sure bailed me out. Wish I could think that fast, but it works great. Thanks for your efforts for us new kids on the block. bobby

:) You the coder!

Link to comment
Share on other sites

Monoceres, that is a GREAT script, once I figured it out. Love it. Ran two scripts and it sure bailed me out. Wish I could think that fast, but it works great. Thanks for your efforts for us new kids on the block. bobby

:) You the coder!

Thanks :(

It sure has helped me out a lot as well :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Hello,

Not 100% sure this is relative to this post, but my problem has cropped up since switching to 3.2.12 and I am getting similar errors.

C:\Documents and Settings\mdwerne\Desktop\AutoIt Scripts\PrevMaintLite\Test.au3(8,119) : WARNING: $STDOUT_CHILD: possibly used before declaration.

$dsqOut = Run(@ComSpec & " /c dsquery computer domainroot -name " & @ComputerName, @SystemDir, @SW_HIDE, $STDOUT_CHILD)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\mdwerne\Desktop\AutoIt Scripts\PrevMaintLite\Test.au3(8,119) : ERROR: $STDOUT_CHILD: undeclared global variable.

$dsqOut = Run(@ComSpec & " /c dsquery computer domainroot -name " & @ComputerName, @SystemDir, @SW_HIDE, $STDOUT_CHILD)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\mdwerne\Desktop\AutoIt Scripts\PrevMaintLite\Test.au3 - 1 error(s), 1 warning(s)

I added all the includes below, and while my error above went away (by adding constants.au3), my dsquery is now blank.

Any thoughts?

Thanks, Mike

P.S. If it's not obvious, I'm still pretty new to scripting with AutoIt. Slowly trying to get better.

;#include <constants.au3>
#include <GUIConstants.au3>
;#include <GUIConstantsEx.au3>
;#include <WindowsConstants.au3>
;#include <StaticConstants.au3>

Global $dsqOut, $OU
$dsqOut = Run(@ComSpec & " /c dsquery computer domainroot -name " & @ComputerName, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
$OU = StdoutRead($dsqOut)

GUICreate("PML ", 500, 400)

$GROUP_1 = GUICtrlCreateGroup("Computer", 15, 10, 475, 157)
$LABEL_1 = GUICtrlCreateLabel("Computer Name:", 25, 30, 80, 20)
$INPUT_1 = GUICtrlCreateInput(@ComputerName, 110, 25, 75, 20)
$INPUT_2 = GUICtrlCreateInput($OU, 25, 95, 450, 20)

$Quit = GUICtrlCreateButton("Quit", 100, 300, 60, 50)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Quit
            ExitLoop
    EndSelect
WEnd
Link to comment
Share on other sites

Change $STDOUT_CHILD to 2

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Change $STDOUT_CHILD to 2

Thank you, that resolved the error I was getting without having constants.au3 included.

But for some reason my dsquery still comes up blank?

From a command line I'm getting a result, but for some reason the query is not making it back into the script. $INPUT_2 is blank.

Again, thank you for the optional handle to $STDOUT_CHILD.

-Mike

Link to comment
Share on other sites

Thank you, that resolved the error I was getting without having constants.au3 included.

But for some reason my dsquery still comes up blank?

From a command line I'm getting a result, but for some reason the query is not making it back into the script. $INPUT_2 is blank.

Again, thank you for the optional handle to $STDOUT_CHILD.

-Mike

Problem resolved!!!

After searching the forums I found this answer by Valik: http://www.autoitscript.com/forum/index.php?showtopic=16098

Bottomline, I added "ProcessWaitClose($dsqOut)" and all is well again. Not sure why 3.2.10 worked and 3.2 12 didn't, but oh well. It' s fixed.

-Mike

Link to comment
Share on other sites

Hi All,

Newbie alert...

I installed v3.2.10.0 the other day and then noticed the newer version, so installed that (removing the old one first).

I was able to run the clock.au3 (C:\Program Files\AutoIt3\Examples\GUI\Advanced\Clock.au3) in previous version but not now.

Can someone tell me how to make the changes to get it to work. I want to show the boss some of the things that can be done...

Any help will be appreciated. :)

Edited by Andy007

Regards,Andy (no, the other one)

Link to comment
Share on other sites

Hi All,

Newbie alert...

I installed v3.2.10.0 the other day and then noticed the newer version, so installed that (removing the old one first).

I was able to run the clock.au3 (C:\Program Files\AutoIt3\Examples\GUI\Advanced\Clock.au3) in previous version but not now.

Can someone tell me how to make the changes to get it to work. I want to show the boss some of the things that can be done...

Any help will be appreciated. :)

As I am in the noob boat too, take my suggestion with a grain of salt.

I added this:

#include <WindowsConstants.au3>

and commented out this:

;Global Const $ULW_ALPHA = 2

Works for me!

-Mike

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...