Vicate Posted June 8, 2009 Posted June 8, 2009 I have a script ready, and I'm trying to get a GUI working with it. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") #Region ### $Form1_1 = GUICreate("Title", 116, 212, 448, 181) GUISetFont(8, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Group1 = GUICtrlCreateGroup("Player", 8, 144, 97, 41) GUICtrlSetColor(-1, 0xC0C0C0) $On = GUICtrlCreateButton("On", 12, 160, 41, 17, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) $Off = GUICtrlCreateButton("Off", 55, 160, 41, 17, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUICtrlCreateGroup("", -99, -99, 1, 1) $noplaying = GUICtrlCreatePic("img.gif", 8, 8, 98, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Info = GUICtrlCreateButton("Info", 36, 186, 41, 17, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func _5() $5 = PixelGetColor(363, 40) Select Case $5 = 0x000000 send("{5 down}") Case $5 <> 0x000000 And _IsPressed("35", $dll) send("{5 up}") EndSelect EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Info ;When this is pressed, I want a window to pop up that I can put info Case $On ;When this is pressed, I want it to "activate" Func_5 ;And perhaps turn the button color to orange or something to indicate that it is on. ;If the Off Button was on, I'd want the Off Button to return to its original color. Case $Off ;When this is pressed, I want it to "deactivate" Func_5 ;And perhaps turn the button color to orange or something to indicate that it is off. ;If the On Button was on, I'd want the On Button to return to its original color. EndSwitch WEnd Under the Case $On, do I put a While... WEnd loop containing the function or what? And how would I go about changing the colors as mentioned in the code above? Thanks in advance.
CodyBarrett Posted June 8, 2009 Posted June 8, 2009 personaly i would use labels.. more customizable.. and coloring buttons causes the script to lagg.. and SERIOUS CPU consumption [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Vicate Posted June 8, 2009 Author Posted June 8, 2009 Alright thanks, I'll take your advice and make them labels. In fiddling around, I've managed to get the colors to change upon pressing, so that's all figured out. I still don't know how to get the function to activate on $On and deactivate on $Off. Modified, with labels: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") #Region ### START Koda GUI section ### Form=c:\documents and settings\owner\desktop\graal player\dev\giutest.kxf $Form1_1 = GUICreate("Title", 116, 212, 448, 181) GUISetFont(8, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Group1 = GUICtrlCreateGroup("Player", 8, 144, 97, 41) GUICtrlSetColor(-1, 0xC0C0C0) $On = GUICtrlCreateLabel(" On", 14, 160, 41, 17, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-2, 0x000000) $Off = GUICtrlCreateLabel(" Off", 57, 160, 41, 17, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUICtrlCreateGroup("", -99, -99, 1, 1) $noplaying = GUICtrlCreatePic("img.gif", 8, 8, 98, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Info = GUICtrlCreateLabel(" Info", 36, 186, 41, 17, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func _5() $5 = PixelGetColor(363, 40) Select Case $5 = 0x000000 send("{5 down}") Case $5 <> 0x000000 And _IsPressed("35", $dll) send("{5 up}") EndSelect EndFunc While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit EndIf If $nMsg = $Info Then ;When this is pressed, I want a window to pop up that I can put info EndIf If $nMsg = $On Then GUICtrlSetBkColor($On, 0x0066FF) GUICtrlSetBkColor($Off, 0x000000) While 2 _5() ;<--- Is this how to activate it? WEnd EndIf If $nMsg = $Off Then GUICtrlSetBkColor($On, 0x000000) GUICtrlSetBkColor($Off, 0x0066FF) EndIf WEnd
CodyBarrett Posted June 8, 2009 Posted June 8, 2009 make a variable at the start $status = '' then when you click ON have IF $status = 'OFF' then ;blah blah blah place your button script here $Status = 'ON' Endif and vise versa for OFF button [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Vicate Posted June 8, 2009 Author Posted June 8, 2009 Well I want it to loop continuously until $Off is pressed, so shouldn't I use a While...WEnd statement? Correct me if I'm wrong. So here's what I have, now. Why isn't this working? :[ expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") $status = '' #Region ### $Form1_1 = GUICreate("Title", 116, 212, 448, 181) GUISetFont(8, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Group1 = GUICtrlCreateGroup("Player", 8, 144, 97, 39) GUICtrlSetColor(-1, 0xC0C0C0) $On = GUICtrlCreateLabel(" On", 14, 160, 41, 15, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-2, 0x000000) $Off = GUICtrlCreateLabel(" Off", 57, 160, 41, 15, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUICtrlCreateGroup("", -99, -99, 1, 1) $noplaying = GUICtrlCreatePic("Data\img.gif", 8, 8, 98, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Info = GUICtrlCreateLabel(" Info", 36, 188, 41, 15, $WS_GROUP) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### Func _5() $5 = PixelGetColor(363, 40) Select Case $5 = 0x000000 send("{5 down}") Case $5 <> 0x000000 And _IsPressed("35", $dll) send("{5 up}") EndSelect EndFunc While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit EndIf If $nMsg = $On Then GUICtrlSetBkColor($On, 0x0066CC) GUICtrlSetBkColor($Off, 0x000000) $Status = 'ON' EndIf If $nMsg = $Off Then GUICtrlSetBkColor($On, 0x000000) GUICtrlSetBkColor($Off, 0x0066CC) $Status = 'OFF' EndIf If $nMsg = $Info Then MsgBox(0, "Info", "Text") EndIf WEnd While $Status = 'ON' _5() WEnd
CodyBarrett Posted June 9, 2009 Posted June 9, 2009 have in your while While 1 ;all your looped code + what im puting If $Status = 'ON' then ;Do what you want if its ON Elseif $Status = 'OFF' endif Wend is that what you mean? [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Vicate Posted June 9, 2009 Author Posted June 9, 2009 That's GREAT.Now I just have to find out how to get rid of the tray menu and I'm set!Thanks pal, I owe you one
DarkSprout Posted June 9, 2009 Posted June 9, 2009 (edited) Vicate said: That's GREAT. Now I just have to find out how to get rid of the tray menu and I'm set! Thanks pal, I owe you one ;// Place below the #includes Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon =|)arkSprout= Edited June 9, 2009 by DarkSprout =|)arkSprout=VBA | VBScript | C# Programmer [font="Verdana"]"Give a person a fish and you feed them for a day; teach a person to use the Internet and they won't bother you for weeks."[/font]
GEOSoft Posted June 9, 2009 Posted June 9, 2009 You an also use #NoTrayIcon George Reveal hidden contents 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!"
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