Sign in to follow this  
Followers 0
Basti756

[solved]Windows Server 2003: GUI not centered, BG image not loaded

7 posts in this topic

#1 ·  Posted (edited)

Hi there,

the script I coded should be launched right after an installation of Windows Server 2003 R2 (via HKLM\...\RunOnce or HKLM\...\Run; I tried both). The user gets a GUI, configures the installation of software and some settings, the machine reboots and everthing is supposed to work :D

But the first issue is that the GUI doesn't show up the way I want it. It should be centered with a picture (JPG) set as background but instead it's kind of moved to to the right and the picture doesn't show up. Another Issue is that an INI file is obviously not read by the script.

The strange thing about all this is that it works perfectly with Windows Vista and (which is actually a lot more strange) it does work when I restart it (Windows Server 2003 R2).

Here's the code of the GUI:

;Do 
;   Sleep ( 1000 )
;Until ProcessExists ( "explorer.exe" )

;ProcessClose ( "explorer.exe" )


#include <GUIconstants.au3>

If @IPAddress1 = "0.0.0.0" Then
    MsgBox (0,"Error","Keine Netzwerkverbindung vorhanden. Die Einrichtung wird daher abgebrochen." & @CRLF & " Stellen sie eine Netzwerkverbindung her und starten sie den Server neu, um den Assistenten erneut aufzurufen." )
    Exit
ElseIf @IPAddress1 = "127.0.0.1" Then
    MsgBox (0,"Error","Keine Netzwerkverbindung vorhanden. Die Einrichtung wird daher abgebrochen." & @CRLF & " Stellen sie eine Netzwerkverbindung her und starten sie den Server neu, um den Assistenten erneut aufzurufen." )
    Exit
ElseIf @IPAddress1 = "169.254.*.*" Then;<----------------MS Standard IP??????
    MsgBox (0,"Error","Keine Netzwerkverbindung vorhanden. Die Einrichtung wird daher abgebrochen." & @CRLF & " Stellen sie eine Netzwerkverbindung her und starten sie den Server neu, um den Assistenten erneut aufzurufen." )
    Exit
EndIf

#include <3c_networKer.au3>
#include <file.au3>
#include <String.au3>

Dim $welcome_label

Dim $lan_error_gui

Dim $next2
Dim $LAN_label 
Dim $ip_label1 
Dim $ip_label2 
Dim $ip_input 
Dim $subm_label1 
Dim $subm_label2 
Dim $subm_input 
Dim $gatew_label1 
Dim $gatew_label2 
Dim $dns_label1 
Dim $dns_label2 
Dim $dns_input 
Dim $wins_label1 
Dim $wins_label2 
Dim $wins_input 
Dim $ip_addr1
Dim $ip_addr2
Dim $subm_1
Dim $subm_2
Dim $gatew_1
Dim $dns_1 
Dim $dns_2 
Dim $wins_1 
Dim $wins_2

Dim $usercount
Dim $usertoplabel
Dim $user1_input
Dim $user2_input
Dim $user3_input
Dim $user4_input
Dim $user5_input
Dim $user1
Dim $user2
Dim $user3
Dim $user4
Dim $user5
Dim $next3

Dim $admnameInput
Dim $admpassInput
Dim $admmailInput
Dim $next4
Dim $admdomtoplabel
Dim $admnameLabel 
Dim $admpasslabel 
Dim $admmailLabel 

DirCreate ( "C:\install\configAssist" )
_FileCreate ( "C:\install\configAssist\trshcn.ini" )

$config_ini = "C:\install\configAssist\trshcn.ini"

$maingui = GUICreate("Einrichtungsassistent",800,600,$DS_SETFOREGROUND)
Opt("GUIOnEventMode", 1)
Opt ("GUICloseOnESC", 0)
;GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$pic = GUICtrlCreatePic ("bg.jpg",0,0,800,600)
GUICtrlSetState ( $pic , $GUI_DISABLE)
$setup_assist = GUICtrlCreateLabel ( "Einrichtungsassistent", 300, 100, 170,30) 
    GUICtrlSetFont ( $setup_assist , 14)
    GUICtrlSetBkColor ( $setup_assist, 0xffffff )
    GUICtrlSetColor ( $setup_assist , 0x696969 )

$info_open = FileOpen ( "info.txt",0)
$info_read = FileRead ( $info_open )
FileClose ( $info_open )

$welcome_label = GUICtrlCreateEdit ( $info_read , 300,170,300,200,BitOR($ES_WANTRETURN,$WS_VSCROLL,$ES_AUTOVSCROLL,$ES_READONLY))
    GUICtrlSetBkColor ( $welcome_label , 0xffffff)

    
$next1 = GUICtrlCreateButton ( "Weiter", 650,460,80,30)
    GUICtrlSetOnEvent ( $next1 , "StartConfig" )

$step1 = GUICtrlCreateLabel ( "Willkommen", 30, 120,100,20)
    GUICtrlSetFont ( $step1 , 13)
    GUICtrlSetBkColor ( $step1, 0xffffff )
    GUICtrlSetColor ( $step1 , 0x000000 )
$step2 = GUICtrlCreateLabel ( "Netzwerk", 30, 150,100,20)
    GUICtrlSetFont ( $step2 , 13)
    GUICtrlSetBkColor ( $step2, 0xffffff )
    GUICtrlSetColor ( $step2 , 0x696969 )
$step3 = GUICtrlCreateLabel ( "Benutzer", 30, 180,100,20)
    GUICtrlSetFont ( $step3 , 13)
    GUICtrlSetBkColor ( $step3, 0xffffff )
    GUICtrlSetColor ( $step3 , 0x696969 )
$step4 = GUICtrlCreateLabel ( "Domäne", 30, 210,100,20)
    GUICtrlSetFont ( $step4 , 13)
    GUICtrlSetBkColor ( $step4, 0xffffff )
    GUICtrlSetColor ( $step4 , 0x696969 )
$step5 = GUICtrlCreateLabel ( "Fertig", 30, 240,100,20)
    GUICtrlSetFont ( $step5 , 13)
    GUICtrlSetBkColor ( $step5, 0xffffff )
    GUICtrlSetColor ( $step5 , 0x696969 )
    
$message_group = GUICtrlCreateGroup ( "Meldungen", 30,280,200,200)
        GUICtrlSetBkColor ( $message_group, 0xffffff )

$usercount = IniRead ( "licence.lic" , "user" , "count" , "" )
$DomainName = IniRead ( "licence.lic" , "domain" , "name" , "" )

;WinSetOnTop ( "Einrichtungsassistent", "", 1 )
GUISetState (@SW_SHOW)

While 1
  Sleep(1000)
WEnd

There are a lot of functions after that piece of code I posted but I don't think they are necessary for the behavior of the GUI since they just used when a button is pressed.

So anybody got an idea on my issues?

Thanks in advance, Bastian

Edited by Basti756

Share this post


Link to post
Share on other sites



...It should be centered with a picture (JPG) set as background but instead it's kind of moved to to the right and the picture doesn't show up...

Regarding the "centered" issue, here's how I typically handle forcing my GUIs to be centered:

$GUIWidth = 400
$GUIHeight = 300

$GUI = GUICreate("Centered Window",$GUIWidth,$GUIHeight,(@DesktopWidth-$GUIWidth)/2,(@DesktopHeight - $GUIHeight)/2)

Still crawling through the code regarding the other issues.


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Thanks for the quick reply. I'm gonna try that on monday when I'm back at work

Share this post


Link to post
Share on other sites

Also here is a function I have in my dialog udf to do the same thing.

Func _Win_Center($hWnd)
   $cPos = WinGetPos($hWnd)
   If WinMove($hWnd, "", (@DesktopWidth/2) - ($cPos[2]/2), (@DesktopHeight/2) - ($cPos[3]/2)) Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc;;<==> _Win_Center()

You can call it one of two ways

_Win_Center($guimain)
GUISetState()

or

If _Win_Center($guimain) Then GUISetState()

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

Share this post


Link to post
Share on other sites

I tried the suggestions and both of them are working. Now I'm still stuck with the missing background image. Additionally I recognized that the file "info.txt" is not not loaded:

$info_open = FileOpen ( "info.txt",0)
$info_read = FileRead ( $info_open )
FileClose ( $info_open )

$welcome_label = GUICtrlCreateEdit ( $info_read, 300,170,300,200,BitOR($ES_WANTRETURN,$WS_VSCROLL,$ES_AUTOVSCROLL,$ES_READONLY))
    GUICtrlSetBkColor ( $welcome_label , 0xffffff)

Just a guess... is the explorer.exe needed for displaying images and txt files in a GUI?

Share this post


Link to post
Share on other sites

I solved the background issue by adding @ScriptDir to the file path. So everything's working now.

Thanks again guys

Share this post


Link to post
Share on other sites

I solved the background issue by adding @ScriptDir to the file path. So everything's working now.

Thanks again guys

Good to hear it's working.

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

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