au3scr Posted October 16, 2008 Share Posted October 16, 2008 (edited) Why my GUI done close itself on esc and why it uses processor in so high amount? How i can fix it?here is my source expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 1) #Region ### START Koda GUI section ### Form= Global $FilesToArray = _FileListToArray(@ScriptDir&"\start", "*.lnk", 1) Global $Shortcuts[$FilesToArray[0] + 1] $x = 0 $y = 60 $gui1height = 0 $gui2height = 467 $gui1widh = 0 $gui2widh = 457 ;~ GUICreate("title",width,height,left,top) $Form2 = GUICreate("Form2transF32", 260, 447, 0, @DesktopHeight - 487,$WS_POPUP) WinSetTrans("Form2transF32","",160) GUISetState(@SW_show) $Form1 = GUICreate("Form1Sartmenuform32", 250, 457, 0, @DesktopHeight - 457 - 20,$WS_POPUP) For $i = 1 To $FilesToArray[0] $file = FileGetShortcut(@ScriptDir&"\start" & "\" & $FilesToArray[$i]) $Shortcuts[$i] = GUICtrlCreateButton($FilesToArray[$i], 20, $y, 36, 36, BitOR($BS_PUSHBOX, $BS_FLAT, $BS_ICON)) GUICtrlSetOnEvent(-1,"clicked") $imgpath = $file[0] If StringRight($imgpath, 4) = ".exe" Then GUICtrlSetImage(-1, $imgpath, 0) $label = GUICtrlCreateLabel ($FilesToArray[$i],60,$y,200,36) GUICtrlSetOnEvent(-1,"clicked") GUICtrlSetFont(-1,10,"Palatino Linotype") $y = $y + 36 Next ;~ $Pic1 = GUICtrlCreatePic(@scriptdir&"\pictures"&"\New Bitmap Image24.bmp", 0, 0, 20, 447, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) ;~ $Pic2 = GUICtrlCreatePic(@scriptdir&"\pictures"&"\logo2.bmp", 180, 5, 50, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlCreateLabel("Logged in as: "&@UserName,25,2) GUICtrlCreateLabel("Current Date: "&@WDAY&":"&@MON&":"&@YEAR,25,5+9) GUICtrlCreateLabel("Current Time: "&@HOUR&":"&@MIN,25,5+15+5) GUICtrlCreateLabel("Current IP: "&@IPAddress1,25,5+15+17) $halt = GUICtrlCreateButton ("",25,$gui2height - 51,36,36,BitOR($BS_PUSHBOX, $BS_FLAT, $BS_ICON)) ;~ GUICtrlSetImage(-1, @ScriptDir & "\icons\halt.ico", 0) GUICtrlCreateLabel("Halt",25 + 36 + 5,$gui2height - 41) WinSetOnTop("Form1Sartmenuform32","",1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func clicked() $lnk = FileGetShortcut(@ScriptDir&"\start"&"\"&GUICtrlRead(@GUI_CtrlId)) ShellExecute($lnk[0],$lnk[2],$lnk[1]) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndhere you ban see my GUI and what taskmanager shows about it Edited October 16, 2008 by au3scr Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 (edited) Turn OnEventMode off. Esc works and the CPU drops to 0 for me. I don't see why you need OnEvenMode and GUIGetMsg() at the same time, use one or the other.Edit: you also don't need to declare the GUICloseOnEsc option, it behaves that way by default.CODE#include <ButtonConstants.au3>#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <GUIConstantsEx.au3>#include <StaticConstants.au3>#include <WindowsConstants.au3>#include <File.au3>#include <GDIPlus.au3>#Region ### START Koda GUI section ### Form=Global $FilesToArray = _FileListToArray(@ScriptDir&"\start", "*.lnk", 1)Global $Shortcuts[$FilesToArray[0] + 1]$x = 0$y = 60$gui1height = 0$gui2height = 467$gui1widh = 0$gui2widh = 457;~ GUICreate("title",width,height,left,top)$Form2 = GUICreate("Form2transF32", 260, 447, 0, @DesktopHeight - 487,$WS_POPUP)WinSetTrans("Form2transF32","",160)GUISetState(@SW_show)$Form1 = GUICreate("Form1Sartmenuform32", 250, 457, 0, @DesktopHeight - 457 - 20,$WS_POPUP)For $i = 1 To $FilesToArray[0] $file = FileGetShortcut(@ScriptDir&"\start" & "\" & $FilesToArray[$i]) $Shortcuts[$i] = GUICtrlCreateButton($FilesToArray[$i], 20, $y, 36, 36, BitOR($BS_PUSHBOX, $BS_FLAT, $BS_ICON)) GUICtrlSetOnEvent(-1,"clicked") $imgpath = $file[0] If StringRight($imgpath, 4) = ".exe" Then GUICtrlSetImage(-1, $imgpath, 0) $label = GUICtrlCreateLabel ($FilesToArray[$i],60,$y,200,36) GUICtrlSetOnEvent(-1,"clicked") GUICtrlSetFont(-1,10,"Palatino Linotype") $y = $y + 36Next;~ $Pic1 = GUICtrlCreatePic(@scriptdir&"\pictures"&"\New Bitmap Image24.bmp", 0, 0, 20, 447, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS));~ $Pic2 = GUICtrlCreatePic(@scriptdir&"\pictures"&"\logo2.bmp", 180, 5, 50, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlCreateLabel("Logged in as: "&@UserName,25,2) GUICtrlCreateLabel("Current Date: "&@WDAY&":"&@MON&":"&@YEAR,25,5+9) GUICtrlCreateLabel("Current Time: "&@HOUR&":"&@MIN,25,5+15+5) GUICtrlCreateLabel("Current IP: "&@IPAddress1,25,5+15+17) $halt = GUICtrlCreateButton ("",25,$gui2height - 51,36,36,BitOR($BS_PUSHBOX, $BS_FLAT, $BS_ICON));~ GUICtrlSetImage(-1, @ScriptDir & "\icons\halt.ico", 0) GUICtrlCreateLabel("Halt",25 + 36 + 5,$gui2height - 41) WinSetOnTop("Form1Sartmenuform32","",1)GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###Func clicked()$lnk = FileGetShortcut(@ScriptDir&"\start"&"\"&GUICtrlRead(@GUI_CtrlId))ShellExecute($lnk[0],$lnk[2],$lnk[1])EndFuncWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitchWEnd Edited October 16, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
au3scr Posted October 16, 2008 Author Share Posted October 16, 2008 how i click on buttons without OnEventMode? buttons are made dynamically Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 Well you could always just check the array position, I did that myself once (I forget how though) but if you must use OnEventMode remove everything you have in the While loop and just add Sleep(250) and things should go down. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
au3scr Posted October 16, 2008 Author Share Posted October 16, 2008 ok now i have While 1 sleep(250) WEnd processor usage is no problem, but esc still dont work. "Well you could always just check the array position" if we talk about arrays then i say 1 thing, i am stupid with array :S Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 Don't feel bad, I'm still using 1D arrays . Just use _IsPressed("1B") to close your script on esc (put in While 1). Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
au3scr Posted October 16, 2008 Author Share Posted October 16, 2008 (edited) _ispressed dont want to help me :S something made script ignore esc Can you or some one show me how to get button actions from array. (i mean makle windows work with out on event mode) Edited October 16, 2008 by au3scr Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 16, 2008 Share Posted October 16, 2008 Worked perfectly for me when I modded your script. You did remove the option for GUICloseOnEsc right? If you did then your code should be something likeWhile 1 If _IsPressed("1B") Then Exit EndIf Sleep(250) WEnd and don't forget to #include <Misc.au3> Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
enaiman Posted October 16, 2008 Share Posted October 16, 2008 You have mixed and messed your code from the begining - you tried a combination which can't work. For the future - try to stick with a form. I've comented your code about links and such in order to test it - here is the working result wich closes on Esc without any _IsPressed or other fancy things. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 1) #Region ### START Koda GUI section ### Form= ;Global $FilesToArray = _FileListToArray(@ScriptDir&"\start", "*.lnk", 1) ;Global $Shortcuts[$FilesToArray[0] + 1] $x = 0 $y = 60 $gui1height = 0 $gui2height = 467 $gui1widh = 0 $gui2widh = 457 ;~ GUICreate("title",width,height,left,top) $Form2 = GUICreate("Form2transF32", 260, 447, 0, @DesktopHeight - 487,$WS_POPUP) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") ;you forgot to add this line which is vital OnEvent WinSetTrans("Form2transF32","",160) GUISetState(@SW_show) $Form1 = GUICreate("Form1Sartmenuform32", 250, 457, 0, @DesktopHeight - 457 - 20,$WS_POPUP) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") ;you forgot to add this line which is vital OnEvent #cs For $i = 1 To $FilesToArray[0] $file = FileGetShortcut(@ScriptDir&"\start" & "\" & $FilesToArray[$i]) $Shortcuts[$i] = GUICtrlCreateButton($FilesToArray[$i], 20, $y, 36, 36, BitOR($BS_PUSHBOX, $BS_FLAT, $BS_ICON)) GUICtrlSetOnEvent(-1,"clicked") $imgpath = $file[0] If StringRight($imgpath, 4) = ".exe" Then GUICtrlSetImage(-1, $imgpath, 0) $label = GUICtrlCreateLabel ($FilesToArray[$i],60,$y,200,36) GUICtrlSetOnEvent(-1,"clicked") GUICtrlSetFont(-1,10,"Palatino Linotype") $y = $y + 36 Next #ce ;~ $Pic1 = GUICtrlCreatePic(@scriptdir&"\pictures"&"\New Bitmap Image24.bmp", 0, 0, 20, 447, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) ;~ $Pic2 = GUICtrlCreatePic(@scriptdir&"\pictures"&"\logo2.bmp", 180, 5, 50, 50, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlCreateLabel("Logged in as: "&@UserName,25,2) GUICtrlCreateLabel("Current Date: "&@WDAY&":"&@MON&":"&@YEAR,25,5+9) GUICtrlCreateLabel("Current Time: "&@HOUR&":"&@MIN,25,5+15+5) GUICtrlCreateLabel("Current IP: "&@IPAddress1,25,5+15+17) $halt = GUICtrlCreateButton ("",25,$gui2height - 51,36,36,BitOR($BS_PUSHBOX, $BS_FLAT, $BS_ICON)) ;~ GUICtrlSetImage(-1, @ScriptDir & "\icons\halt.ico", 0) GUICtrlCreateLabel("Halt",25 + 36 + 5,$gui2height - 41) WinSetOnTop("Form1Sartmenuform32","",1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(200) WEnd Func clicked() $lnk = FileGetShortcut(@ScriptDir&"\start"&"\"&GUICtrlRead(@GUI_CtrlId)) ShellExecute($lnk[0],$lnk[2],$lnk[1]) EndFunc Func Close() ;added this function which handles the Close event Exit EndFunc SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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