Sign in to follow this  
Followers 0
lyledg

Gui Exe Not Working

9 posts in this topic

Hi Guys..

Not sure what is going on..

I have created a script using the GUIcreate etc controls, and am able to run the script manualy(right click, run script) on the actual *.au3 file, but when I compile it into an EXE and run it, I get error's..

Why is this?

Cheers

Lyle

Share this post


Link to post
Share on other sites



This shouldn't happen. Could we see the source? And it would also help to know what version of AutoIt you are using.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Sure mate...thankx..

I am using version 3.0.102.0..

Here is the source....Also, I am really new to AutoIT so please excuse if things can be done better in the code..I would appreciate ANY feedback to get this working better...

It is a logon script that I am crating to use within our company..

Cheers!

Lyle :ph34r:

$Path = ("Servername\path$")

$File = FileOpen("\\Servername\path$\MOTD.htm", 0)

;$File = FileOpen("C:\build\MOTD.htm", 0)

$Env = Envget("PLATFORM")

$LogonVer = " 2.4.0"

$Sdrive = "S: " & DriveMapGet("S:")

$Ldrive = "L: " & DriveMapGet("L:")

$Odrive = "O: " & DriveMapGet("O:")

$Username = "Welcome: " & @Username

$Homedrive = "HomeDrive: P:" & DriveMapGet("P:")

$LogonServer = "LogonServer: " & @Logonserver

$Workstation = "Workstation: " & @Computername

$Alldrives = $Sdrive & @CRLF & $Ldrive & @CRLF & $Odrive

dim $Logoninfo = $Username & @CRLF & $Homedrive & @CRLF & $LogonServer & @CRLF & $Workstation

; Run the logon.cmd from a command line

$Logon = Runwait(@COMSPEC & " /c Logon.cmd", @WindowsDir, @SW_MINIMIZE)

; Start GUI creation

GuiCreate("Login details..", 350, 300)

Opt("GuiCoordMode", 0)

If $Env = "Client" then

;Check to see if Logon script ran correctly and timeout after 5 seconds

DriveMapGet("L:")

If @error = 1 then

GuiCreate("Logon Error..", 285, 135)

GUISetControl( "Label", "ERROR!!...Logon Script did not execute correctly, please investigate..." , 25, 30, 180, 100)

GuiShow(5)

GuiWaitClose()

else

Opt("GuiCoordMode", 1)

GUISetControl( "Group", "User Credentials", 50, 30, 250, 250)

GuiSetControlFont(-1,9,700)

GUISetControl( "Label", $Username , 65, 50, 200, 100)

GUISetControl( "Label", $Workstation , 65, 65, 200, 100)

GUISetControl( "Label", $LogonServer , 65, 80, 200, 100)

Opt("GuiCoordMode", 1)

GUISetControlEx (-1, 70)

$Progress = GUISetControl( "progress", "", 80, 110, 150, 20)

GUISetControl( "Label", "Mapped Drives" , 65, 135, 200, 100)

GuiSetControlFont(-1,9,700)

GUISetControl( "Label", $SDrive , 65, 155, 200, 100)

GUISetControl( "Label", $LDrive , 65, 170, 200, 100)

GUISetControl( "Label", $ODrive , 65, 185, 200, 80)

; Check to extract MOTD from a DFS path and display to the end user

;

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "MOTD", "No Message of the day..., continuing", 1)

Exit

else

; Display MOTD

If @error = -1 Then ExitLoop

Run(@ComSpec & ' /c "' & $Path & '\MOTD.htm"', '', @SW_HIDE)

Endif

Endif

; Now extract the current date and time to log the last logon time of each user and pipe this to C:\OSLbuild\Lastlogon.txt

;=====script start============

; format for week day

Select

Case @WDAY =1

$weekday = " Sun"

Case @WDAY =2

$weekday = " Mon"

Case @WDAY =3

$weekday = " Tue"

Case @WDAY =4

$weekday = " Wed"

Case @WDAY =5

$weekday = " Thur"

Case @WDAY =6

$weekday = " Fri"

Case @WDAY =7

$weekday = " Sat"

EndSelect

; format for months

Select

Case @MON =1

$monthday = " Jan"

Case @MON =2

$monthday = " Feb"

Case @MON =3

$monthday = " Mar"

Case @MON =4

$monthday = " Apr"

Case @MON =5

$monthday = " May"

Case @MON =6

$monthday = " Jun"

Case @MON =7

$monthday = " Jul"

Case @MON =8

$monthday = " Aug"

Case @MON =9

$monthday = " Sept"

Case @MON =10

$monthday = " Oct"

Case @MON =11

$monthday = " Nov"

Case @MON =12

$monthday = " Dec"

EndSelect

$myformat = @Username & $weekday & " - " & @MDAY & $monthday & " " & @YEAR & " @ " & @HOUR & "h" & @MIN

$filewithdate = "C:\Build\Lastlogon.txt"

If FileExists ($filewithdate) =0 then

FileOpen ($filewithdate, 1)

FileWriteLine ($filewithdate, $myformat)

FileClose($filewithdate)

Else

FileWriteLine ($filewithdate, $myformat)

EndIf

; display the GUI waiting a close action by default only button close the GUI

GuiShow(5)

Endif

GuiWaitClose()

Share this post


Link to post
Share on other sites

First problem: The GUI functions are not avaiable in the stable release of 3.0.102, for that you need the beta version. There used to be a 3.0.102 beta (with GUI) but that has been upgraded to 3.0.103 since 3.0.102 went stable. However, the 3.0.102 stable does not contain GUI functions, and will fail if you attempt to use any.

Suggestion: Since you don't actually use any GUI functions except labels, I would suggest that you simply use message boxes anyway.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

First problem: The GUI functions are not avaiable in the stable release of 3.0.102, for that you need the beta version.  There used to be a 3.0.102 beta (with GUI) but that has been upgraded to 3.0.103 since 3.0.102 went stable.  However, the 3.0.102 stable does not contain GUI functions, and will fail if you attempt to use any.

Suggestion: Since you don't actually use any GUI functions except labels, I would suggest that you simply use message boxes anyway.

<{POST_SNAPBACK}>

Thanks for the quick reply..

I was using message boxes, but I have been asked to develop something without "Ok" button and want the data retrieved on displayed on a single form.. I tried using SplashScreen but that did work entirely like I wanted it to...Hence the gui functions worked great..

So, where could I get a version of Autoit that would support gui functions, even though it may be beta, please?

Cheers

Share this post


Link to post
Share on other sites

So, where could I get a version of Autoit that would support gui functions, even though it may be beta, please?

<{POST_SNAPBACK}>

Use the 3.0.103 beta found in the unstable directory.

A couple other things when briefly looking at your code:

  • You use a progress control, but never update it. Isn't this rather useless?
  • There is a GuiCreate, but then you have some conditional code that will create a new GUI (essentially undoing the previous GuiCreate call.) You might want to re-think that.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Use the 3.0.103 beta found in the unstable directory.

A couple other things when briefly looking at your code:

  • You use a progress control, but never update it.  Isn't this rather useless?

  • There is a GuiCreate, but then you have some conditional code that will create a new GUI (essentially undoing the previous GuiCreate call.)  You might want to re-think that.

<{POST_SNAPBACK}>

Thanks for the suggestions.. I REALLY appreciate the help..

As for the progress bar, to be totally honest I was not sure how to use and update the progress bar with the Gui control...Do you have some example code I could follow please to make this work?

I was working on that just before I submitted my question to the forum, so yes there are still holes in the code..

Cheers matey..

Share this post


Link to post
Share on other sites

As for the progress bar, to be totally honest I was not sure how to use and update the progress bar with the Gui control...Do you have some example code I could follow please to make this work?

<{POST_SNAPBACK}>

Here ya go:

GuiCreate("Progress example", 200, 50)
  $progress = GuiSetControl("progress", "Progress", 0, 0, 200, 20)
GuiShow()

For $count = 0 To 100 Step 10;count to 100 by 10's to act as a percentage
  GuiSetControlEx($progress, $count);set the new percentage
  Sleep(500);half second pause to show sample progress
Next

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Here ya go:

GuiCreate("Progress example", 200, 50)
  $progress = GuiSetControl("progress", "Progress", 0, 0, 200, 20)
GuiShow()

For $count = 0 To 100 Step 10;count to 100 by 10's to act as a percentage
  GuiSetControlEx($progress, $count);set the new percentage
  Sleep(500);half second pause to show sample progress
Next

<{POST_SNAPBACK}>

Thanks Mate, incorporated that into my existing code and it looks great...

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
Sign in to follow this  
Followers 0