Jump to content

SOLVED:One click and restart main program.Help!!!


jacq
 Share

Recommended Posts

Welcome.

I have the code:

I have a problem with the program when you push:

$Menu_ustawienia = GUICtrlCreateMenuItem("Ustawienia", $Menu_p)

program starts and you can disable it but then I can not run it again by pressing:

$Menu_ustawienia = GUICtrlCreateMenuItem("Ustawienia", $Menu_p)

without the shutdown of the main program and run it again.

Other buttons that are in the main program does not work well when you start:

$Menu_ustawienia = GUICtrlCreateMenuItem("Ustawienia", $Menu_p)

and also you need to run the main program again.Help!!!

Edited by jacq
Link to comment
Share on other sites

you dont seem to fully understand the concept and usage of functions.

if you want to execute code more than one time depending on an event or an evaluation, you have to use functions. In your case you want to put the creation of the login GUI in a function, so you can call that function whenever the user selects the login item in the main GUI.

Also you cant use Func within an loop or if statement. From Tools Menu in Scite run Tidy Autoit Source and it will show you where the error is.

Also you should move all of your #include commands to the top of the script.

However this is not the reason why your login GUI will not show again.

This requires some rearrangement of your code.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
;~   #include <ButtonConstants.au3>
  #include <EditConstants.au3>
;~   #include <GUIConstantsEx.au3>
;~   #include <WindowsConstants.au3>
;~   #include <StaticConstants.au3>
  #include <String.au3>
$oie = _IECreateEmbedded()
#region ### START Koda GUI section ###
$Form1 = GUICreate("Tv", 896, 489, -1, -1)
$Object1 = GUICtrlCreateObj($oie, 8, 15, 682, 446)

GUISetBkColor(0xf0f8ff)
$Menu_p = GUICtrlCreateMenu("Menu")
$Menu_ustawienia = GUICtrlCreateMenuItem("Ustawienia", $Menu_p)
$Menu_wyjscie = GUICtrlCreateMenuItem("Wyj[cie", $Menu_p)
$BtnRef = GUICtrlCreateButton("Przejdz/Od[wierz", 760, 336, 90, 25)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
$BtnPin = GUICtrlCreateButton("Przyczep/Odczep", 760, 376, 90, 25)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
$BtnProxy = GUICtrlCreateButton("ZmieD Proxy", 760, 416, 90, 25)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
$Group1 = GUICtrlCreateGroup("Opcje", 696, 312, 193, 137)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 712, 16, 161, 253)
GUICtrlSetData(-1, "AXN Crime|AXN HD|Boomerang|Canal+ Film HD|Canal+ HD|Canal+ Sport HD|Cartoon Network|Cinemax HD|Comedy Central|Discovery Channel|Discovery Science|Disney Channel|Dr.HOUSE|Eska TV|EuroSport 2 HD|FilmBox HD|Kuchnia+ HD|MiniMini+ HD|National Geographic|Nickelodeon HD|nPremium 1 HD|nPremium 2 HD|nPremium 3 HD|nPremium 4 HD|Pingwiny z madagaskaru|Polsat|Polsat 2|Polsat sport HD|Puls|TVN 24|TVN 7 HD|TVN HD|TVN Style|TVN Turbo|TVP HD|Viva Polska")
$Combo1 = GUICtrlCreateCombo("yródBo", 720, 288, 145, 25)
GUICtrlSetData(-1, 'Weeb.tv|Alternatywne')

GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
Dim $proxy[30] = ["192.115.106.236:3128", "192.115.106.236:8080", "66.119.33.134:8000", "200.141.76.227:8080", "66.250.69.2:81 ", "170.224.224.101:8000", "216.72.63.198:8080", "61.32.11.130:8080", "211.15.62.123:8000", "201.17.167.229:6588", "81.22.95.139:6588", "200.55.26.65:8080", "61.95.206.50:6588", "203.101.41.19:6588", "210.87.135.125:80", "193.140.140.76:8080", "195.87.69.242:80", "193.140.140.70:8080", "193.95.90.51:80", "193.95.113.114:80", "193.95.27.2:8080", "193.95.90.52:80", "193.95.100.86:80", "161.200.52.2:80", "203.144.198.122:80", "203.144.197.194:80", "203.154.67.164:8080", "203.144.216.211:80", "61.19.158.50:8080", "203.107.174.34:8080"]
$referer = $proxy[Random(0, 29)]
HttpSetProxy(2, $referer)
$source1 = "tvn"
Global $togglebar
Func ToggleBarState()
$togglebar = Not $togglebar
If $togglebar = True Then
  GUICtrlSetState($List1, $GUI_HIDE)
  GUICtrlSetState($BtnRef, $GUI_HIDE)
  GUICtrlSetState($BtnPin, $GUI_HIDE)
  GUICtrlSetState($BtnProxy, $GUI_HIDE)
  GUICtrlDelete($Object1)
  $Object1 = GUICtrlCreateObj($oie, 2, 0, 487, 321)
  _IENavigate($oie, "http://weeb.tv/mini-channel/" & $source1)
EndIf
If $togglebar = False Then
  GUICtrlSetState($List1, $GUI_SHOW)
  GUICtrlSetState($BtnRef, $GUI_SHOW)
  GUICtrlSetState($BtnPin, $GUI_SHOW)
  GUICtrlSetState($BtnProxy, $GUI_SHOW)
  GUICtrlDelete($Object1)
  $Object1 = GUICtrlCreateObj($oie, 2, 0, 361, 321)
  _IENavigate($oie, "http://weeb.tv/mini-channel/" & $source1)
EndIf
EndFunc   ;==>ToggleBarState
HotKeySet("^m", 'ToggleBarState')
Global $togglepin
Func TogglePinState()
$togglepin = Not $togglepin
If $togglepin = True Then
  MsgBox(0, "", "Od teraz program bdzie zawsze na wierzchu !")
  WinSetOnTop("Li", "", 1)
EndIf
If $togglepin = False Then
  WinSetOnTop("Li", "", 0)
  MsgBox(0, "", "Od teraz program nie bdzie przeszkadzaB !")
EndIf
EndFunc   ;==>TogglePinState
HotKeySet("^n", 'TogglePinState')
While 1
$nMsg = GUIGetMsg()
If $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Menu_wyjscie Then
  Exit
EndIf




If $nMsg = $Menu_ustawienia Then
  _ShowLoginGUI()
EndIf
If $nMsg = $BtnRef Then
  Switch GUICtrlRead($List1)
   Case "TVP HD"
    $source1 = "tvp"
    $source2 = ""
   Case "TVN HD"
    $source1 = "tvn"
    $source2 = "http://pl.justin.tv/tobi686/popout"
   Case "TVN 24"
    $source1 = "tvn24"
    $source2 = ""
   Case "Polsat"
    $source1 = "polsat"
    $source2 = ""
   Case "Polsat 2"
    $source1 = "polsat2"
    $source2 = ""
   Case "TVN 7 HD"
    $source1 = "tvn7hd"
    $source2 = ""
   Case "Puls"
    $source1 = "puls"
    $source2 = ""
   Case "nPremium HD"
    $source1 = "npremium1"
    $source2 = ""
   Case "Canal+ HD"
    $source1 = "cplus"
    $source2 = ""
   Case "Cinemax HD"
    $source1 = "cinmax"
    $source2 = ""
   Case "Comedy Central"
    $source1 = "comedycentral"
    $source2 = ""
   Case "Canal+ Film HD"
    $source1 = "cplusfilm"
    $source2 = ""
   Case "FilmBox HD"
    $source1 = "filmbox"
    $source2 = ""
   Case "Axn HD"
    $source1 = "axn"
    $source2 = ""
   Case "nPremium 4 HD"
    $source1 = "npremium4"
    $source2 = ""
   Case "nPremium 3 HD"
    $source1 = "npremium3"
    $source2 = ""
   Case "nPremium 2 HD"
    $source1 = "npremium2"
    $source2 = ""
   Case "AXN Crime"
    $source1 = "axncrime"
    $source2 = ""
   Case "Scifi Universal"
    $source1 = "sfu"
    $source2 = ""
   Case "AleKino+ HD"
    $source1 = "alekino"
    $source2 = ""
   Case "TV 4"
    $source1 = "tv4"
    $source2 = ""
   Case "Dr.HOUSE"
    $source1 = "gry"
    $source2 = ""
   Case "Viva Polska"
    $source1 = "kaszpik"
    $source2 = ""
   Case "TVN Style"
    $source1 = "tvnstyle"
    $source2 = ""
   Case "Pingwiny z madagaskaru"
    $source1 = "men"
    $source2 = ""
   Case "Discovery Science"
    $source1 = "discoveryscenice"
    $source2 = ""
   Case "National Geographic"
    $source1 = "natgeochannel"
    $source2 = ""
   Case "TVN Turbo"
    $source1 = "tvnturbo"
    $source2 = ""
   Case "TVN Style"
    $source1 = "tvnstyle"
    $source2 = ""
   Case "EuroSport 2 HD"
    $source1 = "eurosport2"
    $source2 = ""
   Case "Kuchnia+ HD"
    $source1 = "kuchnia"
    $source2 = ""
   Case "Eska TV"
    $source1 = "men2"
    $source2 = @ScriptDir & "/eska.html"
   Case "Canal+ Sport HD"
    $source1 = "sport"
    $source2 = ""
   Case "Boomerang"
    $source1 = "boomerang"
    $source2 = ""
   Case "Disney Channel"
    $source1 = "disneychannel"
    $source2 = ""
   Case "Polsat sport HD"
    $source1 = "polsatsport"
    $source2 = ""
   Case "Nickelodeon HD"
    $source1 = "nickhd"
    $source2 = ""
   Case "Cartoon Network"
    $source1 = "cn"
    $source2 = ""
   Case "MiniMini+ HD"
    $source1 = "minimini"
    $source2 = ""
   Case "Discovery Channel"
    $source1 = "discovery"
    $source2 = ""
   Case $Menu_wyjscie
    Exit
  EndSwitch
  If GUICtrlRead($Combo1) = "Weeb.tv" Then
   $url = "http://weeb.tv/mini-channel/" & $source1
  EndIf
  If GUICtrlRead($Combo1) = "Alternatywne" Then
   $url = $source2
  EndIf
  If GUICtrlRead($Combo1) = "yródBo" Then
   MsgBox(0, "Error", "Nie wybraBes zródBa! Wybieram domy[lne...")
   $url = "http://weeb.tv/mini-channel/" & $source1
  EndIf
  _IENavigate($oie, $url)
EndIf
If $nMsg = $BtnProxy Then
  HttpSetProxy(2, $referer)
EndIf
If $nMsg = $BtnPin Then
  TogglePinState()
EndIf
WEnd

Func _ShowLoginGUI()
   #region ### START Koda GUI section ###
  $Form2 = GUICreate("Wprowadzanie danych logowania", 398, 203, -1, -1)
  $Zapisz = GUICtrlCreateButton("Zatwierdzam", 170, 160, 73, 33, $WS_GROUP)
  DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
  $login = GUICtrlCreateInput("", 150, 50, 150, 25)
  $password = GUICtrlCreateInput("", 150, 85, 150, 25, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
  $text = GUICtrlCreateLabel("Podaj dane logowania", 145, 20, 200)
  GUICtrlSetColor(-1, 0x00ffff)
  GUICtrlSetFont(-1, 14, 800, 2)
  $text2 = GUICtrlCreateLabel("Podaj login", 50, 53, 100)
  GUICtrlSetColor(-1, 0x00ff00)
  GUICtrlSetFont(-1, 12, 600, 2)
  $text3 = GUICtrlCreateLabel("Podaj hasBo", 50, 87, 100)
  GUICtrlSetColor(-1, 0x00ff00)
  GUICtrlSetFont(-1, 12, 600, 2)
  DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
  GUICtrlSetBkColor($text, $GUI_BKCOLOR_TRANSPARENT)
  GUICtrlSetBkColor($text2, $GUI_BKCOLOR_TRANSPARENT)
  GUICtrlSetBkColor($text3, $GUI_BKCOLOR_TRANSPARENT)

  GUISetState(@SW_SHOW)
  #endregion ### START Koda GUI section ###

  While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
    Case $Zapisz
     save()
   EndSwitch
   If $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Menu_wyjscie Or $nMsg = $Zapisz Then
;~   $pr = ("Wprowadzanie danych logowania") <-- This will always return "true" because () evaluates an expression
     $pr = "Wprowadzanie danych logowania"
;~   GUIDelete($pr) <-- GUIDelete need an variable with an WindowsHandle (for example $Form2)
    GUIDelete($Form2)
    Return
   EndIf
  WEnd
EndFunc


Func save()
$a = FileOpen("dane.ini", 2)
$b = GUICtrlRead($login)
$c = GUICtrlRead($password)
IniWrite("dane.ini", "Dane", "l", $b)
IniWrite("dane.ini", "Dane", "p", $c)
FileClose($a)
$x = IniRead('dane.ini', 'Dane', 'l', 0)
$y = IniRead('dane.ini', 'Dane', 'p', 0)
$HashCheck = StringInStr($x, '*')
$HashCheck2 = StringInStr($y, '*')
If $HashCheck = 0 Then
  $q = _StringEncrypt(1, $x, 'test')
  $q2 = _StringEncrypt(1, $y, 'test')
  IniWrite('dane.ini', 'Dane', 'l', ' ' & $q & '*')
  IniWrite('dane.ini', 'Dane', 'p', ' ' & $q2 & '*')
EndIf
MsgBox(64, "Info", "Dane zostaBy zapisane prawidBowo")
EndFunc   ;==>save

- Moved save() function outside

- put Login GUI code into _ShowLoginGUI() function

- small corrections of the Login GUI code to close it properly

Now it will show again if you close it, but you will notice that there is an error when you try to login.

The problem is that the variables $password and $login are created locally in the _ShowLoginGUI() function but also used in the save() function.

So you have to make both to global variables to make the login work.

Edited by qsek
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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