Jump to content
Sign in to follow this  
Floydtrey

Gui Keeps Freezing. Beginner script.

Recommended Posts

Floydtrey

Hi, I'm trying to learn to write to an INI file... Next i'll be working on a Read file but for the moment I'll start with this. I've been staying away from buttons on gui's because I always seem to get this problem... I have many different methods of ending a script... but for some reason if I start one from a button it always freezes up. The only way to stop it that i've found is to close the script through auto it and this just wont do. I've added the script below please take a look and see if there are any pointers you can give me. PS. I know it's messy i'm trying to figure out how to clean it up.

EDIT: I can minimize the program, and I can see the sub menu's of my menu bar... Just can't call any controls. ( Outside of Minimize )

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: Kal

Script Function:Record and activate MouseClicks.
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
;MR MOD, lol had to edit twice... to add the Includes in right... it kept dopping off the files... leaving #include (NOTHING).
#include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Emy\Desktop\Filesharer121 Website Files\Form1.kxf

HotKeySet("{F1}","Help")
HotKeySet("!C","Start")
HotKeySet("{ESC}","Exit")    ; <<<<<<<<<<< Hmm reading this in reg black and white... I didn't change this back to Form1Close().... lemme see if that will help.

                                         ; <<<<<<<<<<<<<<<I'm sure it won't fix it but it's something I can fix for the moment.

Opt("GUIOnEventMode", 1)                 ; <<<<< I changed the whole code around after a while and went to this. Originally I used Switch. ( I like Switch Better ) lol
#Region ### START Koda GUI section ###
Local $Form1 = GUICreate("INI Maker", 469, 149, 192, 120)
Local $File = GUICtrlCreateMenu("&File")
Local $New = GUICtrlCreateMenuItem("New", $File)
GUICtrlSetOnEvent(-1, "New")
Local $Open = GUICtrlCreateMenuItem("Open", $File)
GUICtrlSetOnEvent(-1, "Open")
Local $Save = GUICtrlCreateMenuItem("Save", $File)
GUICtrlSetOnEvent(-1, "Save")
Local $Exit = GUICtrlCreateMenuItem("Exit", $File)
GUICtrlSetOnEvent(-1, "Form1Close")
Local $Pre_Loaded = GUICtrlCreateMenu("&Pre-Loaded")
Local $Help = GUICtrlCreateMenu("&Help")
Local $Help1 = GUICtrlCreateMenuItem("Help", $Help)
GUICtrlSetOnEvent(-1, "Help")
Local $About = GUICtrlCreateMenuItem("About", $Help)
GUICtrlSetOnEvent(-1, "About")
GUISetBkColor(0x808080)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
Local $Save_As = GUICtrlCreateInput("", 168, 16, 113, 21)
GUICtrlSetOnEvent(-1, "Save_As")
Local $Label1 = GUICtrlCreateLabel("Enter file name here.", 8, 16, 151, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
Local $Label2 = GUICtrlCreateLabel(".INI", 288, 16, 33, 26)
GUICtrlSetFont(-1, 14, 800, 4, "Myriad Web Pro")
Local $Rounds = GUICtrlCreateInput("", 112, 56, 113, 21)
Local $Label3 = GUICtrlCreateLabel("Rounds", 24, 56, 61, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $L_or_R = GUICtrlCreateCombo("Left", 112, 88, 113, 25, BitOR($CBS_DROPDOWNLIST,$CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Right")
Local $Label4 = GUICtrlCreateLabel("Mouse Click", 6, 88, 97, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $Start = GUICtrlCreateButton("Start", 248, 80, 89, 33)
GUICtrlSetOnEvent(-1, "Start")
Local $End = GUICtrlCreateButton("End", 360, 80, 89, 33)
GUICtrlSetOnEvent(-1, "End")
Local $Pic1 = GUICtrlCreatePic("C:\Users\Emy\Desktop\KAL.jpg", 320, 0, 145, 81)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###




Func Form1Close()
GUIDelete()
Exit
EndFunc


; Start Functions here.
Func Reset()
EndFunc
Func Start()
MsgBox(0,"","")
$X = "0"
$Y = "0"
$Z = "0"
$Stop = 0
Local $hDLL = DllOpen("user32.dll")
Local $_Save_As = GUICtrlRead($Save_As)
Local $Round = GUICtrlRead($Rounds)
Local $Mouse_Get_Pos_X = MouseGetPos(0)
Local $Mouse_Get_Pos_Y = MouseGetPos(1)
Local $L_R = Guictrlread($L_OR_R)
$Time = 0                                            ; <<<<<<<<<<<< Used for Troubleshooting
While $Stop = 0
If _IsPressed("43", $hDLL) Then                                                                      ;This script was taken from autoIT help file and modified to include my code.
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Z" & $Z,$L_R)
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Rounds",$Round) ; Writes how many rounds the user put in.
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","X" & $X,$Mouse_Get_Pos_X)
INIWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Y" & $Y,$Mouse_Get_Pos_Y)
$X = $X + "X" + 1 ;I forgot to remove the + "X" and Y and Z here, I'll do that when i get back on. But it didn't crash before I added half the world in code lol.
$Y = $Y + "Y" + 1
$Z = $Z + "Z" + 1
$Time += 1           ;<<<< Used for troubleshooting.
ConsoleWrite("_ISPRESSED - C pressed." & @CRLF & $time)      ;<<<<<<<Used for troubleshooting
Sleep(150)
; Wait until key is released.
While _IsPressed("43", $hDLL)
Sleep(250)
WEnd
ConsoleWrite("_IsPressed - C Key was released." & @CRLF)             :<<<<<<<<<<<< Used for troubleshooting
ElseIf _IsPressed("1B", $hDLL) or $End = 1 Then
$Stop = 1
EndIf

Sleep(250)
WEnd
DllClose($hDLL)
EndFunc


Func End() ; <<<<<<<<<<<< Added this to try to break the script and cause it to sleep... This should pull it outta the function... but doesn't.
While 1
Sleep(1000)
WEnd
EndFunc
Func Help()
EndFunc
Func About()
EndFunc
Func Save()
EndFunc

While 1
Sleep(250)
WEnd
Edited by Floydtrey

Share this post


Link to post
Share on other sites
kylomas

Floydtrey,

IniWrite(@ScriptDir & "/" & $_Save_As & ".ini", "Config", "Rounds", $Round) ; Writes how many rounds the user put in.

On the off chance that this is NOT a management system for an ordnance munitions locker, did you read the forum rules?

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Floydtrey

The program I am trying to make is something similar to the WINZIP Tutorial. I want to be able to perform mouseclicks and the program record the Mousegetpos() to an .ini file. Then call it back later to install the files. This program won't be limited to a single file. and will require very little work to install multiple files. I know there are programs out there for this already. But it is a learning experience. I needed a goal to create a program and this is what I chose. It has nothing to do with munitions in any way. The variable "Round" and the comment

Writes how many rounds the user put in.

Is referencing the "Cycles" that will be completed. The user will put X Rounds into the input box. and the program will perform the loop X times. 99% of the time this program would only have 1 round or cycle. But if I later decide to install many files on many computers, I could simply add a script onto this one to pull computer names out from another part of the .ini file so that I can install the files over the local network.

Again, I have no use for this program as of yet, but I intend to learn a good deal about programming from something as complex as this. ( It's complex to me lol )

With that being said, I do not believe I have violated any of the forum rules. Again Rounds = Cycles. I guess that I chose the wrong term for the variable lol.

Share this post


Link to post
Share on other sites
kylomas

I guess that I chose the wrong term for the variable lol.

I may have reacted in too cynical / critical a fashion. For that, I apologize. If I gt some time later and no one has responded I'll take a look...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
AutoBert

Your GUI could not freezing because the script never starts:

>"D:\Programme\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Programme\AutoIt3\Test\test.au3" /autoit3dir "D:\Programme\AutoIt3" /UserParams   
+>14:49:00 Starting AutoIt3Wrapper v.2.0.0.1    Environment(Language:0407  Keyboard:00000407  OS:WIN_XP/Service Pack 3  CPU:X86 OS:X86)
>Running AU3Check (1.54.19.0)  from:D:\Programme\AutoIt3
D:\Programme\AutoIt3\Test\test.au3(116,61) : ERROR: syntax error (illegal character)
            ConsoleWrite("_IsPressed - C Key was released." & @CRLF) :
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(117,3) : ERROR: missing Wend.
        ElseIf
        ^
D:\Programme\AutoIt3\Test\test.au3(101,112) : REF: missing Wend.
        If _IsPressed("43", $hDLL) Then ;This script was taken from autoIT help file and modified to include my code.
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(22,25) : ERROR: Help(): undefined function.
HotKeySet("{F1}", "Help")
~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(24,26) : ERROR: Exit(): undefined function.
HotKeySet("{ESC}", "Exit")
~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(33,28) : ERROR: New(): undefined function.
GUICtrlSetOnEvent(-1, "New")
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(35,29) : ERROR: Open(): undefined function.
GUICtrlSetOnEvent(-1, "Open")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(37,29) : ERROR: Save(): undefined function.
GUICtrlSetOnEvent(-1, "Save")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(45,30) : ERROR: About(): undefined function.
GUICtrlSetOnEvent(-1, "About")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(48,51) : ERROR: Form1Minimize(): undefined function.
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(49,51) : ERROR: Form1Maximize(): undefined function.
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(50,49) : ERROR: Form1Restore(): undefined function.
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(52,32) : ERROR: Save_As(): undefined function.
GUICtrlSetOnEvent(-1, "Save_As")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3(70,28) : ERROR: End(): undefined function.
GUICtrlSetOnEvent(-1, "End")
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Programme\AutoIt3\Test\test.au3 - 13 error(s), 0 warning(s)
!>14:49:00 AU3Check ended.rc:2
+>14:49:03 AutoIt3Wrapper Finished
>Exit code: 0    Time: 3.808

Share this post


Link to post
Share on other sites
careca

Was Full of errors, now it works, but some stuff is commented, other stuff has empty functions.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: Kal

Script Function:Record and activate MouseClicks.
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
;MR MOD, lol had to edit twice... to add the Includes in right... it kept dopping off the files... leaving #include (NOTHING).
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Emy\Desktop\Filesharer121 Website Files\Form1.kxf

HotKeySet("{F1}","Help")
HotKeySet("!C","Start")
HotKeySet("{ESC}","Close") ; <<<<<<<<<<< Hmm reading this in reg black and white... I didn't change this back to Form1Close().... lemme see if that will help.

                                         ; <<<<<<<<<<<<<<<I'm sure it won't fix it but it's something I can fix for the moment.

Opt("GUIOnEventMode", 1)                 ; <<<<< I changed the whole code around after a while and went to this. Originally I used Switch. ( I like Switch Better ) lol
#Region ### START Koda GUI section ###
Local $Form1 = GUICreate("INI Maker", 469, 149, 192, 120)
Local $File = GUICtrlCreateMenu("&File")
Local $New = GUICtrlCreateMenuItem("New", $File)
GUICtrlSetOnEvent(-1, "New")
Local $Open = GUICtrlCreateMenuItem("Open", $File)
GUICtrlSetOnEvent(-1, "Open")
Local $Save = GUICtrlCreateMenuItem("Save", $File)
GUICtrlSetOnEvent(-1, "Save")
Local $Exit = GUICtrlCreateMenuItem("Exit", $File)
GUICtrlSetOnEvent(-1, "Form1Close")
Local $Pre_Loaded = GUICtrlCreateMenu("&Pre-Loaded")
Local $Help = GUICtrlCreateMenu("&Help")
Local $Help1 = GUICtrlCreateMenuItem("Help", $Help)
GUICtrlSetOnEvent(-1, "Help")
Local $About = GUICtrlCreateMenuItem("About", $Help)
GUICtrlSetOnEvent(-1, "About")
GUISetBkColor(0x808080)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
;GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
;GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
;GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
Local $Save_As = GUICtrlCreateInput("", 168, 16, 113, 21)
GUICtrlSetOnEvent(-1, "Save_As")
Local $Label1 = GUICtrlCreateLabel("Enter file name here.", 8, 16, 151, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
Local $Label2 = GUICtrlCreateLabel(".INI", 288, 16, 33, 26)
GUICtrlSetFont(-1, 14, 800, 4, "Myriad Web Pro")
Local $Rounds = GUICtrlCreateInput("", 112, 56, 113, 21)
Local $Label3 = GUICtrlCreateLabel("Rounds", 24, 56, 61, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $L_or_R = GUICtrlCreateCombo("Left", 112, 88, 113, 25, BitOR($CBS_DROPDOWNLIST,$CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Right")
Local $Label4 = GUICtrlCreateLabel("Mouse Click", 6, 88, 97, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $Start = GUICtrlCreateButton("Start", 248, 80, 89, 33)
GUICtrlSetOnEvent(-1, "Start")
Local $End = GUICtrlCreateButton("End", 360, 80, 89, 33)
GUICtrlSetOnEvent(-1, "End")
Local $Pic1 = GUICtrlCreatePic("C:\Users\Emy\Desktop\KAL.jpg", 320, 0, 145, 81)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###




Func Form1Close()
GUIDelete()
Exit
EndFunc


; Start Functions here.
Func Reset()
EndFunc

Func Start()
MsgBox(0,"","")
$X = "0"
$Y = "0"
$Z = "0"
$Stop = 0
Local $hDLL = DllOpen("user32.dll")
Local $_Save_As = GUICtrlRead($Save_As)
Local $Round = GUICtrlRead($Rounds)
Local $Mouse_Get_Pos_X = MouseGetPos(0)
Local $Mouse_Get_Pos_Y = MouseGetPos(1)
Local $L_R = Guictrlread($L_OR_R)
$Time = 0                                        ; <<<<<<<<<<<< Used for Troubleshooting
While $Stop = 0
If _IsPressed("43", $hDLL) Then                                                                  ;This script was taken from autoIT help file and modified to include my code.
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Z" & $Z,$L_R)
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Rounds",$Round) ; Writes how many rounds the user put in.
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","X" & $X,$Mouse_Get_Pos_X)
INIWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Y" & $Y,$Mouse_Get_Pos_Y)
$X = $X + "X" + 1 ;I forgot to remove the + "X" and Y and Z here, I'll do that when i get back on. But it didn't crash before I added half the world in code lol.
$Y = $Y + "Y" + 1
$Z = $Z + "Z" + 1
$Time += 1       ;<<<< Used for troubleshooting.
ConsoleWrite("_ISPRESSED - C pressed." & @CRLF & $time)  ;<<<<<<<Used for troubleshooting
Sleep(150)
; Wait until key is released.
While _IsPressed("43", $hDLL)
Sleep(250)
WEnd
ConsoleWrite("_IsPressed - C Key was released." & @CRLF)             ;<<<<<<<<<<<< Used for troubleshooting
ElseIf _IsPressed("1B", $hDLL) or $End = 1 Then
$Stop = 1
EndIf
Sleep(250)
WEnd
DllClose($hDLL)
EndFunc


Func End() ; <<<<<<<<<<<< Added this to try to break the script and cause it to sleep... This should pull it outta the function... but doesn't.
While 1
Sleep(1000)
WEnd
EndFunc
Func New()
EndFunc
Func Open()
EndFunc
Func Help()
EndFunc
Func About()
EndFunc
Func Save()
EndFunc
Func Save_As()
EndFunc
Func Close()
Exit
EndFunc

While 1
Sleep(250)
WEnd

EDIT: Didn't mean it works, just meant it now opens and shows the GUI.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
Floydtrey

Was Full of errors, now it works, but some stuff is commented, other stuff has empty functions.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: Kal

Script Function:Record and activate MouseClicks.
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
;MR MOD, lol had to edit twice... to add the Includes in right... it kept dopping off the files... leaving #include (NOTHING).
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Emy\Desktop\Filesharer121 Website Files\Form1.kxf

HotKeySet("{F1}","Help")
HotKeySet("!C","Start")
HotKeySet("{ESC}","Close") ; <<<<<<<<<<< Hmm reading this in reg black and white... I didn't change this back to Form1Close().... lemme see if that will help.

                                         ; <<<<<<<<<<<<<<<I'm sure it won't fix it but it's something I can fix for the moment.

Opt("GUIOnEventMode", 1)                 ; <<<<< I changed the whole code around after a while and went to this. Originally I used Switch. ( I like Switch Better ) lol
#Region ### START Koda GUI section ###
Local $Form1 = GUICreate("INI Maker", 469, 149, 192, 120)
Local $File = GUICtrlCreateMenu("&File")
Local $New = GUICtrlCreateMenuItem("New", $File)
GUICtrlSetOnEvent(-1, "New")
Local $Open = GUICtrlCreateMenuItem("Open", $File)
GUICtrlSetOnEvent(-1, "Open")
Local $Save = GUICtrlCreateMenuItem("Save", $File)
GUICtrlSetOnEvent(-1, "Save")
Local $Exit = GUICtrlCreateMenuItem("Exit", $File)
GUICtrlSetOnEvent(-1, "Form1Close")
Local $Pre_Loaded = GUICtrlCreateMenu("&Pre-Loaded")
Local $Help = GUICtrlCreateMenu("&Help")
Local $Help1 = GUICtrlCreateMenuItem("Help", $Help)
GUICtrlSetOnEvent(-1, "Help")
Local $About = GUICtrlCreateMenuItem("About", $Help)
GUICtrlSetOnEvent(-1, "About")
GUISetBkColor(0x808080)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
;GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
;GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
;GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
Local $Save_As = GUICtrlCreateInput("", 168, 16, 113, 21)
GUICtrlSetOnEvent(-1, "Save_As")
Local $Label1 = GUICtrlCreateLabel("Enter file name here.", 8, 16, 151, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
Local $Label2 = GUICtrlCreateLabel(".INI", 288, 16, 33, 26)
GUICtrlSetFont(-1, 14, 800, 4, "Myriad Web Pro")
Local $Rounds = GUICtrlCreateInput("", 112, 56, 113, 21)
Local $Label3 = GUICtrlCreateLabel("Rounds", 24, 56, 61, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $L_or_R = GUICtrlCreateCombo("Left", 112, 88, 113, 25, BitOR($CBS_DROPDOWNLIST,$CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Right")
Local $Label4 = GUICtrlCreateLabel("Mouse Click", 6, 88, 97, 26)
GUICtrlSetFont(-1, 12, 800, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $Start = GUICtrlCreateButton("Start", 248, 80, 89, 33)
GUICtrlSetOnEvent(-1, "Start")
Local $End = GUICtrlCreateButton("End", 360, 80, 89, 33)
GUICtrlSetOnEvent(-1, "End")
Local $Pic1 = GUICtrlCreatePic("C:\Users\Emy\Desktop\KAL.jpg", 320, 0, 145, 81)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###




Func Form1Close()
GUIDelete()
Exit
EndFunc


; Start Functions here.
Func Reset()
EndFunc

Func Start()
MsgBox(0,"","")
$X = "0"
$Y = "0"
$Z = "0"
$Stop = 0
Local $hDLL = DllOpen("user32.dll")
Local $_Save_As = GUICtrlRead($Save_As)
Local $Round = GUICtrlRead($Rounds)
Local $Mouse_Get_Pos_X = MouseGetPos(0)
Local $Mouse_Get_Pos_Y = MouseGetPos(1)
Local $L_R = Guictrlread($L_OR_R)
$Time = 0                                        ; <<<<<<<<<<<< Used for Troubleshooting
While $Stop = 0
If _IsPressed("43", $hDLL) Then                                                                  ;This script was taken from autoIT help file and modified to include my code.
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Z" & $Z,$L_R)
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Rounds",$Round) ; Writes how many rounds the user put in.
IniWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","X" & $X,$Mouse_Get_Pos_X)
INIWrite(@ScriptDir & "/" & $_Save_As & ".ini","Config","Y" & $Y,$Mouse_Get_Pos_Y)
$X = $X + "X" + 1 ;I forgot to remove the + "X" and Y and Z here, I'll do that when i get back on. But it didn't crash before I added half the world in code lol.
$Y = $Y + "Y" + 1
$Z = $Z + "Z" + 1
$Time += 1       ;<<<< Used for troubleshooting.
ConsoleWrite("_ISPRESSED - C pressed." & @CRLF & $time)  ;<<<<<<<Used for troubleshooting
Sleep(150)
; Wait until key is released.
While _IsPressed("43", $hDLL)
Sleep(250)
WEnd
ConsoleWrite("_IsPressed - C Key was released." & @CRLF)             ;<<<<<<<<<<<< Used for troubleshooting
ElseIf _IsPressed("1B", $hDLL) or $End = 1 Then
$Stop = 1
EndIf
Sleep(250)
WEnd
DllClose($hDLL)
EndFunc


Func End() ; <<<<<<<<<<<< Added this to try to break the script and cause it to sleep... This should pull it outta the function... but doesn't.
While 1
Sleep(1000)
WEnd
EndFunc
Func New()
EndFunc
Func Open()
EndFunc
Func Help()
EndFunc
Func About()
EndFunc
Func Save()
EndFunc
Func Save_As()
EndFunc
Func Close()
Exit
EndFunc

While 1
Sleep(250)
WEnd

EDIT: Didn't mean it works, just meant it now opens and shows the GUI.

Yeah, I didn't finish the rest of it yet, I like to build, test, build, test, build, test lol. I've hit this point and it wasn't working so before I went on with deciding what I wanted all these things to do I was trying to fix the problems I was already having. I've built a few scripts already, ( like 12 I think ) And I wanted to try something a little more difficult. I've only written 1 script with a GUI Attached and it was rather simple so I tried to make it better. I've worked on it a little more. Changed a lot of things around, and got it working somewhat... It will now record the coordinates when I press the "Enter" button instead of "c" but, when I try to call it back with a seperate script , it is not acting correct. I have it saved on a jump drive, and don't have the jump drive on me now so i'll post this part up as soon as I get it back lol.

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  

×