Vaeb Posted November 14, 2007 Share Posted November 14, 2007 Hi every1! I've got this part of a script: expandcollapse popupFunc main2() GUISetState(@SW_HIDE, $SGui) $Gui1 = GUICreate("Stockwerk", "701", "661") GUICtrlCreatePic(@ScriptDir & "\System\bild2.bmp", "5", "5", "691", "631") $og1 = GUICtrlCreateButton("Obergeschoss 1", "50", "50") GUICtrlSetOnEvent($og1, "Obergeschosse") $og2 = GUICtrlCreateButton("Obergeschoss 2", "50", "150") GUICtrlSetOnEvent($og2, "Obergeschosse") $og3 = GUICtrlCreateButton("Obergeschoss 3", "50", "250") GUICtrlSetOnEvent($og3, "Obergeschosse") $og4 = GUICtrlCreateButton("Obergeschoss 4", "50", "350") GUICtrlSetOnEvent($og4, "Obergeschosse") $og5 = GUICtrlCreateButton("Obergeschoss 5", "50", "450") GUICtrlSetOnEvent($og5, "Obergeschosse") $og6 = GUICtrlCreateButton("Obergeschoss 6", "50", "550") GUICtrlSetOnEvent($og6, "Obergeschosse") $ort1 = GUICtrlCreateButton("ort1", "150", "290") GUICtrlSetOnEvent($ort1, "ort1") GUICtrlSetState($ort1, $GUI_DISABLE) $ort3 = GUICtrlCreateButton("ort3", "384", "465") GUICtrlSetOnEvent($ort3, "ort3") GUICtrlSetState($ort3, $GUI_DISABLE) $ort2 = GUICtrlCreateButton("ort2", "220", "470") GUICtrlSetOnEvent($ort2, "ort2") GUICtrlSetState($ort2, $GUI_DISABLE) $Exit = GUICtrlCreateMenu("Beenden") GUICtrlCreateMenuitem("Exit", $Exit) GUICtrlSetOnEvent(-1, "ExitMenu") GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2") GUISetState(@SW_SHOW, $Gui1) EndFunc While 1 Sleep(100) WEnd Func Obergeschosse() $Gui1 = GUIGetMsg() Switch $Gui1 Case $og1 $msgn = "ers" $n = "1" GUICtrlCreatePic(@ScriptDir & "\System\bild1", "5", "5", "691", "631") GUICtrlSetState($og1 And $og2 And $og3 And $og4 And $og5 And $og6, $GUI_DISABLE) GUICtrlSetState($ort1 And $ort3, $GUI_ENABLE) Case $og2 $msgn = "zwei" $n = "2" GUICtrlCreatePic(@ScriptDir & "\System\bild1.bmp", "5", "5", "691", "631") GUICtrlSetState($og1 And $og2 And $og3 And $og4 And $og5 And $og6, $GUI_DISABLE) GUICtrlSetState($ort1 And $ort2 And $ort3, $GUI_ENABLE) EndSwitch EndFunc And the problems are: 1. The buttons sometimes hide behind the picture. 2. The buttons doesn't work when i click on them with the mouse. 3. When i click on a button, nothing happens. Do any1 know how i can fix this? Greets Vaeb I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
Siao Posted November 14, 2007 Share Posted November 14, 2007 Open helpfile and read whole article about GUICtrlCreatePic(). "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Zedna Posted November 14, 2007 Share Posted November 14, 2007 as siao said, here is little help: $pic1 = GUICtrlCreatePic("",0,0,400,300) GUICtrlSetState(-1,$GUI_DISABLE) Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Vaeb Posted November 15, 2007 Author Share Posted November 15, 2007 Thanks for your help. @Zedna: Sith that part, i can now use my mouse to click the Buttons. I still have this problem: Nothing happens when i click on a Button. The Picture should change and some buttons should be enabled after i clicked on a button. Here is the actual part of the script: Func Obergeschosse() $pic111 = GUICtrlCreatePic(@ScriptDir & "\System\pic.bmp", "5", "5", "691", "631",$WS_CLIPSIBLINGS) GUICtrlSetState(-1,$GUI_DISABLE) While 1 $msg = GUIGetMsg() Switch $msg Case $og1 $msgn = "ers" $n = "1" GUICtrlSetState($og1, $GUI_DISABLE) GUICtrlSetState($og2, $GUI_DISABLE) GUICtrlSetState($og3, $GUI_DISABLE) GUICtrlSetState($og4, $GUI_DISABLE) GUICtrlSetState($og5, $GUI_DISABLE) GUICtrlSetState($og6, $GUI_DISABLE) GUICtrlSetState($place1, $GUI_ENABLE) GUICtrlSetState($place2, $GUI_ENABLE) ExitLoop Case $og2 $msgn = "zwei" $n = "2" GUICtrlSetState($og1, $GUI_DISABLE) GUICtrlSetState($og2, $GUI_DISABLE) GUICtrlSetState($og3, $GUI_DISABLE) GUICtrlSetState($og4, $GUI_DISABLE) GUICtrlSetState($og5, $GUI_DISABLE) GUICtrlSetState($og6, $GUI_DISABLE) GUICtrlSetState($place1, $GUI_ENABLE) GUICtrlSetState($place3, $GUI_ENABLE) ExitLoop Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Greets Vaeb I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
BrettF Posted November 15, 2007 Share Posted November 15, 2007 Not sure how you are really doing this, but maybe call Obergeschosse() in your while loop? I am really lost with your code though Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Zedna Posted November 15, 2007 Share Posted November 15, 2007 I think you should use GUICtrlSetImage instead of GUICtrlCreatePic later in your script. Resources UDF  ResourcesEx UDF  AutoIt Forum Search Link to comment Share on other sites More sharing options...
Vaeb Posted November 15, 2007 Author Share Posted November 15, 2007 Thanks for your fast help! @ Bert: I can't do that, cause th pic has to change. @ Zedna: You was right. The pic-color changes now. The stuff with the cases still don't work. When I click on the button $og1, the og-buttons should be disabled and some other buttos should be enabled. Greets Vaeb I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
BrettF Posted November 15, 2007 Share Posted November 15, 2007 (edited) Thanks for your fast help!@ Bert: I can't do that, cause th pic has to change.@ Zedna: You was right. The pic-color changes now.The stuff with the cases still don't work.When I click on the button $og1, the og-buttons should be disabled and some other buttos should be enabled.GreetsVaebEhhh... Sorry. Didn't read your 1st post properly. Give me a sec to see It has to be either GUICtrlSetOnEvent, or GUIGetMsg, so which is it going to be? Edited November 15, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Vaeb Posted November 15, 2007 Author Share Posted November 15, 2007 I would like to do it by GUIGetMsg. What have i got to change? I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
BrettF Posted November 15, 2007 Share Posted November 15, 2007 (edited) I would like to do it by GUIGetMsg.What have i got to change?Remove all the GUICtrlSetOnEvent Functions, and add a case for the control into the while loop (The one in the func, you can use to replace the one with the sleep...) Edited November 15, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Vaeb Posted November 15, 2007 Author Share Posted November 15, 2007 I think I'm goin crazy I tried to do what you said. The script does strange things. It's really not doing what I want it to do This is how the relevant part looks: expandcollapse popupmain() While 1 $Obg = GUIGetMsg () Switch $Obg Case $og1 GUICtrlSetImage ($pic111, @ScriptDir & "\System\pic2.bmp") GUICtrlSetState(-1,$GUI_DISABLE) $msgn = "ers" $n = "1" GUICtrlSetState($og1, $GUI_DISABLE) GUICtrlSetState($og2, $GUI_DISABLE) GUICtrlSetState($og3, $GUI_DISABLE) GUICtrlSetState($og4, $GUI_DISABLE) GUICtrlSetState($og5, $GUI_DISABLE) GUICtrlSetState($og6, $GUI_DISABLE) GUICtrlSetState($place1, $GUI_ENABLE) GUICtrlSetState($place3, $GUI_ENABLE) Case $og2 GUICtrlSetImage ($pic111, @ScriptDir & "\System\pic2.bmp") $msgn = "zwei" $n = "2" GUICtrlSetState($og1, $GUI_DISABLE) GUICtrlSetState($og2, $GUI_DISABLE) GUICtrlSetState($og3, $GUI_DISABLE) GUICtrlSetState($og4, $GUI_DISABLE) GUICtrlSetState($og5, $GUI_DISABLE) GUICtrlSetState($og6, $GUI_DISABLE) GUICtrlSetState($place2, $GUI_ENABLE) GUICtrlSetState($place3, $GUI_ENABLE) Case $og3 = GUICtrlCreateButton("Obergeschoss 3", "50", "250") Case $og4 = GUICtrlCreateButton("Obergeschoss 4", "50", "350") Case $og5 = GUICtrlCreateButton("Obergeschoss 5", "50", "450") Case $og6 = GUICtrlCreateButton("Obergeschoss 6", "50", "550") EndSwitch WEnd Func main() Opt("GUIOnEventMode", 1) $SGui = GUICreate("Drucker", "200", "100") GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2") GUICtrlCreateButton("Einfach", "30", "50") GUICtrlSetOnEvent(-1, "Basic") GUICtrlCreateButton("Erweitert", "80", "50") GUICtrlSetOnEvent(-1, "Advanced") GUICtrlCreateButton("Löschen", "130", "50") GUICtrlSetOnEvent(-1, "Delete") GUISetState(@SW_SHOW, $SGui) If $SGui = "Advance" Then $Adv = 1 Else $Adv = 2 EndIf EndFunc Func main2() GUISetState(@SW_HIDE, $SGui) $Gui1 = GUICreate("Stockwerk", "701", "661") GUISetState(@SW_SHOW, $Gui1) $pic111 = GUICtrlCreatePic(@ScriptDir & "\System\pic1.bmp", "5", "5", "691", "631",$WS_CLIPSIBLINGS ) GUICtrlSetState(-1,$GUI_DISABLE) $place1 = GUICtrlCreateButton("place1", "150", "290") GUICtrlSetState($place1, $GUI_DISABLE) $place2 = GUICtrlCreateButton("place2", "384", "465") GUICtrlSetState($place2, $GUI_DISABLE) $place3 = GUICtrlCreateButton("place3", "220", "470") GUICtrlSetState($place3, $GUI_DISABLE) $og1 = GUICtrlCreateButton("Obergeschoss 1", "50", "50") $og2 = GUICtrlCreateButton("Obergeschoss 2", "50", "150") $Exit = GUICtrlCreateMenu("Beenden") GUICtrlCreateMenuitem("Exit", $Exit) GUICtrlSetOnEvent(-1, "ExitMenu") GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2") EndFunc Greets Vaeb I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
BrettF Posted November 15, 2007 Share Posted November 15, 2007 There is still the fact that you still have GUIOnEvent mode functions in your script. Remove them, and it should work. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Vaeb Posted November 15, 2007 Author Share Posted November 15, 2007 I decided to do it the other way. I didn't know that i have to change the whole script. When I click on the button "Obergeschoss 1", the Obergeschosse buttons doesn't disable, but they should. Isn't it possible to do it like this? If not, do you know a better solution? The relevant part of the script: expandcollapse popupOpt("GUICloseOnESC", 1) Opt("GUIOnEventMode", 1) $Gui1 = GUICreate("Stockwerk", "701", "661") $pic111 = GUICtrlCreatePic(@ScriptDir & "\System\pic2.bmp", "5", "5", "691", "631",$WS_CLIPSIBLINGS ) GUICtrlSetState(-1,$GUI_DISABLE) GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2") GUICtrlCreateButton("Obergeschoss 1", "50", "50") GUICtrlSetOnEvent(-1, "Og1") GUICtrlCreateButton("Obergeschoss 2", "50", "150") GUICtrlSetOnEvent(-1, "Og2") GUICtrlCreateButton("Obergeschoss 3", "50", "250") GUICtrlSetOnEvent(-1, "Og3") GUICtrlCreateButton("Obergeschoss 4", "50", "350") GUICtrlSetOnEvent(-1, "Og4") GUICtrlCreateButton("Obergeschoss 5", "50", "450") GUICtrlSetOnEvent(-1, "Og5") GUICtrlCreateButton("Obergeschoss 6", "50", "550") GUICtrlSetOnEvent(-1, "Og6") $Waisenhausstrasse = GUICtrlCreateButton("Place1", "220", "470") GUICtrlSetState($Place1, $GUI_DISABLE) $Bahnhofquai = GUICtrlCreateButton("Place2", "384", "465") GUICtrlSetState($Place2, $GUI_DISABLE) $Bahnhofplatz = GUICtrlCreateButton("Place3", "150", "290") GUICtrlSetState($Place3, $GUI_DISABLE) $Exit = GUICtrlCreateMenu("Beenden") GUICtrlCreateMenuitem("Exit", $Exit) GUICtrlSetOnEvent(-1, "ExitMenu") GUISetState(@SW_HIDE, $Gui1) Func Og1() $msgn = "ers" $n = "1" GUICtrlSetImage ($pic111, @ScriptDir & "\System\pic1.bmp") GUICtrlSetState($og1 And $og2 And $og3 And $og4 And $og5 And $og6, $GUI_DISABLE) GUICtrlSetState($Place1, $GUI_ENABLE) GUICtrlSetState($Place2, $GUI_ENABLE) EndFunc ;==>Og1 Greets Vaeb I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
dani Posted November 15, 2007 Share Posted November 15, 2007 (edited) Maybe a simple example will help you understand how to get Buttons to work #include <GUIConstants.au3> $GUI = GUICreate("Button Test", 100, 100) $ButtonEnable = GUICtrlCreateButton("Enable Button", 10, 10) $ButtonDisable = GUICtrlCreateButton("Disable Button", 10, 10) $Button = GUICtrlCreateButton("Button", 10, 50) GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($Button, $GUI_DISABLE) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $ButtonEnable GUICtrlSetState($Button, $GUI_ENABLE) GUICtrlSetState($ButtonDisable, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($ButtonEnable, $GUI_DISABLE + $GUI_HIDE) Case $ButtonDisable GUICtrlSetState($ButtonEnable, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($Button, $GUI_DISABLE) GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE) Case $Button MsgBox(0,"", "Button was pressed!") Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GuiDelete() Edited November 15, 2007 by D4ni Link to comment Share on other sites More sharing options...
Vaeb Posted November 15, 2007 Author Share Posted November 15, 2007 It will not work I think. Bert said: "It has to be either GUICtrlSetOnEvent, or GUIGetMsg" And I need GUICtrlSetOnEvent in my script. I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
dani Posted November 15, 2007 Share Posted November 15, 2007 (edited) It will not work I think. Bert said: "It has to be either GUICtrlSetOnEvent, or GUIGetMsg" And I need GUICtrlSetOnEvent in my script.It does work... I just use GUIGetMsg(). I don't use both, now do I? It works fine. Why do you want to use GUIOnEvent mode? ps. please first actually run stuff before you claim it doesn't work pps. I didn't have the intention to have you use this in your program, I just hoped I could explain how GUIGetMsg() mode works ~~ EDIT Please read some documentation first man. I never used onevent, but converted my script in 2 minutes. here you go expandcollapse popup#include <GUIConstants.au3> $I_Say_So = False; Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $GUI = GUICreate("Button Test", 100, 100) $ButtonEnable = GUICtrlCreateButton("Enable Button", 10, 10) $ButtonDisable = GUICtrlCreateButton("Disable Button", 10, 10) $Button = GUICtrlCreateButton("Button", 10, 50) GUICtrlSetOnEvent($ButtonEnable, "Enable") GUICtrlSetOnEvent($ButtonDisable, "Disable") GUICtrlSetOnEvent($Button, "Button") ;GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "Quit") GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($Button, $GUI_DISABLE) GUISetState() Do ; Nothing Until $I_Say_So Func Button() MsgBox(1,"", "Button pressed!") EndFunc Func Enable() GUICtrlSetState($Button, $GUI_ENABLE) GUICtrlSetState($ButtonDisable, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($ButtonEnable, $GUI_DISABLE + $GUI_HIDE) EndFunc Func Disable() GUICtrlSetState($ButtonEnable, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($Button, $GUI_DISABLE) GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE) EndFunc Func Quit() Exit EndFunc I commented out the function associated with the $GUI_EVENT_CLOSE cause it caused my script to exit even when the button was pressed :s Edited November 15, 2007 by D4ni Link to comment Share on other sites More sharing options...
Zedna Posted November 15, 2007 Share Posted November 15, 2007 Read the helpfile! There is section GUI Reference with all needed GUI base informations and examples. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Valuater Posted November 15, 2007 Share Posted November 15, 2007 Until $I_Say_So I Like that one!!! 8) Link to comment Share on other sites More sharing options...
Vaeb Posted November 23, 2007 Author Share Posted November 23, 2007 Thank you. I thought it's harder to convert everything. But it was very easy. It works very good. I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now