Jump to content

My First Include (need Help) + Overlay Command?


Go to solution Solved by MaxMeyer123,

Recommended Posts

Hi guys, first of all sorry for my bad english.

 

Atm im coding an Include for my Pyload (Nas) really simple because i just started with coding :P

 

#include-once
#include <File.au3>
#include "WinHttp.au3"
#include "WinHttpConstants.au3"
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
Global $version = "1.0"
Global $sPaket = "" ;; ist hier oben da sonst errors kamen
Global $HSession = ""
Global $Logpath = FileOpen(@ScriptDir & "\PyLog.log", 2)
 
;~ _py_Connect()
Func _py_Connect()
   Global $c = 1
   Global $inifile = @ScriptDir & "\_Py_Tools.ini"
   Global $Section = "Pyload"
   Global $Loginname = IniRead($inifile, $Section, "Loginname", "")
   Global $Loginpassword = IniRead($inifile, $Section, "Loginpassword", "")
   Global $sPort = IniRead($inifile, $Section, "sPort", "")
   Global $hHost = Iniread($inifile, $Section, "hHost", "")
   Global $HSession = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36")
   If Not _WinHttpCheckPlatform() Then
   _FileWriteLog($Logpath, "Error: This script does not work on your System, because minimal requirements for WinHTTP are not satisfied!")
   EndIf
 
 
   _FileWriteLog($Logpath, "----Start----")
 
 
If _Nas_Ready() = 1 Then
$HSession = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36")
If @error Or $HSession = 0 Then
_FileWriteLog($Logpath, "Error: _WinHttpOpen failed")
EndIf
 
 _FileWriteLog($Logpath, "Connecting...")
 $hHost = _WinHTTPConnect($HSession, $hHost, $sPort)
 $sPaket = _Winhttpsimplerequest($hHost, "GET", "/login")
 $sPaket = _Winhttpsimplerequest($hHost, "POST", "/login", "", "do=login&username="& $Loginname &"&password="& $Loginpassword)
 
If @error Or $hHost = 0 Then
_FileWriteLog($Logpath, "Error: _WinHttpConnect failed")
return 0
Else
_FileWriteLog($Logpath, "_WinHTTPConnect successful")
;~  test()
return 1
EndIf
   EndIf
EndFunc   ;==>_py_Connect
 
Func _Nas_Ready()
   $result = Ping($hHost)
    If not @error Then
      Return 1
    Else
      Return 0
  EndIf
EndFunc;==>_Nas_Ready
 
 
Func _PY_GetDLStatus()
$sPaket = _Winhttpsimplerequest($hHost, "GET", "/api/getFileData/1")
_FileWrite($sPaket)
If StringInStr($sPaket,'Download:</span><a id="time" style=" background-color: #8ffc25; padding-left: 0cm; padding-right: 0.1cm; "> an') Then
  Return 1
   ElseIf StringInStr($sPaket,'<li><span class="time">Download:</span><a id="time" style=" background-color:  #fc6e26; padding-left: 0cm; padding-right: 0.1cm; "> aus</a></li>') Then
  Return 0
   Else
  Return -1
 EndIf
EndFunc ;=> dl STATUS
 
Func _PY_DLSpeed()
$sPaket = _Winhttpsimplerequest($hHost, "GET", "/api/getFileData/1")
_FileWrite($sPaket)
$Speed = StringRegExp($sPaket, 'id="speed">(.*?)</b>', 1) ;; $Speed[0]
$Speed = Round($Speed[0]/1000000, 3)
$Speed = $Speed & " MB/s"
return $Speed
Endfunc ;=> _py_dl_speed
 
Func _PY_Downloadparts()
   $sPaket = _Winhttpsimplerequest($hHost, "GET", "/queue/")
   _FileWrite($sPaket)
   $PartsArr = StringRegExp($sPaket,'<label style="font-size: 0\.8em; font-weight: bold; padding-right: 5px ;float: right; position: relative; top: -17px">[\r\n]+[ ]+(\d+) / (\d+)</label>',3)
   Return $PartsArr ;_PY_Downloadparts()[0] ;; _PY_Downloadparts()[1]
Endfunc ;=> dl parts
 
;~ Func _Py_DownloadGB() ;; wv von wv gb geladen wurden
Func _PY_alreadydl()
   $sPaket = _Winhttpsimplerequest($hHost, "GET", "/queue/")
   _FileWrite($sPaket)
   $groesseArr = StringRegExp($sPaket,'([\d+|\.+]* \w+) / ([\d+|\.+]* \w+)</label>',3)
   Return $groesseArr ;; $groesseArr[0] $groesseArr[1]
Endfunc
 
Func Test()
   Msgbox(1,"",_PY_alreadydl()[0] & " out of " & _PY_alreadydl()[1])
EndFunc
 
Func _Py_exit()
_WinHttpCloseHandle($HSession)
_FileWriteLog($Logpath, "----Ende----")
EndFunc
 
 
 
Func _FileWrite($sHTML, $Zusatz = "")
   ConsoleWrite($c & "Mitschnitt" & $Zusatz & @CRLF)
   FileDelete($c & "Mitschnitt" & $Zusatz & ".html")
   Filewrite($c  & "Mitschnitt" & $Zusatz & ".html", $sHTML)
   $c += 1
Endfunc ;==>_FileWrite
 
 
 

 

I tested every Function by ~ the return under the WInHttpConnect successful and write an test()

 

But if i Include this and wanna test it i get the Error Line 15 -> "Keine Verbindung"

 

#include "includes/Pyload_Selfmade.au3"
test123()
Func Test123()
    If _py_Connect() = 1 Then
  Msgbox(1,"1","")
        If _PY_GetDLStatus() = 0 Then
            Global $Statuspydl = "aus!"
        Elseif _PY_GetDLStatus() = 1 Then
            Global $Statuspydl = "an!"
        Else
            $Statuspydl = "Err GetDlStatus(API)"
        EndIf
        Msgbox(1, "Pyload Status:", "Download: " & $Statuspydl & " Speed: "& _PY_DLSpeed()) ;; wird später gelöscht und es wird einfach der rest in das overlay gepackt (aus dieser funktion)
    _Py_exit()
    Else
        MsgBox(64, "ERROR", "Keine Verbindung")
    EndIf
EndFunc

 

Second Question, i have some more Function to see things like Wlan on/off how can i write an Overlay that is undraggable, in foreground of all windows, transparent. (Just Text, Pics would be possible too)

I tried to make an Overlay via a GUI but it didnt work out.

 

Ty guys

Edited by MaxMeyer123
Link to comment
Share on other sites

Hallo Max,

kannst du dein gesamtes Skript posten, so dass es testbar ist?

Es gibt übrigens auch ein sehr gutes deutsches Forum www.autoit.de wenn du Problem hat, deine Probleme auf Englisch zu beschreiben.

Is it really an error? You code shows it _py_connect doesn't return 1 then show the MsgBox with "keine Verbindung".

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

if the "include" connect to my server it should return 

_py_Connect() = 1

if i start the test script it dont even create a log if i just acitvate the include it does.. (if i start the script with 

 _py_Connect() i put a ;~ infront for the include now still not working)

i copyed my whole scripts

Link to comment
Share on other sites

Guessing here. Try

If _Nas_Ready(1)

or maybe

_Nas_Ready($iNas)

If $iNas = 1 then

;Do something

Else

;Do something

It looks like _Py_Connect is not returning true in your second bit of code.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Moderators

MaxMeyer12,

Please do not bump your own threads within 24 hours. :naughty:

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer - as indeed they already have twice so far! ;)

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Guessing here. Try

If _Nas_Ready(1)

or maybe

_Nas_Ready($iNas)

If $iNas = 1 then

;Do something

Else

;Do something

It looks like _Py_Connect is not returning true in your second bit of code.

i  wrote

If _Nas_Ready() = 1 Then  now but still the same error

but if i just run the script without include it and run it on my test script it work and the log get created but when i include this in my test.au3 it just say "keine verbindung" (line 15)

__

Sorry M23 

Link to comment
Share on other sites

Autoits Ping function returns a time in miliseconds not a Boolean value (true(1) or false(0))

Try this:

Func _Nas_Ready()

    If not @error Then
      Return 1
    Else
      Return 0
  EndIf

EndFunc

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Solution

Autoits Ping function returns a time in miliseconds not a Boolean value (true(1) or false(0))

Try this:

Func _Nas_Ready()

    If not @error Then

      Return 1

    Else

      Return 0

  EndIf

EndFunc

still the same error, and still the log dont get created :S

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