Jump to content

Can't select radio when automated


Recommended Posts

Hello everyone,

First, watch the screenshot I attached:

Naamloos.png.551f4c52832304bed587319e1099f0bd.png

The background beneath the radios is that a value is subtracted from Player 1, and added to player 2, in the case of the screenshot I made.
You can see that I created 2 radio groups. On the upper part, radio 1 and 2, and on the lower part radio 5 and 6. Now I automated the buttons in such a way ,that when in group 1 player 1 is selected, player 2 in group 2 automatically gets checked for you. Same thing when checking player 2 in the upper part: player 1 gets checked on the lower part. I did this because there is no reason selecting player 1 or 2 twice, because nothing will change. Now that runs smoothly using this script:

If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio6),1) And Not BitAND(GUICtrlGetState($Radio5),1) Then GUICtrlSetState($Radio6,1)
If GUICtrlRead($Radio2)=1 And Not BitAND(GUICtrlGetState($Radio5),1) And Not BitAND(GUICtrlGetState($Radio6),1) Then GUICtrlSetState($Radio5,1)
If GUICtrlRead($Radio5)=1 And Not BitAND(GUICtrlGetState($Radio2),1) And Not BitAND(GUICtrlGetState($Radio1),1) Then GUICtrlSetState($Radio2,1)
If GUICtrlRead($Radio6)=1 And Not BitAND(GUICtrlGetState($Radio1),1) And Not BitAND(GUICtrlGetState($Radio2),1) Then GUICtrlSetState($Radio1,1)

But there is a problem when clicking on a radio in group 2, the lower one. It is very hard to check one, because for some reason the radio get's deselected instantly most of the time. I already tried to prevent it by using the second BitAND() in the codes I shared (It doesn't check the radio automatically if the other radio in the other group is selected, meaning that the user want's to switch the radios). But it didn't work.

Does somebody know why you sometimes can't check radio 5 or 6 (the lower part)?

Edited by Silas
Link to post
Share on other sites

Is there a reproducible script for us to test?

This has a lot of conditions and probably when you click the lower group one of the conditions acts on it, you have to be smart about the way you place the conditions, for one, instead of checking if X box is NOT checked and Y is NOT checked, maybe check only one of them and mark the other one regardless of it being marked or not.

I don't know if the idea was well passed but in my head it makes sense.

Spoiler

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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

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.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

Link to post
Share on other sites
1 hour ago, Silas said:

for some reason the radio get's deselected instantly most of the time

Radios 5 and 6 are slaves, and this looks like a continuous checking (maybe in a While loop ?)
Such an automated checking should be done only when a button is clicked. Could you post a little reproducer as careca suggested to make things easier ?  :)

Link to post
Share on other sites

@Silas, @careca, @mikell
What about WM_COMMAND? :)

Spoiler
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
Global $frmMainForm = GUICreate("A Form", 236, 162, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication")
Global $grpGroup1 = GUICtrlCreateGroup("Group 1", 17, 20, 201, 57)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
Global $radPlayer1_1 = GUICtrlCreateRadio("Player 1", 23, 46, 73, 17)
Global $radPlayer2_1 = GUICtrlCreateRadio("Player 2", 135, 46, 73, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $grpGroup2 = GUICtrlCreateGroup("Group 2", 17, 84, 201, 57)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
Global $radPlayer1_2 = GUICtrlCreateRadio("Player 1", 23, 110, 73, 17)
Global $radPlayer2_2 = GUICtrlCreateRadio("Player 2", 135, 110, 73, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW, $frmMainForm)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


While 1
    Sleep(100)
WEnd


Func ExitApplication()
    Exit
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Local $hdlWindow, _
          $intControlID_From, _
          $intMessageCode


    $intControlID_From = BitAND($wParam, 0xFFFF)
    $intMessageCode = BitShift($wParam, 16)

    Switch $intMessageCode
        Case $BN_CLICKED
            Switch $intControlID_From
                ; Clicking on Player 1 - Group 1 : Set Player 2 - Group 2 to 1
                Case $radPlayer1_1
                    GUICtrlSetState($radPlayer2_2, 1)

                ; Clicking on Player 2 - Group 1 : Set Player 1 - Group 2 to 1
                Case $radPlayer2_1
                    GUICtrlSetState($radPlayer1_2, 1)

                ; Clicking on Player 1 - Group 2 : Set Player 2 - Group 1 to 1
                Case $radPlayer1_2
                    GUICtrlSetState($radPlayer2_1, 1)

                ; Clicking on Player 2 - Group 2 : Set Player 1 - Group 1 to 1
                Case $radPlayer2_2
                    GUICtrlSetState($radPlayer1_1, 1)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc

 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites

Thats good Francesco! :D

Spoiler

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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

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.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

Link to post
Share on other sites

Alright, I tried to copy paste some things, but the script looks really weird without the context.

#include <ButtonConstants.au3> ;===========Includers
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>

$WBreedte = 306 ;width
$WHoogte = 165 ;height
Global $Window = GUICreate("MonoBank - Start", $WBreedte, $WHoogte, @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $GUI_SS_DEFAULT_GUI)
GUISetFont(12, 400, 0, "Arial")
GUISetState(@SW_SHOW) ;==== I only added this old window so that the following codes still work


$Spelers=2
$Speler1=1
$Speler2=1
$Geld1=1500
$Geld2=1500 ;== Variables used later in this script
Global $WhileH = 1 ;(Part of bigger thing in the whole script)
Global $SpelersOver = 2

    #Region ;Al het toevoegen (all the creating of the GUI)
    Global $Startbedrag = 1500
    Global $Einde = False
            $WBreedte =508
            $WHoogte = 360
            $X_Undo = 218
            $X_Input = 271
            $X_Transfer = 418
                Global $Spelend1 = 1
                Global $Spelend2 = 1

    WinMove($Window, "", @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $WBreedte, $WHoogte)
        Global $Zender1 = GUICtrlCreateLabel($Speler1, 222, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x4286f4)
        Global $Zender2 = GUICtrlCreateLabel($Speler2, 360, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xea3838)
        Global $GeldStatus1 = GUICtrlCreateLabel("?" & $Geld1, 222, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        Global $GeldStatus2 = GUICtrlCreateLabel("?" & $Geld2, 360, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        Global $Ontvanger1 = GUICtrlCreateLabel($Speler1, 222, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x4286f4)
        Global $Ontvanger2 = GUICtrlCreateLabel($Speler2, 360, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xea3838)

    GUIStartGroup()
        Global $Radio1 = GUICtrlCreateRadio("", 266, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        Global $Radio2 = GUICtrlCreateRadio("", 404, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)

    GUIStartGroup()
        Global $Radio5 = GUICtrlCreateRadio("", 266, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        Global $Radio6 = GUICtrlCreateRadio("", 404, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)

        Global $Input = GUICtrlCreateInput("", $X_Input, 153, 144, 50, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER,$WS_GROUP))
            GUICtrlSetFont(-1, 28, 400, 0, "Arial")
            GUICtrlSetCursor (-1, 5)
            GUICtrlSetLimit(-1, 6)

        Global $Button_Transfer = GUICtrlCreateButton("OK", $X_Transfer, 153, 50, 50, BitOR($WS_GROUP, $BS_DEFPUSHBUTTON))
            GUICtrlSetCursor(-1, 0)
        Global $Button_Undo = GUICtrlCreateButton("<", $X_Undo, 153, 50, 50, $WS_GROUP)
            GUICtrlSetCursor(-1, 0)
#EndRegion (creating GUI)

    While $WhileH
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Transfer
                If GUICtrlRead($Input)= Not "" And $Einde = False Then
                    ;Transfer()
                EndIf
;           Case $Button_Undo
;               Sumsing
            ;Case $Button_Return
            ;   MsgBox(4, "Waarschuwing", "Als je teruggaat, verlies je alle voortgang en krijgt iedereen weer het standaard bedrag." & @CRLF & "Wil je doorgaan?") ;Warning box. About losing progress
            ;   Start()

        EndSwitch

    If $SpelersOver=2 Then
        If $Spelers=2 Then
            If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio6),1) And Not BitAND(GUICtrlGetState($Radio5),1) Then GUICtrlSetState($Radio6,1)
            If GUICtrlRead($Radio2)=1 And Not BitAND(GUICtrlGetState($Radio5),1) And Not BitAND(GUICtrlGetState($Radio6),1) Then GUICtrlSetState($Radio5,1)
            If GUICtrlRead($Radio5)=1 And Not BitAND(GUICtrlGetState($Radio2),1) And Not BitAND(GUICtrlGetState($Radio1),1) Then GUICtrlSetState($Radio2,1)
            If GUICtrlRead($Radio6)=1 And Not BitAND(GUICtrlGetState($Radio1),1) And Not BitAND(GUICtrlGetState($Radio2),1) Then GUICtrlSetState($Radio1,1)
        EndIf
    EndIf

    WEnd

If some things aren't clear: here's the whole script.

;Ideeën:
;   - Bij instellen namen, kies ook pion/naam van pion, en kleur?
;   - Startbedrag
;   - Beginscherm en namen ook groter font maken, zodat iedereen het goed kan lezen
;   - Terugknop omzetten in pijl terug:
                                        ;$Pic_Return = GUICtrlCreateIcon("C:\Users\Silas\Desktop\Terugknop.bmp", 0, 0,40,20)
                                            ;If @error Then
                                                ;MsgBox(0, "", @error)
                                        ;   EndIf
;   - Versimpel script (duidelijker maken, uitleggen, maak van Namen2-4 1 func etc
;   - De naam en radio samenvoegen in 1, doorzichtige knop
;   - Leg script uit met dit soort tekst

#include <ButtonConstants.au3> ;===========Includers
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>

Start()
Func Start() ;===========Startscherm (hoeveel spelers er zijn)
    $WBreedte = 306
    $WHoogte = 165
Global $Window = GUICreate("MonoBank - Start", $WBreedte, $WHoogte, @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $GUI_SS_DEFAULT_GUI)
    GUISetFont(12, 400, 0, "Arial")
Global $Label_Spelers = GUICtrlCreateLabel("Welkom, met hoeveel spelers zijn jullie?", 16, 16, 277, 22)
Global $Radio2 = GUICtrlCreateRadio("2 Spelers", 32, 56, 113, 17)
    GUICtrlSetCursor(-1, 0)
Global $Radio3 = GUICtrlCreateRadio("3 Spelers", 32, 88, 113, 17)
    GUICtrlSetCursor(-1, 0)
Global $Radio4 = GUICtrlCreateRadio("4 Spelers", 32, 120, 113, 17)
    GUICtrlSetCursor(-1, 0)
Global $Button_Next = GUICtrlCreateButton("Volgende", 184, 125, 97, 25, $BS_DEFPUSHBUTTON)
    GUICtrlSetFont(-1, 11, 400, 0, "Arial")
    GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)

Global $While1=1
While $While1 ;===========Wat te doen bij startscherm
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button_Next
            If GUICtrlRead($Radio2) = 1 or GUICtrlRead($Radio3) = 1 or GUICtrlRead($Radio4) = 1 Then
                Ctr_Radio() ;Verwijst naar controle van de opties
            Else
                MsgBox($MB_OK, "Niet zo snel", "Voer eerst in met hoeveel spelers jullie zijn") ;Foutmelding
            EndIf
    EndSwitch
Wend
EndFunc   ;==>Start

Func Ctr_Radio() ;===========Controlleert welke optie gekozen is, en verwijst door naar toepassende venster
    If GUICtrlRead($Radio2) = 1 Then
        Global $Spelers = 2
        Namen2()
    ElseIf GUICtrlRead($Radio3) = 1 Then
        Global $Spelers = 3
        Namen3()
    ElseIf GUICtrlRead($Radio4) = 1 Then
        Global $Spelers = 4
        Namen4()
    Else
        MsgBox($MB_OK, "Hosuton, we got a problem", "Er kon niet gelezen worden welke optie je gekozen hebt." & @CRLF & "Foutcode: " & @error) ;Foutmelding, lijkt me duidelijk
    EndIf
EndFunc   ;==>Ctr_Radio

Func Namen2() ;===========Venster waarbij je namen kiest voor 2 spelers
        WinSetTitle($Window, "", "MonoBank - Namen")
        GUICtrlDelete($Label_Spelers)
        GUICtrlDelete($Radio2)
        GUICtrlDelete($Radio3)
        GUICtrlDelete($Radio4)
        GUICtrlDelete($Button_Next)
    Global $Label_Namen = GUICtrlCreateLabel("Hoe zal ik jullie noemen?", 71, 15)
    Global $Label1 = GUICtrlCreateLabel("Speler 1", 62, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0x4286f4)
    Global $Input1 = GUICtrlCreateInput("", 38, 90, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Label2 = GUICtrlCreateLabel("Speler 2", 198, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0xea3838)
    Global $Input2 = GUICtrlCreateInput("", 174, 90, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Button_Next = GUICtrlCreateButton("Start", 306 / 2 - 42, 125, 97, 25, $BS_DEFPUSHBUTTON)
        GUICtrlSetFont(-1, 11, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 0)
    Global $Button_Return = GUICtrlCreateButton("<", 0, 0, 25, 25, $WS_GROUP)
        GUICtrlSetFont(-1, 11, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 0)

Global $While1 = 0
Global $While2 = 1

    While $While2
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            ;Case $Button_Return
            ;   Start()
            Case $Button_Next
                If GUICtrlRead($Input1) = "" and GUICtrlRead($Input2) = "" Then
                    MsgBox(0, "Niet zo snel", "Ik ken niemand die geen naam heeft")
                ElseIf GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Then
                    MsgBox(0, "Niet zo snel", "Je moet wel voor beide personen een naam invoeren")
                Else
                    Global $Speler1 = GUICtrlRead($Input1)
                    Global $Speler2 = GUICtrlRead($Input2)
                    Hoofdscherm()
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Namen2

Func Namen3() ;===========Venster waarbij je namen kiest voor 3 spelers
        $WBreedte = 423
        $WHoogte = 220
    WinMove($Window, "", @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $WBreedte, $WHoogte)
        WinSetTitle($Window, "", "MonoBank - Namen")
        GUICtrlDelete($Label_Spelers)
        GUICtrlDelete($Radio2)
        GUICtrlDelete($Radio3)
        GUICtrlDelete($Radio4)
        GUICtrlDelete($Button_Next)
    Global $Label_Namen = GUICtrlCreateLabel("Hoe zal ik jullie noemen?", 127, 24, 175, 22, $WS_GROUP)
    Global $Label1 = GUICtrlCreateLabel("Speler 1", 64, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0x4286f4)
    Global $Input1 = GUICtrlCreateInput("", 40, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Label2 = GUICtrlCreateLabel("Speler 2", 184, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0xea3838)
    Global $Input2 = GUICtrlCreateInput("", 160, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Label3 = GUICtrlCreateLabel("Speler 3", 304, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0x10cc38)
    Global $Input3 = GUICtrlCreateInput("", 281, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Button_Next = GUICtrlCreateButton("Start", 166, 144, 97, 25, BitOR($WS_GROUP, $BS_DEFPUSHBUTTON))
        GUICtrlSetFont(-1, 11, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 0)
    Global $Button_Return = GUICtrlCreateButton("<", 0, 0, 25, 25, $WS_GROUP)
        GUICtrlSetFont(-1, 11, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 0)

Global $While1 = 0
Global $While2 = 1

    While $While2
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Next
                If GUICtrlRead($Input1) = "" and GUICtrlRead($Input2) = "" And GUICtrlRead($Input3) = "" Then
                    MsgBox(0, "Niet zo snel", "Ik ken niemand die geen naam heeft")
                ElseIf GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Or GUICtrlRead($Input3) = "" Then
                    MsgBox(0, "Niet zo snel", "Je moet wel alle namen invoeren")
                Else
                    Global $Speler1 = GUICtrlRead($Input1)
                    Global $Speler2 = GUICtrlRead($Input2)
                    Global $Speler3 = GUICtrlRead($Input3)
                    Hoofdscherm()
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Namen3

Func Namen4() ;===========Venster waarbij je namen kiest voor 4 spelers
        $WBreedte = 546
        $WHoogte = 220
    WinMove($Window, "", @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $WBreedte, $WHoogte)
        WinSetTitle($Window, "", "MonoBank - Namen")
        GUICtrlDelete($Label_Spelers)
        GUICtrlDelete($Radio2)
        GUICtrlDelete($Radio3)
        GUICtrlDelete($Radio4)
        GUICtrlDelete($Button_Next)
    Global $Label_Namen = GUICtrlCreateLabel("Hoe zal ik jullie noemen?", 185, 24, 175, 22, $WS_GROUP)
    Global $Label1 = GUICtrlCreateLabel("Speler 1", 64, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0x4286f4)
    Global $Input1 = GUICtrlCreateInput("", 40, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Label2 = GUICtrlCreateLabel("Speler 2", 184, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0xea3838)
    Global $Input2 = GUICtrlCreateInput("", 160, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Label3 = GUICtrlCreateLabel("Speler 3", 304, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0x10cc38)
    Global $Input3 = GUICtrlCreateInput("", 281, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Label4 = GUICtrlCreateLabel("Speler 4", 424, 64, 63, 22, $WS_GROUP)
        GUICtrlSetColor(-1, 0xdbd82b)
    Global $Input4 = GUICtrlCreateInput("", 402, 96, 105, 24, BitOR($ES_AUTOHSCROLL, $WS_GROUP))
        GUICtrlSetFont(-1, 10, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 5)
    Global $Button_Next = GUICtrlCreateButton("Start", 224, 144, 97, 25, BitOR($WS_GROUP, $BS_DEFPUSHBUTTON))
        GUICtrlSetFont(-1, 11, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 0)
    Global $Button_Return = GUICtrlCreateButton("<", 0, 0, 25, 25, $WS_GROUP)
        GUICtrlSetFont(-1, 11, 400, 0, "Arial")
        GUICtrlSetCursor(-1, 0)

Global $While1 = 0
Global $While2 = 1

    While $While2
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Next
                If GUICtrlRead($Input1) = "" And GUICtrlRead($Input2) = "" And GUICtrlRead($Input3) = "" And GUICtrlRead($Input4) = "" Then
                    MsgBox(0, "Niet zo snel", "Ik ken niemand die geen naam heeft")
                ElseIf GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Or GUICtrlRead($Input3) = "" Or GUICtrlRead($Input4) = "" Then
                    MsgBox(0, "Niet zo snel", "Je moet wel alle namen invoeren")
                Else
                    Global $Speler1 = GUICtrlRead($Input1)
                    Global $Speler2 = GUICtrlRead($Input2)
                    Global $Speler3 = GUICtrlRead($Input3)
                    Global $Speler4 = GUICtrlRead($Input4)
                    Hoofdscherm()
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Namen4

Func Hoofdscherm()  ;===========Het venster waar het allemaal gebeurt
    #Region ;Al het verwijderen
        WinSetTitle($Window, "", "MonoBank")
        GUICtrlDelete($Button_Next)
        ;GUICtrlDelete($Button_Return)
        GUICtrlDelete($Label1)
        GUICtrlDelete($Label2)
            If IsDeclared("Label3") = Not 0 Then
        GUICtrlDelete($Label3)
                EndIf
            If IsDeclared("Label4") = Not 0 Then
        GUICtrlDelete($Label4)
                EndIf
        GUICtrlDelete($Input1)
        GUICtrlDelete($Input2)
            If IsDeclared("Input3") = Not 0 Then
        GUICtrlDelete($Input3)
                EndIf
            If IsDeclared("Input4") = Not 0 Then
        GUICtrlDelete($Input4)
                EndIf
        GUICtrlDelete($Label_Namen) ;============= Nu is alles prachtig mooi opgruimt
        #EndRegion
    #Region ;Al het toevoegen
    Global $Startbedrag = 1500
    Global $Einde = False
        If $Spelers = 2 Then
            $WBreedte =508
            $X_Undo = 218
            $X_Input = 271
            $X_Transfer = 418
                Global $Geld1 = $Startbedrag
                Global $Geld2 = $Startbedrag
                Global $Spelend1 = 1
                Global $Spelend2 = 1
        ElseIf $Spelers = 3 Then
            $WBreedte = 623
            $X_Undo = 288
            $X_Input = 341
            $X_Transfer = 488
                Global $Geld1 = $Startbedrag
                Global $Geld2 = $Startbedrag
                Global $Geld3 = $Startbedrag
                Global $Spelend1 = 1
                Global $Spelend2 = 1
                Global $Spelend3 = 1
        ElseIf $Spelers = 4 Then
            $WBreedte = 758
            $X_Undo = 358
            $X_Input = 411
            $X_Transfer = 558
                Global $Geld1 = $Startbedrag
                Global $Geld2 = $Startbedrag
                Global $Geld3 = $Startbedrag
                Global $Geld4 = $Startbedrag
                Global $Spelend1 = 1
                Global $Spelend2 = 1
                Global $Spelend3 = 1
                Global $Spelend4 = 1
        Else
            MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen hoeveel spelers er zijn" & @CRLF & "Foutcode: " & @error)
        EndIf       ;===================== Dit allemaal bepaalt de posities en andere dingen van bepaalde dingen, afhankelijk van het aantal spelers
        $WHoogte = 360
    WinMove($Window, "", @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $WBreedte, $WHoogte)
        Global $Zender1 = GUICtrlCreateLabel($Speler1, 222, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x4286f4)
        Global $Zender2 = GUICtrlCreateLabel($Speler2, 360, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xea3838)
    If IsDeclared("Speler3") = Not 0 Then
        Global $Zender3 = GUICtrlCreateLabel($Speler3, 499, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x10cc38)
        EndIf

        Global $GeldStatus1 = GUICtrlCreateLabel("₩" & $Geld1, 222, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        Global $GeldStatus2 = GUICtrlCreateLabel("₩" & $Geld2, 360, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
    If IsDeclared("Speler3") = Not 0 Then
        Global $GeldStatus3 = GUICtrlCreateLabel("₩" & $Geld3, 499, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        EndIf

    If IsDeclared("Speler4") = Not 0 Then
        Global $GeldStatus4 = GUICtrlCreateLabel("₩" & $Geld4, 637, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        EndIf
    If IsDeclared("Speler4") = Not 0 Then
        Global $Zender4 = GUICtrlCreateLabel($Speler4, 637, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xdbd82b)
        EndIf
        Global $Ontvanger1 = GUICtrlCreateLabel($Speler1, 222, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x4286f4)
        Global $Ontvanger2 = GUICtrlCreateLabel($Speler2, 360, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xea3838)
    If IsDeclared("Speler3") = Not 0 Then
        Global $Ontvanger3 = GUICtrlCreateLabel($Speler3, 499, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x10cc38)
        EndIf
    If IsDeclared("Speler4") = Not 0 Then
        Global $Ontvanger4 = GUICtrlCreateLabel($Speler4, 637, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xdbd82b)
        EndIf

    GUIStartGroup()
        Global $Radio1 = GUICtrlCreateRadio("", 266, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        Global $Radio2 = GUICtrlCreateRadio("", 404, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
    If IsDeclared("Speler3") = Not 0 Then
        Global $Radio3 = GUICtrlCreateRadio("", 543, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        EndIf
    If IsDeclared("Speler4") = Not 0 Then
        Global $Radio4 = GUICtrlCreateRadio("", 681, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        EndIf
    GUIStartGroup()
        Global $Radio5 = GUICtrlCreateRadio("", 266, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        Global $Radio6 = GUICtrlCreateRadio("", 404, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
    If IsDeclared("Speler3") = Not 0 Then
        Global $Radio7 = GUICtrlCreateRadio("", 543, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        EndIf
    If IsDeclared("Speler4") = Not 0 Then
        Global $Radio8 = GUICtrlCreateRadio("", 681, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        EndIf

        Global $Input = GUICtrlCreateInput("", $X_Input, 153, 144, 50, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER,$WS_GROUP))
            GUICtrlSetFont(-1, 28, 400, 0, "Arial")
            GUICtrlSetCursor (-1, 5)
            GUICtrlSetLimit(-1, 6)

        Global $Button_Transfer = GUICtrlCreateButton("OK", $X_Transfer, 153, 50, 50, BitOR($WS_GROUP, $BS_DEFPUSHBUTTON))
            GUICtrlSetCursor(-1, 0)
        Global $Button_Undo = GUICtrlCreateButton("<", $X_Undo, 153, 50, 50, $WS_GROUP)
            GUICtrlSetCursor(-1, 0)
        #EndRegion

        ;==================================================Doe een "veel plezier!" popup of zo, en ook zon soort popup in plaats van eens stom msgbox met WE HEBBEN EEN WINNAAR
Global $While2 = 0
Global $WhileH = 1
If $Spelers = 2 Then
    Global $SpelersOver = 2
ElseIf $Spelers = 3 Then
    Global $SpelersOver = 3
ElseIf $Spelers = 4 Then
    Global $SpelersOver = 4
EndIf ;==> Dit stelt het de variable $Spelers in op het aantal spelers, zodat in de volgende while loop gechekt kan worden of er 2 spelers over zijn, waardoor de radio's zich slimmer gedragen

    While $WhileH
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Transfer
                If GUICtrlRead($Input)= Not "" And $Einde = False Then
                    Transfer()
                EndIf
;           Case $Button_Undo
;               Sumsing
            Case $Button_Return
                MsgBox(4, "Waarschuwing", "Als je teruggaat, verlies je alle voortgang en krijgt iedereen weer het standaard bedrag." & @CRLF & "Wil je doorgaan?")
                Start()

        EndSwitch

        If GuiCtrlRead($GeldStatus1) <> "₩" & $Geld1 Then GUICtrlSetData($GeldStatus1, "₩" & $Geld1)
        If GuiCtrlRead($GeldStatus2) <> "₩" & $Geld2 Then GUICtrlSetData($GeldStatus2, "₩" & $Geld2)
        If IsDeclared("Speler3") = Not 0 And GuiCtrlRead($GeldStatus3) <> "₩" & $Geld3 Then   GUICtrlSetData($GeldStatus3, "₩" & $Geld3)
        If IsDeclared("Speler4") = Not 0 And GuiCtrlRead($GeldStatus4) <> "₩" & $Geld4 Then   GUICtrlSetData($GeldStatus4, "₩" & $Geld4)
        ;============= Updatet de geldstatussen meteen als een bedrag verandert

    If $SpelersOver=2 Then
        If $Spelers=2 Then
            If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio6),1) And Not BitAND(GUICtrlGetState($Radio5),1) Then GUICtrlSetState($Radio6,1)
            If GUICtrlRead($Radio2)=1 And Not BitAND(GUICtrlGetState($Radio5),1) And Not BitAND(GUICtrlGetState($Radio6),1) Then GUICtrlSetState($Radio5,1)
            If GUICtrlRead($Radio5)=1 And Not BitAND(GUICtrlGetState($Radio2),1) And Not BitAND(GUICtrlGetState($Radio1),1) Then GUICtrlSetState($Radio2,1)
            If GUICtrlRead($Radio6)=1 And Not BitAND(GUICtrlGetState($Radio1),1) And Not BitAND(GUICtrlGetState($Radio2),1) Then GUICtrlSetState($Radio1,1)
        ElseIf $Spelers=3 Then
                Exit
        ElseIf $Spelers=4 Then
                Exit
        EndIf
    EndIf
;Laat de radios slim wisselen tussen de 2 spelers die over zijn
;       If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_DISABLE) Then GUICtrlSetState($Radio5, 128)
;       If GUICtrlRead($Radio1)<>1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_ENABLE) And $Spelend1 = 1 Then GUICtrlSetState($Radio5, 64)
;       If GUICtrlRead($Radio5)=1 And Not BitAND(GUICtrlGetState($Radio1), $GUI_DISABLE) Then GUICtrlSetState($Radio1, 128)
;       If GUICtrlRead($Radio5)<>1 And Not BitAND(GUICtrlGetState($Radio1), $GUI_ENABLE) And $Spelend1 = 1 Then GUICtrlSetState($Radio1, 64)
;
;       If GUICtrlRead($Radio2)=1 And Not BitAND(GUICtrlGetState($Radio6), $GUI_DISABLE) Then GUICtrlSetState($Radio6, 128)
;       If GUICtrlRead($Radio2)<>1 And Not BitAND(GUICtrlGetState($Radio6), $GUI_ENABLE) And $Spelend2 = 1 Then GUICtrlSetState($Radio6, 64)
;       If GUICtrlRead($Radio6)=1 And Not BitAND(GUICtrlGetState($Radio2), $GUI_DISABLE) Then GUICtrlSetState($Radio2, 128)
;       If GUICtrlRead($Radio6)<>1 And Not BitAND(GUICtrlGetState($Radio2), $GUI_ENABLE) And $Spelend2 = 1 Then GUICtrlSetState($Radio2, 64)
;
;       If IsDeclared("Speler3") Then
;           If GUICtrlRead($Radio3)=1 And Not BitAND(GUICtrlGetState($Radio7), $GUI_DISABLE) Then GUICtrlSetState($Radio7, 128)
;           If GUICtrlRead($Radio3)<>1 And Not BitAND(GUICtrlGetState($Radio7), $GUI_ENABLE) And $Spelend3 = 1 Then GUICtrlSetState($Radio7, 64)
;           If GUICtrlRead($Radio7)=1 And Not BitAND(GUICtrlGetState($Radio3), $GUI_DISABLE) Then GUICtrlSetState($Radio3, 128)
;           If GUICtrlRead($Radio7)<>1 And Not BitAND(GUICtrlGetState($Radio3), $GUI_ENABLE) And $Spelend3 = 1 Then GUICtrlSetState($Radio3, 64)
;       EndIf
;
;       If IsDeclared("Speler4") Then
;           If GUICtrlRead($Radio4)=1 And Not BitAND(GUICtrlGetState($Radio8), $GUI_DISABLE) Then GUICtrlSetState($Radio8, 128)
;           If GUICtrlRead($Radio4)<>1 And Not BitAND(GUICtrlGetState($Radio8), $GUI_ENABLE) And $Spelend4 = 1 Then GUICtrlSetState($Radio8, 64)
;           If GUICtrlRead($Radio8)=1 And Not BitAND(GUICtrlGetState($Radio4), $GUI_DISABLE) Then GUICtrlSetState($Radio4, 128)
;           If GUICtrlRead($Radio8)<>1 And Not BitAND(GUICtrlGetState($Radio4), $GUI_ENABLE) And $Spelend4 = 1 Then GUICtrlSetState($Radio4, 64)
;       EndIf
;       ;============= Schakelt botsende radio's uit

    WEnd
EndFunc

Func Transfer() ;====== Kijkt welke zender is geselecteerd > berekent kosten > bekijkt welke ontvanger is geselecteerd > berekent inkomen  en ondertussen checkt hij wanneer iemand gewonnen heeft
    $GeldErbij = GUICtrlRead($Input)
    $Schulden1 = False

    If GUICtrlRead($Radio1) = 1 Then
        $Result = $Geld1 - $GeldErbij
            $PreTransfer = $Geld1
        Global $Geld1 = $Result ;===> Berekent de transactie
                    $Failliet = 0 ;Nodig bij het bepalen of iemand failliet is (Begint bij de volgende regel)
                    If $Geld1 < 0 Then
                        $Schulden1 = True
                        $GeldErbij = $PreTransfer ;Zorgt ervoor dat bij het overmaken aan de ander (zie beneden deze if's), dat de debtor alleen het geld krijgt die de schuldige ook echt heeft
                        $Failliet = MsgBox(4, "Failliet", $Speler1 & " staat op dit moment in het rood." & @CRLF & "Wil je deze speler failliet verklaren?" & @CRLF & "(Als je op nee drukt, wordt het balans van " & $Speler1 & " teruggezet naar 0.")
                            If $Spelers = 2 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Radio2, 1)
                                    GUICtrlSetState($Radio1, 128)
                                    GUICtrlSetState($Zender1, 128)
                                    GUICtrlSetState($Ontvanger1, 128)
                                    GUICtrlSetState($GeldStatus1, 128)
                                    GUICtrlSetState($Radio5, 128)
                                    $Spelend1 = 0
                                    $Einde = True
                                    MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler2 & "!")
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld1 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox1.1") ;Ik label elke msgbox die een foutcode geeft op deze manier, dan kun je makkelijker vinden waar de fout zich voordeet
                                EndIf

                            ElseIf $Spelers = 3 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Zender1, 128)
                                    GUICtrlSetState($Ontvanger1, 128)
                                    GUICtrlSetState($GeldStatus1, 128)
                                    GUICtrlSetState($Radio5, 128)
                                    $Spelend1 = 0
                                    If $Spelend2 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio2, 1)
                                        GUICtrlSetState($Radio1, 128)
                                    ElseIf $Spelend3 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio3, 1)
                                        GUICtrlSetState($Radio1, 128)
                                    EndIf
                                    If $Spelend3 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler2 & "!")
                                        $Einde = True
                                    ElseIf $Spelend2 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler3 & "!")
                                        $Einde = True
                                    EndIf
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld1 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox1.2")
                                EndIf

                            ElseIf $Spelers = 4 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Zender1, 128)
                                    GUICtrlSetState($Ontvanger1, 128)
                                    GUICtrlSetState($GeldStatus1, 128)
                                    GUICtrlSetState($Radio5, 128)
                                    $Spelend1 = 0
                                    If $Spelend2 = 1 Then ;Hier checkedt(vinkt) hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio2, 1)
                                        GUICtrlSetState($Radio1, 128)
                                    ElseIf $Spelend3 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio3, 1)
                                        GUICtrlSetState($Radio1, 128)
                                    ElseIf $Spelend4 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio4, 1)
                                        GUICtrlSetState($Radio1, 128)
                                    EndIf
                                    If $Spelend3 = 0 And $Spelend4 = 0 Then ;Hier checkt hij of iemand gewonnen heeft
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler2 & "!")
                                        $Einde = True
                                    ElseIf $Spelend2 = 0 And $Spelend4 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler3 & "!")
                                        $Einde = True
                                    ElseIf $Spelend2 = 0 And $Spelend3 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler4 & "!")
                                        $Einde = True
                                    EndIf
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld1 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox1.3")
                                EndIf
                            Else
                                MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen hoeveel mensen er zijn" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox1.4")
                            EndIf
                    EndIf

        If GUICtrlRead($Radio5) = 1 Then
                $Result = $Geld1 + $GeldErbij
                Global $Geld1 = $Result
        ElseIf GUICtrlRead($Radio6) = 1 Then
                $Result = $Geld2 + $GeldErbij
                Global $Geld2 = $Result
        ElseIf IsDeclared("Speler3") = Not 0 And GUICtrlRead($Radio7) = 1 Then
                $Result = $Geld3 + $GeldErbij
                Global $Geld3 = $Result
        ElseIf IsDeclared("Speler4") = Not 0 And GUICtrlRead($Radio8) = 1 Then
                $Result = $Geld4 + $GeldErbij
                Global $Geld4 = $Result
        Else
            MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen welke radioknop is geselecteerd" & @CRLF & "bij een van de secties bij het toevoegen van het bedrag." & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox1.5")
        EndIf




    ElseIf GUICtrlRead($Radio2) = 1 Then
        $Result = $Geld2 - $GeldErbij
            $PreTransfer = $Geld2
        Global $Geld2 = $Result ;===> Berekent de transactie
                    $Failliet = 0 ;Nodig bij het bepalen of iemand failliet is (Begint bij de volgende regel)
                    If $Geld2 < 0 Then
                        $Schulden2 = True
                        $GeldErbij = $PreTransfer ;Zorgt ervoor dat bij het overmaken aan de ander (zie beneden deze if's), dat de debtor alleen het geld krijgt die de schuldige ook echt heeft
                        $Failliet = MsgBox(4, "Failliet", $Speler2 & " staat op dit moment in het rood." & @CRLF & "Wil je deze speler failliet verklaren?" & @CRLF & "(Als je op nee drukt, wordt het balans van " & $Speler2 & " teruggezet naar 0.")
                            If $Spelers = 2 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Radio1, 1)
                                    GUICtrlSetState($Radio2, 128)
                                    GUICtrlSetState($Radio6, 128)
                                    GUICtrlSetState($Zender2, 128)
                                    GUICtrlSetState($Ontvanger2, 128)
                                    GUICtrlSetState($GeldStatus2, 128)
                                    $Spelend2 = 0
                                    $Einde = True
                                    MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler1 & "!")
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld2 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox2.1")
                                EndIf

                            ElseIf $Spelers = 3 Then
                                    If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                        GUICtrlSetState($Zender2, 128)
                                        GUICtrlSetState($Ontvanger2, 128)
                                        GUICtrlSetState($GeldStatus2, 128)
                                        GUICtrlSetState($Radio6, 128)
                                        $Spelend2 = 0
                                        If $Spelend1 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                            GUICtrlSetState($Radio1, 1)
                                            GUICtrlSetState($Radio2, 128)
                                        ElseIf $Spelend3 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                            GUICtrlSetState($Radio3, 1)
                                            GUICtrlSetState($Radio2, 128)
                                        EndIf
                                        If $Spelend3 = 0 Then
                                            MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler1 & "!")
                                            $Einde = True
                                        ElseIf $Spelend1 = 0 Then
                                            MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler3 & "!")
                                            $Einde = True
                                        EndIf
                                    ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                        $Geld2 = 0
                                    Else
                                        MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox2.2")
                                    EndIf

                            ElseIf $Spelers = 4 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Zender2, 128)
                                    GUICtrlSetState($Ontvanger2, 128)
                                    GUICtrlSetState($GeldStatus2, 128)
                                    GUICtrlSetState($Radio6, 128)
                                    $Spelend2 = 0
                                    If $Spelend1 = 1 Then ;Hier checkedt(vinkt) hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio1, 1)
                                        GUICtrlSetState($Radio2, 128)
                                    ElseIf $Spelend3 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio3, 1)
                                        GUICtrlSetState($Radio2, 128)
                                    ElseIf $Spelend4 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio4, 1)
                                        GUICtrlSetState($Radio2, 128)
                                    EndIf
                                    If $Spelend3 = 0 And $Spelend4 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler1 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 And $Spelend4 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler3 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 And $Spelend3 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler4 & "!")
                                        $Einde = True
                                    EndIf
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld2 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox2.3")
                                EndIf
                            Else
                                MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen hoeveel mensen er zijn" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox2.4")
                            EndIf
                    EndIf

        If GUICtrlRead($Radio5) = 1 Then
                $Result = $Geld1 + $GeldErbij
                Global $Geld1 = $Result
        ElseIf GUICtrlRead($Radio6) = 1 Then
                $Result = $Geld2 + $GeldErbij
                Global $Geld2 = $Result
        ElseIf IsDeclared("Speler3") = Not 0 And GUICtrlRead($Radio7) = 1 Then
                $Result = $Geld3 + $GeldErbij
                Global $Geld3 = $Result
        ElseIf IsDeclared("Speler4") = Not 0 And GUICtrlRead($Radio8) = 1 Then
                $Result = $Geld4 + $GeldErbij
                Global $Geld4 = $Result
        Else
            MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen welke radioknop is geselecteerd" & @CRLF & "bij een van de secties bij het toevoegen van het bedrag." & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox2.5")
        EndIf




    ElseIf GUICtrlRead($Radio3) = 1 Then
        $Result = $Geld3 - $GeldErbij
            $PreTransfer = $Geld3
        Global $Geld3 = $Result ;===> Berekent de transactie
                    $Failliet = 0 ;Nodig bij het bepalen of iemand failliet is (Begint bij de volgende regel)
                    If $Geld3 < 0 Then
                        $Schulden3 = True
                        $GeldErbij = $PreTransfer ;Zorgt ervoor dat bij het overmaken aan de ander (zie beneden deze if's), dat de debtor alleen het geld krijgt die de schuldige ook echt heeft
                        $Failliet = MsgBox(4, "Failliet", $Speler3 & " staat op dit moment in het rood." & @CRLF & "Wil je deze speler failliet verklaren?" & @CRLF & "(Als je op nee drukt, wordt het balans van " & $Speler3 & " teruggezet naar 0.")
                            If $Spelers = 3 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Zender3, 128)
                                    GUICtrlSetState($Ontvanger3, 128)
                                    GUICtrlSetState($GeldStatus3, 128)
                                    GUICtrlSetState($Radio7, 128)
                                    $Spelend3 = 0
                                    If $Spelend1 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio1, 1)
                                        GUICtrlSetState($Radio3, 128)
                                    ElseIf $Spelend2 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio2, 1)
                                        GUICtrlSetState($Radio3, 128)
                                    EndIf
                                    If $Spelend2 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler1 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler2 & "!")
                                        $Einde = True
                                    EndIf
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld3 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox3.1")
                                EndIf

                            ElseIf $Spelers = 4 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Zender3, 128)
                                    GUICtrlSetState($Ontvanger3, 128)
                                    GUICtrlSetState($GeldStatus3, 128)
                                    GUICtrlSetState($Radio7, 128)
                                    $Spelend3 = 0
                                    If $Spelend4 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio4, 1)
                                        GUICtrlSetState($Radio3, 128)
                                    ElseIf $Spelend2 = 1 Then ;Hier checkedt hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio2, 1)
                                        GUICtrlSetState($Radio3, 128)
                                    ElseIf $Spelend1 = 1 Then ;Hier checkedt(vinkt) hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio1, 1)
                                        GUICtrlSetState($Radio3, 128)
                                    EndIf
                                    If $Spelend2 = 0 And $Spelend4 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler1 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 And $Spelend4 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler2 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 And $Spelend2 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler4 & "!")
                                        $Einde = True
                                    EndIf
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld3 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox3.2")
                                EndIf
                            Else
                                MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen hoeveel mensen er zijn" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox3.3")
                            EndIf
                    EndIf

        If GUICtrlRead($Radio5) = 1 Then
                $Result = $Geld1 + $GeldErbij
                Global $Geld1 = $Result
        ElseIf GUICtrlRead($Radio6) = 1 Then
                $Result = $Geld2 + $GeldErbij
                Global $Geld2 = $Result
        ElseIf IsDeclared("Speler3") = Not 0 And GUICtrlRead($Radio7) = 1 Then
                $Result = $Geld3 + $GeldErbij
                Global $Geld3 = $Result
        ElseIf IsDeclared("Speler4") = Not 0 And GUICtrlRead($Radio8) = 1 Then
                $Result = $Geld4 + $GeldErbij
                Global $Geld4 = $Result
        Else
            MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen welke radioknop is geselecteerd" & @CRLF & "bij een van de secties bij het toevoegen van het bedrag." & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox3.4")
        EndIf




    ElseIf GUICtrlRead($Radio4) = 1 Then
        $Result = $Geld4 - $GeldErbij
            $PreTransfer = $Geld4
        Global $Geld4 = $Result ;===> Berekent de transactie
                    $Failliet = 0 ;Nodig bij het bepalen of iemand failliet is (Begint bij de volgende regel)
                    If $Geld4 < 0 Then
                        $Schulden4 = True
                        $GeldErbij = $PreTransfer ;Zorgt ervoor dat bij het overmaken aan de ander (zie beneden deze if's), dat de debtor alleen het geld krijgt die de schuldige ook echt heeft
                        $Failliet = MsgBox(4, "Failliet", $Speler4 & " staat op dit moment in het rood." & @CRLF & "Wil je deze speler failliet verklaren?" & @CRLF & "(Als je op nee drukt, wordt het balans van " & $Speler4 & " teruggezet naar 0.")
                            If $Spelers = 4 Then
                                If $Failliet = 6 Then ;Als de speler op ja drukte bij vorige MsgBox
                                    GUICtrlSetState($Zender4, 128)
                                    GUICtrlSetState($Ontvanger4, 128)
                                    GUICtrlSetState($GeldStatus4, 128)
                                    GUICtrlSetState($Radio8, 128)
                                    $Spelend4 = 0
                                    If $Spelend3 = 1 Then ;Hier checked hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio3, 1)
                                        GUICtrlSetState($Radio4, 128)
                                    ElseIf $Spelend2 = 1 Then ;Hier checked hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio2, 1)
                                        GUICtrlSetState($Radio4, 128)
                                    ElseIf $Spelend1 = 1 Then ;Hier checked(vinkt) hij de Radio die nog overblijft
                                        GUICtrlSetState($Radio1, 1)
                                        GUICtrlSetState($Radio4, 128)
                                    EndIf
                                    If $Spelend2 = 0 And $Spelend3 = 0 Then ;Bepaalt de winnaar
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler1 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 And $Spelend3 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler2 & "!")
                                        $Einde = True
                                    ElseIf $Spelend1 = 0 And $Spelend2 = 0 Then
                                        MsgBox(0, "Gefeliciteerd!", "We hebben een winnaar: " & $Speler3 & "!")
                                        $Einde = True
                                    EndIf
                                ElseIf $Failliet = 7 Then ;Als de speler op nee drukte
                                    $Geld4 = 0
                                Else
                                    MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden gelezen welke optie u gekozen heeft" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox4.1")
                                EndIf
                            Else
                                MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen hoeveel mensen er zijn" & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox4.2")
                            EndIf
                    EndIf

        If GUICtrlRead($Radio5) = 1 Then
                $Result = $Geld1 + $GeldErbij
                Global $Geld1 = $Result
        ElseIf GUICtrlRead($Radio6) = 1 Then
                $Result = $Geld2 + $GeldErbij
                Global $Geld2 = $Result
        ElseIf IsDeclared("Speler3") = Not 0 And GUICtrlRead($Radio7) = 1 Then
                $Result = $Geld3 + $GeldErbij
                Global $Geld3 = $Result
        ElseIf IsDeclared("Speler4") = Not 0 And GUICtrlRead($Radio8) = 1 Then
                $Result = $Geld4 + $GeldErbij
                Global $Geld4 = $Result
        Else
            MsgBox(0, "Bug-detector 2000", "Er kon helaas niet worden geladen welke radioknop is geselecteerd" & @CRLF & "bij een van de secties bij het toevoegen van het bedrag." & @CRLF & "Foutcode: " & @error & @CRLF & @CRLF & "Transfer/ErrorMsgBox4.3")
        EndIf

    EndIf

EndFunc   ;===> Berekent hoe de dikke stacks flowen boii

You guys can collapse everything except for Hoofdmenu(). Yes, I'm Dutch but I have bilingual school, so you guys don't have to worry about it.

The codes I shared earlier are at line 178, and line 421 in my whole script. ($SpelersOver is short for Players which are still playing, and Spelers means Players.) And note that this isn't game automatation. This is just replacing the digital bank for Monopoly, which you have to buy. Also, you don't have to use the banknotes anymore.

 

I understand where Francesco is going, but I don't understand the part where you have to use WM_COMMAND. Is it still relevant after I send my whole script?

Edited by Silas
Edit 1: Error in code. Edit 2: removed a lot of obsolete things in the first script
Link to post
Share on other sites

@Silas
Little modification to your script:

Spoiler
#include <ButtonConstants.au3> ;===========Includers
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>

$WBreedte = 306 ;width
$WHoogte = 165 ;height
Global $Window = GUICreate("MonoBank - Start", $WBreedte, $WHoogte, @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $GUI_SS_DEFAULT_GUI)
GUISetFont(12, 400, 0, "Arial")
GUISetState(@SW_SHOW) ;==== I only added this old window so that the following codes still work


$Spelers=2
$Speler1=1
$Speler2=1
$Geld1=1500
$Geld2=1500 ;== Variables used later in this script
Global $WhileH = 1 ;(Part of bigger thing in the whole script)
Global $SpelersOver = 2

    #Region ;Al het toevoegen (all the creating of the GUI)
    Global $Startbedrag = 1500
    Global $Einde = False
            $WBreedte =508
            $WHoogte = 360
            $X_Undo = 218
            $X_Input = 271
            $X_Transfer = 418
                Global $Spelend1 = 1
                Global $Spelend2 = 1

    WinMove($Window, "", @DesktopWidth / 2 - ($WBreedte / 2), @DesktopHeight / 2 - ($WHoogte / 2), $WBreedte, $WHoogte)
        Global $Zender1 = GUICtrlCreateLabel($Speler1, 222, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x4286f4)
        Global $Zender2 = GUICtrlCreateLabel($Speler2, 360, 52, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xea3838)
        Global $GeldStatus1 = GUICtrlCreateLabel("?" & $Geld1, 222, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        Global $GeldStatus2 = GUICtrlCreateLabel("?" & $Geld2, 360, 18, 105, 31, $SS_CENTER)
            GUICtrlSetFont(-1, 18, 400, 0, "Arial")
        Global $Ontvanger1 = GUICtrlCreateLabel($Speler1, 222, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0x4286f4)
        Global $Ontvanger2 = GUICtrlCreateLabel($Speler2, 360, 241, 105, 36, BitOR($WS_GROUP, $SS_CENTER))
            GUICtrlSetFont(-1, 20, 400, 0, "Arial")
            GUICtrlSetColor(-1, 0xea3838)

    GUIStartGroup()
        Global $Radio1 = GUICtrlCreateRadio("", 266, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        Global $Radio2 = GUICtrlCreateRadio("", 404, 99, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)

    GUIStartGroup()
        Global $Radio5 = GUICtrlCreateRadio("", 266, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)
        Global $Radio6 = GUICtrlCreateRadio("", 404, 288, 21, 21, BitOR($BS_AUTORADIOBUTTON,$BS_TOP))
            GUICtrlSetCursor (-1, 0)

        Global $Input = GUICtrlCreateInput("", $X_Input, 153, 144, 50, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER,$WS_GROUP))
            GUICtrlSetFont(-1, 28, 400, 0, "Arial")
            GUICtrlSetCursor (-1, 5)
            GUICtrlSetLimit(-1, 6)

        Global $Button_Transfer = GUICtrlCreateButton("OK", $X_Transfer, 153, 50, 50, BitOR($WS_GROUP, $BS_DEFPUSHBUTTON))
            GUICtrlSetCursor(-1, 0)
        Global $Button_Undo = GUICtrlCreateButton("<", $X_Undo, 153, 50, 50, $WS_GROUP)
            GUICtrlSetCursor(-1, 0)
#EndRegion (creating GUI)

    While $WhileH
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Transfer
                If GUICtrlRead($Input)= Not "" And $Einde = False Then
                    ;Transfer()
                EndIf
            Case $Radio1
                GUICtrlSetState($Radio6, 1)

            Case $Radio2
                GUICtrlSetState($Radio5, 1)

            Case $Radio5
                GUICtrlSetState($Radio2, 1)

            Case $Radio6
                GUICtrlSetState($Radio1, 1)
;           Case $Button_Undo
;               Sumsing
            ;Case $Button_Return
            ;   MsgBox(4, "Waarschuwing", "Als je teruggaat, verlies je alle voortgang en krijgt iedereen weer het standaard bedrag." & @CRLF & "Wil je doorgaan?") ;Warning box. About losing progress
            ;   Start()

        EndSwitch

;~     If $SpelersOver=2 Then
;~         If $Spelers=2 Then
;~             If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio6),1) And Not BitAND(GUICtrlGetState($Radio5),1) And Not BitAND(GUICtrlGetState($Radio2),1) Then GUICtrlSetState($Radio6,1)
;~             If GUICtrlRead($Radio2)=1 And Not BitAND(GUICtrlGetState($Radio5),1) And Not BitAND(GUICtrlGetState($Radio6),1) And Not BitAND(GUICtrlGetState($Radio1),1) Then GUICtrlSetState($Radio5,1)
;~             If GUICtrlRead($Radio5)=1 And Not BitAND(GUICtrlGetState($Radio2),1) And Not BitAND(GUICtrlGetState($Radio1),1) And Not BitAND(GUICtrlGetState($Radio6),1) Then GUICtrlSetState($Radio2,1)
;~             If GUICtrlRead($Radio6)=1 And Not BitAND(GUICtrlGetState($Radio1),1) And Not BitAND(GUICtrlGetState($Radio2),1) And Not BitAND(GUICtrlGetState($Radio5),1) Then GUICtrlSetState($Radio1,1)
;~         EndIf
;~     EndIf

    WEnd

 

 

1 hour ago, Silas said:

I understand where Francesco is going, but I don't understand the part where you have to use WM_COMMAND. Is it still relevant after I send my whole script?

Through a WM_COMMAND handler, you can do it only when a specific event occurs, like $BN_CLICKED, which is fired when you click on a radio button ( in this example ).
So, I think that would be easier to do it via WM_COMMAND instead of doing in an infinite While...WEnd loop :)
But there you are with your little script modification ;)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites

@FrancescoDiMuro

Isn't your solution good enough ? clear, simple, handy, nice-looking and so on ?

1 hour ago, FrancescoDiMuro said:

I think that would be easier to do it via WM_COMMAND

I don't really agree (in this case)... 2 reasons :
- WM_COMMAND can cause trouble if wrongly used, and can hide inappropriate instructions existing in the main While loop because of its higher priority
- much better to learn and understand the basics first  :)
For instance, how to fire events using commands only, and how to avoid as much as possible continuous checkings in the main While loop, which are resources consuming and can cause bugs

 

Link to post
Share on other sites

Hi, I would do it this way:

While $WhileH
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Transfer
                If GUICtrlRead($Input)= Not "" And $Einde = False Then
                    ;Transfer()
                EndIf
;           Case $Button_Undo
;               Sumsing
            ;Case $Button_Return
            ;   MsgBox(4, "Waarschuwing", "Als je teruggaat, verlies je alle voortgang en krijgt iedereen weer het standaard bedrag." & @CRLF & "Wil je doorgaan?") ;Warning box. About losing progress
            ;   Start()
            Case $Radio1
                GUICtrlSetState($Radio6,1)
            Case $Radio2
                GUICtrlSetState($Radio5,1)
            Case $Radio5
                GUICtrlSetState($Radio2,1)
            Case $Radio6
                GUICtrlSetState($Radio1,1)

        EndSwitch

;~     If $SpelersOver=2 Then
;~         If $Spelers=2 Then
;~             If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio6),1) And Not BitAND(GUICtrlGetState($Radio5),1) Then GUICtrlSetState($Radio6,1)
;~             If GUICtrlRead($Radio2)=1 And Not BitAND(GUICtrlGetState($Radio5),1) And Not BitAND(GUICtrlGetState($Radio6),1) Then GUICtrlSetState($Radio5,1)
;~             If GUICtrlRead($Radio5)=1 And Not BitAND(GUICtrlGetState($Radio2),1) And Not BitAND(GUICtrlGetState($Radio1),1) Then GUICtrlSetState($Radio2,1)
;~             If GUICtrlRead($Radio6)=1 And Not BitAND(GUICtrlGetState($Radio1),1) And Not BitAND(GUICtrlGetState($Radio2),1) Then GUICtrlSetState($Radio1,1)
;~         EndIf
;~     EndIf

    WEnd

Because they are grouped you have to set only one of the opposite site and the other is disabled automatically.

Regards, Simpel

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to post
Share on other sites
31 minutes ago, mikell said:

Isn't your solution good enough ? clear, simple, handy, nice-looking and so on ?

At which solution are you referring? :D
By the way, I agree with your opinion, but I thought that a mention to such a powerful tool ( WM_* handlers ) was a must.
It's like StringRegExp(): it's a powerful tool, but an incorrect pattern will give you strange results :lmao:

35 minutes ago, mikell said:

For instance, how to fire events using commands only, and how to avoid as much as possible continuous checkings in the main While loop, which are resources consuming and can cause bugs

I don't think I completely understood you, sorry :)

Cheers :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites

Hi @FrancescoDiMuro,

I didn't saw that, maybe because of "reveal hidden contents" or because the discussion about "WM_COMMAND ". ;-)

But if two persons found the exact same solution independently there must be some good at it.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndyS19
      I created 3 radio buttons and when the script is run, the selected buttons display the text on the right of the actual button.  Also, it appears like the radio button occupies space around it, as it obscures part of the other controls when I hover the mouse around it.  I would like to group the buttons closer together and put other controls on the right of them.  I also wanted to make the button text display on the left side of the button.
      Here is my test code:
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("ExitStageLeft") Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GuiCtrlRead tab index _Main() Func _Main() GUICreate("test", 300, 300, -1, -1, -1, -1) GUIStartGroup() local $x = 50, $y = 10, $w = 40, $h = 15,$spcY = 15 GUICtrlCreateRadio("", $x, $y, $w, $h) GUICtrlCreateRadio("ABC", $x, $y + ($spcY*1), $w, $h) GUICtrlCreateRadio("", $x, $y + ($spcY*2), $w, $h) GUIStartGroup() GUICtrlCreateInput("An Input Control", 70, 10, 110, 30) GUICtrlCreateInput("Another Input Control", 10, 73, 110, 20) GUISetOnEvent(-3, 'ExitStageLeft') GUISetState(@SW_SHOW) While (1) Sleep(251) WEnd EndFunc Func ExitStageLeft() Exit EndFunc I want "ABC" to display on the left of the 2nd radio button.
       

    • By Jibberish
      Hi,
      I am maybe an intermediate AutoIt script writer, but have no experience creating GUIs.
      I have a script with two functions. One for Checkboxes and another with radio buttons. Each function creates it's own window.
      I'd like to use one window with both checkboxes and radio buttons.
      I pulled samples from AutoIt Help and other places and worked it into this: (RadioCheck still uses the example Case and MsgBoxes. I will clean this up soon)
      Func CheckOptions() ; Create a GUI with various controls. Local $hGUI = GUICreate("SGX4CP Options", 275, 250) ; Create a checkbox control. Local $iLoopCheckbox = GUICtrlCreateCheckbox("Loop", 10, 10, 185, 25) Local $iFullScreenCheckbox = GUICtrlCreateCheckbox("Fullscreen", 10, 40, 185, 25) Local $iRestartPlaybackCheckbox = GUICtrlCreateCheckbox("Restart Playback from Sleep", 10, 70, 185, 25) GUICtrlSetState($iRestartPlaybackCheckbox, $GUI_CHECKED) Local $iDisableSleepCheckbox = GUICtrlCreateCheckbox("Disable Sleep", 10, 100, 185, 25) Local $iLogCheckbox = GUICtrlCreateCheckbox("Show Log", 10, 130, 185, 25) GUICtrlSetState($iLogCheckbox, $GUI_CHECKED) Local $idClose = GUICtrlCreateButton("Next", 110, 220, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $iLoopCheckbox If _IsChecked($iLoopCheckbox) Then $bLoopChecked = True Else $bLoopChecked = False EndIf Case $iFullScreenCheckbox if _IsChecked($iFullScreenCheckbox) Then $bFullScreenChecked = True Else $bFullScreenChecked = False EndIf Case $iRestartPlaybackCheckbox if _IsChecked($iRestartPlaybackCheckbox) Then $bRestartPlaybackChecked = True Else $bRestartPlaybackChecked = False EndIf Case $iDisableSleepCheckbox if _IsChecked($iDisableSleepCheckbox) Then $bDisableSleepChecked = True Else $bDisableSleepChecked = False EndIf Case $iLogCheckbox if _IsChecked($iLogCheckbox) Then $bLogChecked = True Else $bLogChecked = False EndIf EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc Func RadioCheck() GUICreate("Select Test",300,180) ; will create a dialog box that when displayed is centered Local $idRadio1 = GUICtrlCreateRadio("Loop Forever", 10, 10) Local $idRadio2 = GUICtrlCreateRadio("Play each video 3 times", 10, 40) Local $idRadio3 = GUICtrlCreateRadio("Play each video separately", 10, 70) GUICtrlSetState($idRadio1, $GUI_CHECKED) Local $idClose = GUICtrlCreateButton("Start Test", 120,100) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE ExitLoop Case $idMsg = $idRadio1 And BitAND(GUICtrlRead($idRadio1), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'The app will run forever, playing each video once, then looping back to the first video.') $bTestSelectForever = True Case $idMsg = $idRadio2 And BitAND(GUICtrlRead($idRadio2), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'Each video will loop 3 times then move to the next video.') $bTestSelect3Times = True Case $idMsg = $idRadio3 And BitAND(GUICtrlRead($idRadio2), $GUI_CHECKED) = $GUI_CHECKED MsgBox($MB_SYSTEMMODAL, 'Info:', 'Player opens, first video plays, player closes. Player opens, second video plays, player closes, etc.') $bTestSelectSingleVideo = True EndSelect WEnd EndFunc I would like to combine the checkbox "Loop" and the radio button $idRadio2. Radio2 requires Loop to be checked.
      I planned to remove the Loop checkbox and only enable it if Radio2 is selected.
      Can I combine these two functions into one with one window with both Checkboxes and Radio Buttons?
      Thanks
      Jibberish
    • By ur
      I have below screen when I launch the application.

      By default the first radio button is checked.
      I want to select the second radio button as highlighted.
      And when it is selected, the textbox highlighted will be enabled and we need to enter the license details.
       
      To do that, I tried to get the control id with windo info tool , but I am getting the second section(Concurrent Licenses) completely as "Button" class with ID 12.But not that radiobutton ID.
      Even I tried with that as below.
      $hwd =WinWaitActivate("erwin Data Modeler Licensing","Acquire concurrent u") ControlCommand($hwd,"","[CLASS:Button; INSTANCE:12]","Check") But not working.
      Any suggestions please.
    • By Synapsee
      AutoIt Radio Player
      Last : v0.0.0.8
      Tested only on W7X64

      Changelog :
      ==========>  AutoIt Radio Player v0.0.0.8.zip <==========
      Personal Message :
           This is my first script posted. Any comment are welcome. Give me your best web radio i will try add them !
      Install/Use :
      Add a station :
      Unsolved problem :
            When the coverGUI go outside the monitor and comeback inside, a part of current cover disapear : I have no idea how fix that
          
      TODO :
           Make coverGUI mouse resizable (while script running) : any idea are welcome
           Crop some pixel of cover : any idea are welcome
      Related Posts/Bin :
      ArrayMultiColSort MouseWheelDelta Sample1 MouseWheelDelta Sample2 ContextMenu Fix ReduceMemory MemGlobalAllocFromBinary Curl.au3 (AutoIt binary code) Main Code :
      ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7;All Warning ;-w 5 = local var declared but not used : Removed for Curl.au3 ;-d = as Opt("MustDeclareVars", 1) : Removed for Bass.au3 #AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w- 4 -w 6 -w- 7 #Region ;==> #include #include <Array.au3>;_ArrayAdd #include <GuiButton.au3>;_GUICtrlButton_SetImage() #include <GuiMenu.au3>;$MNS_MODELESS #include <GUIConstants.au3>;$WS_POPUP #include <GDIplus.au3>;_GDIPlus_BitmapCreateFromStream() #include <Memory.au3>;$GMEM_MOVEABLE #include <String.au3>;_StringBetween() #include <AutoIt Radio Player\include\Bass.au3>;_BASS_ChannelPlay() #include <AutoIt Radio Player\include\BassConstants.au3>;$BASS_CONFIG_NET_PLAYLIST #include <AutoIt Radio Player\include\Curl.au3>;Curl_Data_Get() #EndRegion ;==> #include #Region ;==> Func for Bass.au3 Local $MusicHandle Func _Audio_play($MusicHandle) _BASS_ChannelPlay($MusicHandle, 1) EndFunc Func _Audio_stop($MusicHandle) _BASS_ChannelStop($MusicHandle) EndFunc Func _Audio_init_stop($MusicHandle) _BASS_StreamFree($MusicHandle) _BASS_Free() EndFunc Func _Audio_init_start() If _BASS_STARTUP(@ScriptDir & "\AutoIt Radio Player\include\bass.dll") Then If _BASS_Init(0, -1, 44100, 0) Then If _BASS_SetConfig($BASS_CONFIG_NET_PLAYLIST, 1) = 0 Then SetError(3) EndIf Else SetError(2) EndIf Else SetError(@error) EndIf EndFunc Func _Set_volume($volume) _BASS_SetConfig($BASS_CONFIG_GVOL_STREAM, $volume * 100) EndFunc Func _Set_url($file) If FileExists($file) Then $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0) Else $MusicHandle = _BASS_StreamCreateURL($file, 0, 1) EndIf If @error Then Return SetError(1) EndIf Return $MusicHandle EndFunc #EndRegion ;==> Func for Bass.au3 Global Const $SC_DRAGMOVE = 0xF012;Global #Region ;==> Func from AutoIt Forum ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayMultiColSort ; Description ...: Sort 2D arrays on several columns ; Syntax.........: _ArrayMultiColSort(ByRef $aArray, $aSortData[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $aArray - The 2D array to be sorted ; $aSortData - 2D array holding details of the sort format ; Format: [Column to be sorted, Sort order] ; Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items ; Any elements not matched in string are left unsorted after all sorted elements ; $iStart - Element of array at which sort starts (default = 0) ; $iEnd - Element of array at which sort endd (default = 0 - converted to end of array) ; Requirement(s).: v3.3.8.1 or higher ; Return values .: Success: No error ; Failure: @error set as follows ; @error = 1 with @extended set as follows (all refer to $sIn_Date): ; 1 = Array to be sorted not 2D ; 2 = Sort data array not 2D ; 3 = More data rows in $aSortData than columns in $aArray ; 4 = Start beyond end of array ; 5 = Start beyond End ; @error = 2 with @extended set as follows: ; 1 = Invalid string parameter in $aSortData ; 2 = Invalid sort direction parameter in $aSortData ; Author ........: Melba23 ; Remarks .......: Columns can be sorted in any order ; Example .......; Yes ; =============================================================================================================================== Func _ArrayMultiColSort(ByRef $aArray, $aSortData, $iStart = 0, $iEnd = 0) ; Errorchecking ; 2D array to be sorted If UBound($aArray, 2) = 0 Then Return SetError(1, 1, "") EndIf ; 2D sort data If UBound($aSortData, 2) <> 2 Then Return SetError(1, 2, "") EndIf If UBound($aSortData) > UBound($aArray) Then Return SetError(1, 3) EndIf ; Start element If $iStart < 0 Then $iStart = 0 EndIf If $iStart >= UBound($aArray) - 1 Then Return SetError(1, 4, "") EndIf ; End element If $iEnd <= 0 Or $iEnd >= UBound($aArray) - 1 Then $iEnd = UBound($aArray) - 1 EndIf ; Sanity check If $iEnd <= $iStart Then Return SetError(1, 5, "") EndIf Local $iCurrCol, $iChunk_Start, $iMatchCol ; Sort first column __AMCS_SortChunk($aArray, $aSortData, 0, $aSortData[0][0], $iStart, $iEnd) If @error Then Return SetError(2, @extended, "") EndIf ; Now sort within other columns For $iSortData_Row = 1 To UBound($aSortData) - 1 ; Determine column to sort $iCurrCol = $aSortData[$iSortData_Row][0] ; Create arrays to hold data from previous columns Local $aBaseValue[$iSortData_Row] ; Set base values For $i = 0 To $iSortData_Row - 1 $aBaseValue[$i] = $aArray[$iStart][$aSortData[$i][0]] Next ; Set start of this chunk $iChunk_Start = $iStart ; Now work down through array For $iRow = $iStart + 1 To $iEnd ; Match each column For $k = 0 To $iSortData_Row - 1 $iMatchCol = $aSortData[$k][0] ; See if value in each has changed If $aArray[$iRow][$iMatchCol] <> $aBaseValue[$k] Then ; If so and row has advanced If $iChunk_Start < $iRow - 1 Then ; Sort this chunk __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf ; Set new base value $aBaseValue[$k] = $aArray[$iRow][$iMatchCol] ; Set new chunk start $iChunk_Start = $iRow EndIf Next Next ; Sort final section If $iChunk_Start < $iRow - 1 Then __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf Next EndFunc ;==>_ArrayMultiColSort ; #FUNCTION# ==================================================================================================================== ; Name...........: __AMCS_SortChunk ; Description ...: Sorts array section ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func __AMCS_SortChunk(ByRef $aArray, $aSortData, $iRow, $iColumn, $iChunkStart, $iChunkEnd) Local $aSortOrder ; Set default sort direction Local $iSortDirn = 1 ; Need to prefix elements? If IsString($aSortData[$iRow][1]) Then ; Split elements $aSortOrder = StringSplit($aSortData[$iRow][1], ",") If @error Then Return SetError(1, 1, "") EndIf ; Add prefix to each element For $i = $iChunkStart To $iChunkEnd For $j = 1 To $aSortOrder[0] If $aArray[$i][$iColumn] = $aSortOrder[$j] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] ExitLoop EndIf Next ; Deal with anything that does not match If $j > $aSortOrder[0] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] EndIf Next Else Switch $aSortData[$iRow][1] Case 0, 1 ; Set required sort direction if no list If $aSortData[$iRow][1] Then $iSortDirn = -1 Else $iSortDirn = 1 EndIf Case Else Return SetError(1, 2, "") EndSwitch EndIf ; Sort the chunk Local $iSubMax = UBound($aArray, 2) - 1 __ArrayQuickSort2D($aArray, $iSortDirn, $iChunkStart, $iChunkEnd, $iColumn, $iSubMax) ; Remove any prefixes If IsString($aSortData[$iRow][1]) Then For $i = $iChunkStart To $iChunkEnd $aArray[$i][$iColumn] = StringTrimLeft($aArray[$i][$iColumn], 3) Next EndIf EndFunc ;==>__AMCS_SortChunk Func _ReduceMemory() Local $aReturn = DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1) If @error = 1 Then Return SetError(1, 0, 0) EndIf Return $aReturn[0] EndFunc ;==>_ReduceMemory ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_ImageLoadFromHGlobal ; Description ...: Creates an Image object based on movable HGlobal memory block ; Syntax.........: _GDIPlus_ImageLoadFromHGlobal($hGlobal) ; Parameters ....: $hGlobal - Handle of a movable HGlobal memory block ; Return values .: Success - Pointer to a new Image object ; Failure - 0 and either: ; |@error and @extended are set if DllCall failed: ; | -@error = 1 if could not create IStream ; | -@error = 2 if DLLCall to create image failed ; |$GDIP_STATUS contains a non zero value specifying the error code ; Author ........: ProgAndy ; Modified.......: ; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources. ; The HGLOBAL will be owned by the image and freed automatically when the image is disposed. ; Related .......: _GDIPlus_ImageLoadFromStream, _GDIPlus_ImageDispose ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GDIPlus_ImageLoadFromHGlobal($hGlobal) Local $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $hGlobal, "bool", True, "ptr*", 0) If @error Or $aResult[0] <> 0 Or $aResult[3] = 0 Then Return SetError(1, @error, 0) Local $hImage = DllCall($__g_hGDIPDll, "uint", "GdipLoadImageFromStream", "ptr", $aResult[3], "int*", 0) Local $error = @error Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $aResult[3], "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) If $error Then Return SetError(2, $error, 0) If $hImage[2] = 0 Then Return SetError(3, 0, $hImage[2]) Return $hImage[2] EndFunc ;==>_GDIPlus_ImageLoadFromHGlobal ; #FUNCTION# ==================================================================================================================== ; Name...........: _MemGlobalAllocFromBinary ; Description ...: Greates a movable HGLOBAL memory block from binary data ; Syntax.........: _MemGlobalAllocFromBinary($bBinary) ; Parameters ....: $bBinary - Binary data ; Return values .: Success - Handle of a new movable HGLOBAL ; Failure - 0 and set @error: ; |1 - no data ; |2 - could not allocate memory ; |3 - could not set data to memory ; Author ........: ProgAndy ; Modified.......: ; Remarks .......: ; Related .......: _MemGlobalAlloc, _MemGlobalFree, _MemGlobalLock ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _MemGlobalAllocFromBinary(Const $bBinary) Local $iLen = BinaryLen($bBinary) If $iLen = 0 Then Return SetError(1, 0, 0) Local $hMem = _MemGlobalAlloc($iLen, $GMEM_MOVEABLE) If @error Or Not $hMem Then Return SetError(2, 0, 0) DllStructSetData(DllStructCreate("byte[" & $iLen & "]", _MemGlobalLock($hMem)), 1, $bBinary) If @error Then _MemGlobalUnlock($hMem) _MemGlobalFree($hMem) Return SetError(3, 0, 0) EndIf _MemGlobalUnlock($hMem) Return $hMem EndFunc ;==>_MemGlobalAllocFromBinary #EndRegion ;==> Func from AutoIt Forum ;INI Location Local $Config_INI = "AutoIt Radio Player\Config.ini" Local $Save_INI = "AutoIt Radio Player\Save.ini" ;Get $aRadio and $aLabel <===========================================That part need improve Local $aINISections = IniReadSectionNames($Config_INI) Local $aRadio[0][8] Local $aLabel[0][11] For $i = 1 To UBound($aINISections) - 1 If $aINISections[$i] <> "GUI" Then ;For $aRadio Local $SoundLink = "", $CoverLink = "", $CoverLinkStart = "", $CoverLinkEnd = "", $CoverLinkBetweenNum = "", $CoverLinkBefore = "", $Default = 0 ;For $aLabel Local $CurrentArtistLink = "", $CurrentArtistStart = "", $CurrentArtistEnd = "", $CurrentArtistBetweenNum = 0, $CurrentArtistSplit = "", $CurrentArtistNumSplit = "" Local $CurrentAlbumLink = "", $CurrentAlbumStart = "", $CurrentAlbumEnd = "", $CurrentAlbumBetweenNum = 0, $CurrentAlbumSplit = "", $CurrentAlbumNumSplit = "" Local $CurrentTitleLink = "", $CurrentTitleStart = "", $CurrentTitleEnd = "", $CurrentTitleBetweenNum = 0, $CurrentTitleSplit = "", $CurrentTitleNumSplit = "" Local $NextArtistLink = "", $NextArtistStart = "", $NextArtistEnd = "", $NextArtistBetweenNum = 0, $NextArtistSplit = "", $NextArtistNumSplit = "" Local $NextAlbumLink = "", $NextAlbumStart = "", $NextAlbumEnd = "", $NextAlbumBetweenNum = 0, $NextAlbumSplit = "", $NextAlbumNumSplit = "" Local $NextTitleLink = "", $NextTitleStart = "", $NextTitleEnd = "", $NextTitleBetweenNum = 0, $NextTitleSplit = "", $NextTitleNumSplit = "" Local $ListenersCountLink = "", $ListenersCountStart = "", $ListenersCountEnd = "", $ListenersCountBetweenNum = 0, $ListenersCountSplit = "", $ListenersCountNumSplit = "" Local $controlID1 = "", $controlID2 = "" Local $Sec = IniReadSection($Config_INI, $aINISections[$i]) For $y = 1 To UBound($Sec) - 1 Assign($Sec[$y][0], $Sec[$y][1]) Next ;$aRadio _ArrayAdd($aRadio, $aINISections[$i] & "|" & $SoundLink & "|" & $CoverLink & "|" & $CoverLinkStart & "|" & $CoverLinkEnd & "|" & $CoverLinkBetweenNum & "|" & $CoverLinkBefore & "|" & $Default) ;$aLabel _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Artist" & "|" & $CurrentArtistLink & "|" & $CurrentArtistStart & "|" & $CurrentArtistEnd & "|" & $CurrentArtistBetweenNum & "|" & $CurrentArtistSplit & "|" & $CurrentArtistNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Album" & "|" & $CurrentAlbumLink & "|" & $CurrentAlbumStart & "|" & $CurrentAlbumEnd & "|" & $CurrentAlbumBetweenNum & "|" & $CurrentAlbumSplit & "|" & $CurrentAlbumNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Title" & "|" & $CurrentTitleLink & "|" & $CurrentTitleStart & "|" & $CurrentTitleEnd & "|" & $CurrentTitleBetweenNum & "|" & $CurrentTitleSplit & "|" & $CurrentTitleNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Artist" & "|" & $NextArtistLink & "|" & $NextArtistStart & "|" & $NextArtistEnd & "|" & $NextArtistBetweenNum & "|" & $NextArtistSplit & "|" & $NextArtistNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Album" & "|" & $NextAlbumLink & "|" & $NextAlbumStart & "|" & $NextAlbumEnd & "|" & $NextAlbumBetweenNum & "|" & $NextAlbumSplit & "|" & $NextAlbumNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Title" & "|" & $NextTitleLink & "|" & $NextTitleStart & "|" & $NextTitleEnd & "|" & $NextTitleBetweenNum & "|" & $NextTitleSplit & "|" & $NextTitleNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Listeners" & "|" & "Count" & "|" & $ListenersCountLink & "|" & $ListenersCountStart & "|" & $ListenersCountEnd & "|" & $ListenersCountBetweenNum & "|" & $ListenersCountSplit & "|" & $ListenersCountNumSplit & "|" & $controlID1 & "|" & $controlID2) EndIf Next Global $aRadio_Sort[][] = [[0, 0], [1, 0]] _ArrayMultiColSort($aRadio, $aRadio_Sort) Local $aLabel2[0][11] For $i = 0 To UBound($aLabel) - 1 If $aLabel[$i][3] <> "" Then Local $fill = $aLabel[$i][0] For $y = 1 To UBound($aLabel, 2) - 1 $fill = $fill & "|" & $aLabel[$i][$y] Next _ArrayAdd($aLabel2, $fill) EndIf Next $aLabel = $aLabel2 ;_ArrayDisplay($aRadio) ;_ArrayDisplay($aLabel) ;Init/Opt Opt("GUIOnEventMode", 1) _Audio_init_start() _GDIPlus_Startup() ;Icon Local $IcoFile = @ScriptDir & "\AutoIt Radio Player\img\icon.ico" Local $IcoNumber = -1 TraySetIcon($IcoFile, $IcoNumber) ;Get Default Station Local $def_selected = 0 For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][0] = IniRead($Save_INI, @ComputerName, "Default_Radio", "default") Then $def_selected = 1 $aRadio[$r][7] = 1 EndIf Next If $def_selected = 0 Then $aRadio[0][7] = 1 EndIf ;ConsoleWrite("Start" & @CRLF) ;Get $Radio_Name, $Radio_SoundLink, $Radio_CoverLink, $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before Local $Radio_Name, $Radio_SoundLink, $Radio_CoverLink Local $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 1 Then $Radio_Name = $aRadio[$r][0] $Radio_SoundLink = $aRadio[$r][1] $Radio_CoverLink = $aRadio[$r][2] $Radio_CoverLink_Start = $aRadio[$r][3] $Radio_CoverLink_End = $aRadio[$r][4] $Radio_CoverLink_BetweenNum = $aRadio[$r][5] $Radio_CoverLink_Before = $aRadio[$r][6] EndIf Next ;Declare Local $PlayerGUI, $CoverGUI;GUI Local $PlayPause, $Close;Button Local $Play = 1;PlayStatus ($Play = 1 = Autoplay) Local $Volume_Label, $VolumePercent, $Previous_VolumePercent;Volume Local $Previous_Cover_Read;PreviousRead Local $BASS_ErrorGetCode ;$Config_INI\GUI Local $CoverSize = IniRead($Config_INI, "GUI", "CoverSize", 150) Local $PlayerBorder = IniRead($Config_INI, "GUI", "PlayerBorder", 10) ;ConsoleWrite("Build GUI" & @CRLF) ;Build GUI _Build_PlayerGUI() _Build_CoverGUI() ;ConsoleWrite("Show GUI" & @CRLF) GUISetState(@SW_SHOW, $PlayerGUI) If $Radio_CoverLink <> "" Then GUISetState(@SW_SHOW, $CoverGUI) EndIf _Set_volume(0) ;GetPlayerDATA() - GetCoverDATA() - Start Sound GetPlayerDATA();Start Sound too with resume on disconnect AdlibRegister("GetPlayerDATA", 8000) If $Radio_CoverLink <> "" Then GetCoverDATA() AdlibRegister("GetCoverDATA", 8000) EndIf ;ConsoleWrite("GUIRegisterMsg" & @CRLF) GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL");for set volume GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN");for drag gui #Region ;==> Internal Func Func _Build_CoverGUI() ;ConsoleWrite("Build CoverGUI" & @CRLF) If $Radio_CoverLink <> "" Then $CoverGUI = GUICreate("AutoIt Radio Cover", _;Title $CoverSize, _ ;X $CoverSize, _ ;Y IniRead($Save_INI, @ComputerName, "Cover_X", -1), _;Left IniRead($Save_INI, @ComputerName, "Cover_Y", -1), _;Top $WS_POPUP, $WS_EX_TOPMOST);Style GUISetBkColor(0x000000, $CoverGUI);Black BkColor GUISetIcon($IcoFile, $IcoNumber, $CoverGUI) Else $CoverGUI = "" EndIf EndFunc ;==>_Build_CoverGUI Func _Build_PlayerGUI() ;ConsoleWrite("Build PlayerGUI" & @CRLF) ;Clean previous stored ControlID For $r = 0 To UBound($aLabel) - 1 $aLabel[$r][9] = "" $aLabel[$r][10] = "" Next ;$LabelCount Local $LabelCount = 0 For $r = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$r][0] Then $LabelCount = $LabelCount + 1 EndIf Next ;$LabelY If $LabelCount * 13 + $PlayerBorder * 2 < 50 Then Local $LabelY = 10 * 3 Else $LabelY = $LabelCount * 13 EndIf ;$PlayerGUI $PlayerGUI = GUICreate("AutoIt Radio Player", _ $PlayerBorder + 260 + 50 + 10 + $PlayerBorder * 2, _;X $PlayerBorder + $LabelY + $PlayerBorder, _;Y IniRead($Save_INI, @ComputerName, "Title_X", -1), _;Left IniRead($Save_INI, @ComputerName, "Title_Y", -1), _;Top $WS_POPUP, $WS_EX_TOPMOST);Style GUISetBkColor(0x000000, $PlayerGUI);Black BkColor GUISetIcon($IcoFile, $IcoNumber, $PlayerGUI) ;$Contextmenu Local $ContextMenu = GUICtrlCreateContextMenu(-1) Local $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) Local $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent($ContextMenu_Item1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 0 Then GUICtrlCreateMenuItem($aRadio[$r][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next ;GUICtrlCreateLabel $LabelCount = 0 Local $Previous_Type = "" For $r = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$r][0] Then If $Previous_Type <> $aLabel[$r][1] Then $Previous_Type = $aLabel[$r][1] $aLabel[$r][10] = GUICtrlCreateLabel($aLabel[$r][1], $PlayerBorder, 13 * $LabelCount + $PlayerBorder, 50, 13, $SS_CENTERIMAGE) GUICtrlSetColor($aLabel[$r][10], 0xFFFFFF);White TextColor GUICtrlSetOnEvent($aLabel[$r][10], "_WM_LBUTTONDOWN") $ContextMenu = GUICtrlCreateContextMenu($aLabel[$r][10]) $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r2 = 0 To UBound($aRadio) - 1 If $aRadio[$r2][7] = 0 Then GUICtrlCreateMenuItem($aRadio[$r2][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next EndIf $aLabel[$r][9] = GUICtrlCreateLabel("", $PlayerBorder + 50, 13 * $LabelCount + $PlayerBorder, 260, 13, $SS_CENTERIMAGE) $LabelCount = $LabelCount + 1 GUICtrlSetColor($aLabel[$r][9], 0xFFFFFF);White TextColor GUICtrlSetOnEvent($aLabel[$r][9], "_WM_LBUTTONDOWN") $ContextMenu = GUICtrlCreateContextMenu($aLabel[$r][9]) $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r2 = 0 To UBound($aRadio) - 1 If $aRadio[$r2][7] = 0 Then GUICtrlCreateMenuItem($aRadio[$r2][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next EndIf Next ;GUICtrlCreateLabel Volume $Volume_Label = GUICtrlCreateLabel("0", $PlayerBorder, $PlayerBorder, 260 + 50, $LabelY, "") GUICtrlSetColor($Volume_Label, 0xFFFFFF);White TextColor GUICtrlSetOnEvent($Volume_Label, "_WM_LBUTTONDOWN") GUICtrlSetState($Volume_Label, $GUI_HIDE) ;$Volume_Label Contextmenu $ContextMenu = GUICtrlCreateContextMenu($Volume_Label) $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 0 Then Local $Item = GUICtrlCreateMenuItem($aRadio[$r][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next ;$Close $Close = GUICtrlCreateButton("Close", _ $PlayerBorder * 2 + 260 + 50, _;Left $PlayerBorder, _;Top 10, _;X 10, _;Y $BS_BITMAP);Style _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Close.bmp") GUICtrlSetOnEvent($Close, "_Close") GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "_Close") ;$PlayPause $PlayPause = GUICtrlCreateButton("Play/Pause", _ $PlayerBorder * 2 + 260 + 50, _;Left $PlayerBorder + 10 + 10, _;Top 10, _;X 10, _;Y $BS_BITMAP);Style _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\Stop.bmp") GUICtrlSetOnEvent($PlayPause, "_PlayPause") EndFunc ;==>_Build_PlayerGUI Func _Close() _Audio_init_stop($MusicHandle) _GDIPlus_Shutdown() Exit EndFunc ;==>_Close Func _PlayPause() ;Change $Play If $Play = 1 Then $Play = 0 Else $Play = 1 EndIf Local $Msg = GUIGetCursorInfo($PlayerGUI) ;Change Button Image If $Play = 1 Then If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopp.bmp");Mouse Pressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopo.bmp");Mouse Over EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stop.bmp");Nothing EndIf Else If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playp.bmp");Mouse Pressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playo.bmp");Mouse Over EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\play.bmp");Nothing EndIf EndIf ;Play Sound If $Play = 0 Then _Audio_stop($MusicHandle) Else $MusicHandle = _Set_url($Radio_SoundLink) _Audio_play($MusicHandle) EndIf EndFunc ;==>_PlayPause Func _RemoveVolumeLabel() AdlibUnRegister("_RemoveVolumeLabel") ;Show Others Label For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then GUICtrlSetState($aLabel[$i][9], $GUI_SHOW) EndIf Next Local $Previous_Type = "" For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then If $Previous_Type <> $aLabel[$i][1] Then $Previous_Type = $aLabel[$i][1] GUICtrlSetState($aLabel[$i][10], $GUI_SHOW) EndIf GUICtrlSetState($aLabel[$i][9], $GUI_SHOW) EndIf Next ;Hide Volume Label GUICtrlSetState($Volume_Label, $GUI_HIDE) EndFunc ;==>_RemoveVolumeLabel Func _Save_Change_Volume() AdlibUnRegister("_Save_Change_Volume") _Set_volume($VolumePercent);Set IniWrite($Save_INI, @ComputerName, "Volume", $VolumePercent);Save EndFunc ;==>_Save_Change_Volume Func _WM_LBUTTONDOWN() ;Move GUI If WinActive("AutoIt Radio Cover") Then _SendMessage($CoverGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) Else _SendMessage($PlayerGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndIf ;Save GUI pos Local $Player_pos = WinGetPos("AutoIt Radio Player") Local $Cover_pos = WinGetPos("AutoIt Radio Cover") IniWrite($Save_INI, @ComputerName, "Title_X", $Player_pos[0]) IniWrite($Save_INI, @ComputerName, "Title_Y", $Player_pos[1]) If $Radio_CoverLink <> "" Then IniWrite($Save_INI, @ComputerName, "Cover_X", $Cover_pos[0]) IniWrite($Save_INI, @ComputerName, "Cover_Y", $Cover_pos[1]) EndIf EndFunc ;==>_WM_LBUTTONDOWN Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) AdlibUnRegister("_RemoveVolumeLabel") If GUICtrlGetState($Volume_Label) <> 80 Then ;Show $Volume_Label GUICtrlSetState($Volume_Label, $GUI_SHOW) ;Hide Others Label Local $Previous_Type = "" For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$r][0] Then If $Previous_Type <> $aLabel[$i][1] Then $Previous_Type = $aLabel[$i][1] GUICtrlSetState($aLabel[$i][10], $GUI_HIDE) EndIf GUICtrlSetState($aLabel[$i][9], $GUI_HIDE) EndIf Next EndIf ;Change $VolumePercent Local $WheelDelta = BitShift($wParam, 16) / 120 $VolumePercent = $VolumePercent + 4 * $WheelDelta If $WheelDelta > 0 Then If $VolumePercent > 100 Then $VolumePercent = 100 Else If $VolumePercent < 0 Then $VolumePercent = 0 EndIf If $Previous_VolumePercent <> $VolumePercent Then $Previous_VolumePercent = $VolumePercent GUICtrlSetData($Volume_Label, $VolumePercent) EndIf ;Change\Save Sound AdlibRegister("_Save_Change_Volume", 50) ;Hide $Volume_Label in 3s AdlibRegister("_RemoveVolumeLabel", 3000) Return $GUI_RUNDEFMSG EndFunc ;==>_WM_MOUSEWHEEL Func ContextMenu_ChangeRadio() $Previous_Cover_Read = "" Local $NewRadioName = GUICtrlRead(@GUI_CtrlId, 1) ;Maybe the next radio have no cover so delete it If $Radio_CoverLink <> "" Then GUIDelete($CoverGUI) AdlibUnRegister("GetCoverDATA") EndIf ;Maybe the $PlayerGUI need resize so delete it GUIDelete($PlayerGUI) AdlibUnRegister("GetPlayerDATA") _Audio_stop($MusicHandle) ;Remove Default Radio Tag For $r = 0 To UBound($aRadio) - 1 $aRadio[$r][7] = 0 Next ;Set $NewRadioName to Default For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][0] = $NewRadioName Then $aRadio[$r][7] = 1 IniWrite($Save_INI, @ComputerName, "Default_Radio", $aRadio[$r][0]) EndIf Next ;Get $Radio_Name, $Radio_SoundLink, $Radio_CoverLink, $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 1 Then $Radio_Name = $aRadio[$r][0] $Radio_SoundLink = $aRadio[$r][1] $Radio_CoverLink = $aRadio[$r][2] $Radio_CoverLink_Start = $aRadio[$r][3] $Radio_CoverLink_End = $aRadio[$r][4] $Radio_CoverLink_BetweenNum = $aRadio[$r][5] $Radio_CoverLink_Before = $aRadio[$r][6] EndIf Next ;ConsoleWrite("Build GUI" & @CRLF) ;Build GUI _Build_PlayerGUI() _Build_CoverGUI() ;ConsoleWrite("Show GUI" & @CRLF) GUISetState(@SW_SHOW, $PlayerGUI) If $Radio_CoverLink <> "" Then GUISetState(@SW_SHOW, $CoverGUI) EndIf ;GetPlayerDATA() - GetCoverDATA() GetPlayerDATA() AdlibRegister("GetPlayerDATA", 8000) If $Radio_CoverLink <> "" Then GetCoverDATA() AdlibRegister("GetCoverDATA", 8000) EndIf EndFunc ;==>ContextMenu_ChangeRadio Func UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "") Local $Error = "" Local $Data = "" Local $Curl = Curl_Easy_Init() If Not $Curl Then Return If $write = 0 Then ;Read Mode ; How to get html or header data? ; 1. Set $CURLOPT_WRITEFUNCTION and $CURLOPT_HEADERFUNCTION to Curl_DataWriteCallback() ; 2. Set $CURLOPT_WRITEDATA or $CURLOPT_HEADERDATA to any number as identify ; 3. Use Curl_Data_Get() to read the returned data in binary format ; 4. Use Curl_Data_Cleanup() to remove the data Local $Html = $Curl ; any number as identify Local $Header = $Curl + 1 ; any number as identify Curl_Easy_Setopt($Curl, $CURLOPT_URL, $Link) Curl_Easy_Setopt($Curl, $CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A') Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) Curl_Easy_Setopt($Curl, $CURLOPT_ACCEPT_ENCODING, "") Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $Header) Curl_Easy_Setopt($Curl, $CURLOPT_COOKIE, "tool=curl; script=autoit; fun=yes;") Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, $Timeout) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Local $Code = Curl_Easy_Perform($Curl) If $Code = $CURLE_OK Then ;ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF) ;ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF) $Data = BinaryToString(Curl_Data_Get($Html)) $Error = "" ;MsgBox(0, 'Header', BinaryToString(Curl_Data_Get($Header))) ;MsgBox(0, 'Html', BinaryToString(Curl_Data_Get($Html))) Else ;ConsoleWrite(Curl_Easy_StrError($Code) & @LF) $Data = "" $Error = Curl_Easy_StrError($Code) EndIf Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Header) Curl_Data_Cleanup($Html) Else ;Write Mode EndIf Local $aray[2] = [$Data,$Error] return $aray EndFunc Func GetCoverDATA() ;ConsoleWrite("GetCoverDATA (Start)" & @CRLF) ;Get $RealCoverLink If $Radio_CoverLink_Start = "" Then ;ConsoleWrite("$RealCoverLink = $Radio_CoverLink" & @CRLF) Local $RealCoverLink = $Radio_CoverLink Else ;ConsoleWrite("$RealCoverLink <> $Radio_CoverLink" & @CRLF) ;UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "") Local $aray = UseCurl($Radio_CoverLink, 5) Local $Data = $aray[0] Local $Error = $aray[1] If $Error <> "" then ;ConsoleWrite("$Error = " & $Error & @CRLF) EndIf Local $Between = _StringBetween($Data, $Radio_CoverLink_Start, $Radio_CoverLink_End) If @error <> 0 Then $Between = "" Else $Between = $Between[$Radio_CoverLink_BetweenNum] EndIf $RealCoverLink = $Radio_CoverLink_Before & $Between $RealCoverLink = StringReplace($RealCoverLink, " ","%20") EndIf ;ConsoleWrite("$RealCoverLink = " & $RealCoverLink & @CRLF) ;UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "") Local $Cover_Read = UseCurl($RealCoverLink, 5, 1) $Cover_Read = $Cover_Read[0] If $Cover_Read <> $Previous_Cover_Read and $Cover_Read <> "" Then $Previous_Cover_Read = $Cover_Read Local $hMem = _MemGlobalAllocFromBinary($Cover_Read) Local $hImage = _GDIPlus_ImageLoadFromHGlobal($hMem) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($CoverGUI) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $CoverSize, $CoverSize) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hImage) EndIf ;ConsoleWrite("GetCoverDATA (End)" & @CRLF) EndFunc ;==>GetCoverDATA() Func GetPlayerDATA() _ReduceMemory() ;ConsoleWrite("GetPlayerDATA (Start)" & @CRLF) ;Assign Local $Previous_Data, $Previous_DataLink For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then If $Previous_DataLink <> $aLabel[$i][3] Then Local $aray = UseCurl($aLabel[$i][3], 5) Local $Data = $aray[0] Local $Error = $aray[1] $Previous_Data = $Data $Previous_DataLink = $aLabel[$i][3] Else $Data = $Previous_Data $Previous_DataLink = $aLabel[$i][3] EndIf Local $Between = _StringBetween($Data, $aLabel[$i][4], $aLabel[$i][5]) If @error <> 0 Then $Between = "" Else If Not ($aLabel[$i][6] > Ubound($Between)-1) Then $Between = $Between[$aLabel[$i][6]] Else $Between = "" EndIf EndIf If $aLabel[$i][7] <> "" Then Local $Split = StringSplit($Between, $aLabel[$i][7], 1) If $Split[0] < $aLabel[$i][8] Then Local $Info = "" Else $Info = $Split[$aLabel[$i][8]] EndIf Else $Info = $Between EndIf If $Data = "" Then $Info = $Error EndIf $Info = StringReplace($Info, "â·", "·") $Info = StringReplace($Info, "apos;", "'") Assign($aLabel[$i][1] & $aLabel[$i][2], $Info) EndIf Next If _BASS_ChannelIsActive($MusicHandle) <> 1 and $Play = 1 Then _Audio_stop($MusicHandle) ;ConsoleWrite("Start playing sound" & @CRLF) $Play = 1 $MusicHandle = _Set_url($Radio_SoundLink) _Audio_play($MusicHandle) ;ConsoleWrite("Set Volume" & @CRLF) $VolumePercent = IniRead($Save_INI, @ComputerName, "Volume", 4) $Previous_VolumePercent = $VolumePercent _Set_volume($VolumePercent) EndIf ;Update Ctrl For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then If Eval($aLabel[$i][1] & $aLabel[$i][2]) <> GUICtrlRead($aLabel[$i][9]) Then GUICtrlSetData($aLabel[$i][9], Eval($aLabel[$i][1] & $aLabel[$i][2])) EndIf EndIf Next ;ConsoleWrite("GetPlayerDATA (End)" & @CRLF) EndFunc ;==>GetPlayerDATA() #EndRegion ;==> Internal Func While 1 Local $Msg = GUIGetCursorInfo($PlayerGUI) If $Msg[4] = $Close Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Closep.bmp");MousePressed Else _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Closeo.bmp");MouseOver EndIf Else _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Close.bmp");Nothing EndIf If $Play = 1 Then If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopp.bmp");MousePressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopo.bmp");MouseOver EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stop.bmp");Nothing EndIf Else If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playp.bmp");MousePressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playo.bmp");MouseOver EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\play.bmp");Nothing EndIf EndIf Sleep(100) WEnd ;1075 v0.0.0.8 30/04/2016 01:55  
    • By wakillon
      TinyShoutCastTuner v1.0.3.5

      Based on the >LiveStreaming source code of trancexx.
      Listen Shoutcast Radios Stations with a station search engine by filters and an easy Favorites stations management.

      Thanks to monoceres, trancexx, Kip and Prog@ndy for AutoItObject.

      >AutoItObject 1.2.2.0 and >WinAPIEx are needed.




      As usual externals skin files are downloaded at first execution.
      See Tray Menu for more options.
      Search is a bit slow but successfull...

      Previous Downloads : 436

      Update of 2012-11-05 
      source and executable are available in the Download Section
       
      Some Radios : FavoritesRadioStations.reg


      Hope you like it !
×
×
  • Create New...