Jump to content

GUI Freezed


n1maS
 Share

Recommended Posts

Hi all

I'm kinda new to AutoIt. I made a simple scipt for myself to Unname a file!

very simple.

but the problem is when I show and Close "ABOUT" from the menu, the main GUI freezes and you have to close it from Task Manager

like I said I'm newbie to AutoIt. so any help would be greatly appreciated:)

Here's my code:

#NoTrayIcon
#Region
#AutoIt3Wrapper_icon=n1ma.ico
#AutoIt3Wrapper_Res_Description=Unname A File
#AutoIt3Wrapper_Res_Fileversion=1.5.0.0
#AutoIt3Wrapper_Res_LegalCopyright=n1ma 2012
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
#include <file.au3>
#include <array.au3>
#include <ButtonConstants.au3>
Global $tSHFCS, $tIcon, $aIcon[2], $sPath, $aParts[2] = [288, -1],$szDrive, $szDir, $szFName, $szExt

$CheckforRunningWindow = WinExists ("Created By n1maSSTO")
If $CheckforRunningWindow = 1 Then
WinActivate ("Created By n1maSSTO")
Else
Main()
EndIf

Func Main()
$Form1 = GUICreate("Created By n1maSSTO", 288, 270)
GUISetBkColor(0xFFFFFF)
$MainMenu = GUICtrlCreateMenu("&Main Menu")
$Exit = GUICtrlCreateMenuItem("E&xit", $MainMenu)
$HelpMenu = GUICtrlCreateMenu("&Help")
$About = GUICtrlCreateMenuItem("&About", $HelpMenu)
$Label1 = GUICtrlCreateLabel("Unname A File", 76, 12, 155, 23)
GUICtrlSetFont(-1, 13, 800, 0, "Segoe UI Symbol")
$Label2 = GUICtrlCreateLabel("n1ma ©2012" ,182,208, 145, 17)
GUICtrlSetFont(-1, 11, 400, 0, "Segoe Script")
$LabelFile = GUICtrlCreateLabel("File", 8, 55, 56, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Leelawadee")
$FileInput = GUICtrlCreateInput("", 8, 75, 225, 21, $ES_READONLY, $WS_EX_CLIENTEDGE)
$InFileButton = GUICtrlCreateButton(". . .", 240, 72, 30, 25)
$ProcessButton = GUICtrlCreateButton("Process", 35, 160, 100, 30)
GUICtrlSetFont(-1, 10, 800, 0, "Leelawadee")
$Close = GUICtrlCreateButton("Close", 155, 160, 100, 30)
GUICtrlSetFont(-1, 10, 800, 0, "Leelawadee")
$StatusBar = _GUICtrlStatusBar_Create($Form1, $aParts)
_GUICtrlStatusBar_SetText($StatusBar, "Select a File")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Close
GUIDelete()
ExitLoop
Case $Exit
GUIDelete()
ExitLoop
Case $About
About()
Case $InFileButton
$IPath = FileOpenDialog("Choose A File", @WindowsDir & "", "All Files (*.*)", 1)
If $IPath <> "" Then GUICtrlSetData($FileInput, $IPath)
Case $ProcessButton
     Global $IPath
             $FilePath = _PathSplit($IPath, $szDrive, $szDir, $szFName, $szExt)
Select
Case $IPath == ""
     _GUICtrlStatusBar_SetText($StatusBar, "Please Choose a File")
Case $FilePath[3] == ""
     _GUICtrlStatusBar_SetText($StatusBar, "File is Already Unnamed")
Case $FilePath[4] == ""
     _GUICtrlStatusBar_SetText($StatusBar, "File Doesn't Have an Extension")
Case FileExists($FilePath[1] & $FilePath[2] & $FilePath[4]) = 1
     _GUICtrlStatusBar_SetText($StatusBar, "An Unnamed File Exists in The Same Directory")
Case Else
     FileMove($IPath,$FilePath[1] & $FilePath[2] & $FilePath[4])
     _GUICtrlStatusBar_SetText($StatusBar, "File Was Unnamed Successfuly")
     $IPath = ""
     GUICtrlSetData($FileInput,"")
EndSelect
EndSwitch
WEnd
EndFunc

Func About()
$AGUI = GUICreate("About Developer", 302, 165)
GUISetBkColor(0xFFFFFF)
$Label2 = GUICtrlCreateLabel("n1ma File Unnamer!", 75, 8, 195, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Leelawadee")
$Label3 = GUICtrlCreateLabel("n1maSSTO ©2012", 212, 144, 145, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
$Label1 = GUICtrlCreateLabel("Version 1.5", 121, 32, 69, 19)
GUICtrlSetFont(-1, 10, 400, 0, "Leelawadee")
$Label4 = GUICtrlCreateLabel("My Profile on P30ask.com", 76, 56, 179, 19)
GUICtrlSetFont(-1, 10, 400, 0, "Leelawadee")
$Label5 = GUICtrlCreateLabel("(Click here to visit)", 131, 72, 92, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
$Label6 = GUICtrlCreateLabel("Special thanks to AutoIt help file!!", 54, 106, 203, 18)
GUICtrlSetFont(-1, 10, 400, 0, "Leelawadee")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
     Case $GUI_EVENT_CLOSE
GUIDelete($AGUI)
WinActivate ("Created By n1maSSTO")
Case $Label4
ShellExecute("http://forum.p30ask.com/members/n1ma-128301/")
Case $Label5
ShellExecute("http://forum.p30ask.com/members/n1ma-128301/")
EndSwitch
WEnd
EndFunc
Link to comment
Share on other sites

  • Moderators

n1maS,

You need to escape from the loop where you look for the second GUI to be closed: :huh:

Switch $nMsg
    Case $GUI_EVENT_CLOSE
        GUIDelete($AGUI)
        WinActivate("Created By n1maSSTO")
        ExitLoop : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Other wise you stay in that loop forever and your main GUI idle loop is never re-entered. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

is there something better than help file?

We think the Help file is pretty good! :D

But you can find a couple of excellent tutorials here and here. There are also some more advanced tutorials in the Wiki (the link is at the top of the page). :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...