Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

How to convert GUI scripts to v3.2.12.0


  • Please log in to reply
69 replies to this topic

#1 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,294 posts

Posted 10 May 2008 - 08:28 AM

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.








#2 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,294 posts

Posted 10 May 2008 - 09:48 AM

Discuss.

#3 monoceres

monoceres

    asdf

  • MVPs
  • 3,959 posts

Posted 10 May 2008 - 12:10 PM

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)
AutoIt         
#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!


#4 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,557 posts

Posted 10 May 2008 - 12:42 PM

Very handy tool for this migration process is Organize Includes from Xenobiologist
Link: http://www.autoitscript.com/forum/index.php?showtopic=55368

Edited by Zedna, 10 May 2008 - 12:43 PM.


#5 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 16 May 2008 - 07:11 PM

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.
GeorgeQuestion 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!"

#6 MattX

MattX

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 349 posts

Posted 16 May 2008 - 11:13 PM

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 ?

#7 monoceres

monoceres

    asdf

  • MVPs
  • 3,959 posts

Posted 17 May 2008 - 06:36 AM

You need additional constants, please test my script above :)

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


#8 MattX

MattX

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 349 posts

Posted 17 May 2008 - 07:50 AM

You need additional constants, please test my script above :)


I ran your excellent script against mine and it stated it didn't need any additional constants...

#9 i542

i542

    Captain on the Bridge.

  • Active Members
  • PipPipPipPipPipPip
  • 1,821 posts

Posted 17 May 2008 - 08:21 AM

You need to add #include <WindowsConstants.au3> :)
I can do signature me.

#10 monoceres

monoceres

    asdf

  • MVPs
  • 3,959 posts

Posted 17 May 2008 - 04:46 PM

You also need:
#include <StaticConstants.au3>

Ps. tested fixing your script with my script, it worked fine. Sure you specified the include folder in the autoit folder?

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


#11 1bobby

1bobby

    Wayfarer

  • Active Members
  • Pip
  • 50 posts

Posted 19 May 2008 - 04:31 PM

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.



#12 1bobby

1bobby

    Wayfarer

  • Active Members
  • Pip
  • 50 posts

Posted 19 May 2008 - 06:17 PM

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!

#13 monoceres

monoceres

    asdf

  • MVPs
  • 3,959 posts

Posted 19 May 2008 - 06:46 PM

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!


#14 mdwerne

mdwerne

    Polymath

  • Active Members
  • PipPipPipPip
  • 209 posts

Posted 20 May 2008 - 08:02 PM

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.

Plain Text         
;#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


#15 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 20 May 2008 - 09:00 PM

Change $STDOUT_CHILD to 2
GeorgeQuestion 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!"

#16 mdwerne

mdwerne

    Polymath

  • Active Members
  • PipPipPipPip
  • 209 posts

Posted 20 May 2008 - 09:25 PM

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

#17 mdwerne

mdwerne

    Polymath

  • Active Members
  • PipPipPipPip
  • 209 posts

Posted 20 May 2008 - 10:50 PM

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

#18 Andy007

Andy007

    Seeker

  • Active Members
  • 31 posts

Posted 20 May 2008 - 11:38 PM

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, 20 May 2008 - 11:40 PM.

Regards,Andy (no, the other one)

#19 mdwerne

mdwerne

    Polymath

  • Active Members
  • PipPipPipPip
  • 209 posts

Posted 21 May 2008 - 01:48 AM

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

#20 Andy007

Andy007

    Seeker

  • Active Members
  • 31 posts

Posted 21 May 2008 - 02:22 AM

Thanks Mike.

That worked. I just assumed it should have been fine in the first place being a sample au3 script that was installed during the setup.
Regards,Andy (no, the other one)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users