Jump to content

gui button


ussr
 Share

Recommended Posts

HI

I have a basic mistake in my script but I dont know how

to fix it.

When I press the button one time It is working ,

but next the button pressed and nothing happening .

I guess the loop but I dont know how to fix It .

Please help me.

Thank youlauncher.au3

Link to comment
Share on other sites

I don't have uTorrent installed, but what is it meant to do?

and what is the problem you're having?

I'm not too good but I am going to try and help you :)

Edit:

Could you also send the INI or is it meant to be an empty file that we add data into?

Edited by TomDuDolan

My ickle pieces of software :3Radio Scriptr //Almost completeSimple IP/URL pinger, my first program. //CompletedSimple Downloader // Working - basic stateOn-GoingRadio Scriptr - Radio Server.

Link to comment
Share on other sites

HI

I have a basic mistake in my script but I dont know how

to fix it.

When I press the button one time It is working ,

but next the button pressed and nothing happening .

I guess the loop but I dont know how to fix It .

Please help me.

Thank youlauncher.au3

ussr - It seems that you will be stuck in your While 1 & 2 loops.

See comment inside.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "end")
Func end()
    Exit 0
EndFunc   ;==>end

Global $Button1, $Combo1, $Combo2, $Combo3, $Combo4
first()
Func first()
    GUICreate("Form1", 485, 285, 282, 117)
    $Combo1 = GUICtrlCreateCombo("min", 24, 32, 145, 25)
    GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $Combo2 = GUICtrlCreateCombo("hour", 24, 88, 145, 25)
    GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24")
    $Combo3 = GUICtrlCreateCombo("min", 304, 32, 145, 25)
    GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $Combo4 = GUICtrlCreateCombo("hour", 304, 88, 145, 25)
    GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24")
    $Button1 = GUICtrlCreateButton("1", 200, 144, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
EndFunc   ;==>first
While 1
    Sleep(20)
    $GuiMsg = GUIGetMsg()
    Select
        Case $GuiMsg = $Gui_Event_Close
            Exit
        Case $GuiMsg = $Combo1
            IniWrite("C:\basz.ini", "section", "1", GUICtrlRead($Combo1))
        Case $GuiMsg = $Combo2
            IniWrite("C:\basz.ini", "section", "2", GUICtrlRead($Combo2))
        Case $GuiMsg = $Combo3
            IniWrite("C:\basz.ini", "section", "3", GUICtrlRead($Combo3))
        Case $GuiMsg = $Combo4
            IniWrite("C:\basz.ini", "section", "4", GUICtrlRead($Combo4))
            Sleep(50)
        Case $GuiMsg = $Button1
            FUNU()
            Sleep(20)
            des()
    EndSelect
WEnd
Func clos()
    $list = ProcessList("uTorrent.exe")
    ProcessClose($list[1][1])
    Sleep(10)
EndFunc   ;==>clos
Func FUNU()
    While 1
        $min = IniRead("C:\basz.ini", "section", "1", "")
        $hour = IniRead("C:\basz.ini", "section", "2", "")
        Sleep(50)
        If @MIN = $min And @HOUR = $hour Then
            Run(@ProgramFilesDir & "\uTorrent\uTorrent.exe")
            Return; <<<<<<<<<<<<  ============   Rather use EndLoop to break out of this While 1 loop
        EndIf
    WEnd
EndFunc   ;==>FUNU
Func des()
    While 2
        $mins = IniRead("C:\basz.ini", "section", "3", "")
        $hours = IniRead("C:\basz.ini", "section", "4", "")
        Sleep(50)
        If @MIN = $mins And @HOUR = $hours Then
            clos()
            Return; <<<<<<<<<<<   ===========    Rather use EndLoop to break out of this While 2 loop
        EndIf
    WEnd
EndFunc   ;==>des
Link to comment
Share on other sites

A simplified version too >>

Also note you don't need to put Sleep() in the While Loop when using GUIGetMsg() as GUIGetMsg() sleeps too, this is to reduce CPU usage. Also the Function "FUNU()" will keep opening up a new UTorrent, unless UTorrent only allows one process (I don't know never tried it.)

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; Used to Check the Script it declaring variables correctly.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main()
    Local $Button1, $Combo1, $Combo2, $Combo3, $Combo4

    GUICreate("Working Example", 485, 285, 282, 117)
    $Combo1 = GUICtrlCreateCombo("min", 24, 32, 145, 25)
    GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $Combo2 = GUICtrlCreateCombo("hour", 24, 88, 145, 25)
    GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24")
    $Combo3 = GUICtrlCreateCombo("min", 304, 32, 145, 25)
    GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")
    $Combo4 = GUICtrlCreateCombo("hour", 304, 88, 145, 25)
    GUICtrlSetData(-1, "01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24")
    $Button1 = GUICtrlCreateButton("1", 200, 144, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit

            Case $Combo1
                IniWrite(@ScriptDir & "\basz.ini", "section", "1", GUICtrlRead($Combo1))
                ConsoleWrite(GUICtrlRead($Combo1) & @CRLF)

            Case $Combo2
                IniWrite(@ScriptDir & "\basz.ini", "section", "2", GUICtrlRead($Combo2))
                ConsoleWrite(GUICtrlRead($Combo2) & @CRLF)

            Case $Combo3
                IniWrite(@ScriptDir & "\basz.ini", "section", "3", GUICtrlRead($Combo3))
                ConsoleWrite(GUICtrlRead($Combo3) & @CRLF)

            Case $Combo4
                IniWrite(@ScriptDir & "\basz.ini", "section", "4", GUICtrlRead($Combo4))
                ConsoleWrite(GUICtrlRead($Combo4) & @CRLF)

            Case $Button1
;~              _Function()
;~              _Close()
        EndSwitch
    WEnd
EndFunc   ;==>_Main

@JoHanatCent - I wasn't taking your spotlight, but I had just edited the Script and saw your post, so I thought instead of scrapping it I would at least post what I had :)

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I belive µTorrent wont open a new instance, but make the current uTorrent window selected and active.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

It is still not working .

When I set min and hour and press the button it is starting one time .

The closing part ( func des() clos() ) are not working too.

I close the UTORRENT manually and

if I set another min and hour nothing happening.

I also noticed that the ,if I launch one time the

next time It doesnt write into the ini file.

And I cant close it too.

guinness I found in your script consolewrite .

How can I read it at the while 1 - 2 sections?

And Why did you used It together with iniwrite?

Link to comment
Share on other sites

I use ConsoleWrite() for debugging purposes only, it shows the text that was selected in the ComboBox. Didn't JoHanatCent's work?

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

A simplified version too >>

@JoHanatCent - I wasn't taking your spotlight, but I had just edited the Script and saw your post, so I thought instead of scrapping it I would at least post what I had :)

@guinness - No problem. I'm not here for the spotlight and your solution seems like a better route to go?
Link to comment
Share on other sites

Just try It put the ("Notepad.exe") inted of torrent and you will see what is the problem.

It will opening the notepad untill @MIN = $min And @HOUR = $hour

I want to run one time per button pressed.

if Not ProcessExists("Notepad.exe") and @MIN = $min And @HOUR = $hour Then

This way run one time.

I still have this problems :

When I set min and hour and press the button it is starting one time .

The closing part ( func des() clos() ) are not working too.

I close the UTORRENT manually and

if I set another min and hour nothing happening.

I also noticed that the ,if I launch one time the

next time It doesnt write into the ini file.

And I cant close it too.

Link to comment
Share on other sites

Just try It put the ("Notepad.exe") inted of torrent and you will see what is the problem.

I still have this problems :

@ussr - Try this. Tested this with Notepad.

If you get stuck just post your code here again and we'll try our best to help!

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $min, $hour, $mins, $hours, $Button1
_Main()

Func _Main()
    Local $Combo1, $Combo2, $Combo3, $Combo4

    GUICreate('Working Example', 485, 285, 282, 117)
    $Label = GUICtrlCreateLabel('Min / Hour to Start:', 24, 10, 190, 15)
    $Label = GUICtrlCreateLabel('Min / Hour to Stop:', 304, 10, 190, 15)
    $Combo1 = GUICtrlCreateCombo('min', 24, 32, 145, 25)
    GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59')
    $Combo2 = GUICtrlCreateCombo('hour', 24, 88, 145, 25)
    GUICtrlSetData(-1, '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24')
    $Combo3 = GUICtrlCreateCombo('min', 304, 32, 145, 25)
    GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59')
    $Combo4 = GUICtrlCreateCombo('hour', 304, 88, 145, 25)
    GUICtrlSetData(-1, '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24')
    $Button1 = GUICtrlCreateButton('Go', 200, 144, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit

            Case $Combo1;Min
                IniWrite(@ScriptDir & '\basz.ini', 'section', '1', GUICtrlRead($Combo1))
                ConsoleWrite(GUICtrlRead($Combo1) & @CRLF)

            Case $Combo2;Hour
                IniWrite(@ScriptDir & '\basz.ini', 'section', '2', GUICtrlRead($Combo2))
                ConsoleWrite(GUICtrlRead($Combo2) & @CRLF)

            Case $Combo3;Min
                IniWrite(@ScriptDir & '\basz.ini', 'section', '3', GUICtrlRead($Combo3))
                ConsoleWrite(GUICtrlRead($Combo3) & @CRLF)

            Case $Combo4;Hour
                IniWrite(@ScriptDir & '\basz.ini', 'section', '4', GUICtrlRead($Combo4))
                ConsoleWrite(GUICtrlRead($Combo4) & @CRLF)

            Case $Button1
                GUICtrlSetData($Button1, 'Started')
                While 'Waiting'
                    Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                            ExitLoop

                    EndSwitch
                    _Function()
                    _Close()
                WEnd
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func clos()
    GUICtrlSetData($Button1, 'Ending !!!')
    Sleep(13)
    $list = ProcessList('NotePad.exe')
    ProcessClose($list[1][1])

    Sleep(10)
    MsgBox(0, '', 'Closing everything !', 6)
    Exit
EndFunc   ;==>clos
Func _Function()
    $min = IniRead('basz.ini', 'section', '1', '')
    $hour = IniRead('basz.ini', 'section', '2', '')
    Sleep(50)
    If @MIN = Number($min) And @HOUR = Number($hour) Then
        If ProcessExists('notepad.exe') Then
            MsgBox(0, 'Attention Time now is '&@HOUR&':'&@MIN, '===  Notepad is running.  ===' & @CRLF & @CRLF & 'Starting ' & _
                    $hour & ':' & $min & @CRLF & 'Ending  ' & $hours & ':' & $mins, 5)
        Else
            Run('NotePad.exe')
        EndIf
    EndIf
EndFunc   ;==>_Function
Func _Close()
    $mins = IniRead('basz.ini', 'section', '3', '')
    $hours = IniRead('basz.ini', 'section', '4', '')
    Sleep(50)
    If ProcessExists('notepad.exe') Then
        If @MIN = Number($mins) And @HOUR = Number($hours) Then
            clos()
        EndIf
    EndIf
EndFunc   ;==>_Close

Tidy up!

Edited by JoHanatCent
Link to comment
Share on other sites

HI

Me again.

How can I put it together.

I want to use calendar ,open , timer on my script.

When I use the timer it is working .

If I click open after that the timer doesnt work.

I guess loop problem.

Please have a look.

timer.au3

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...