Jump to content

Connect to internet problem in cycle


Recommended Posts

I made this script:

$INTERNET_AUTODIAL_FORCE_ONLINE = 1
$INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
$INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4
$INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT = 8
Global $s = 0
Global $check = 1
Global $coord = 0
Global $plusz = 0
Global $starcenter = 0
Global $yellow = 0
Global $var = "C:\Cryptload\Cryptload.exe"
Global $coord2 = 0
MsgBox(4096,"Cryptload Manager v5.0","Please point me to Cryptload.exe",10)
$var = FileOpenDialog("Cryptload Manager v5.0","c:\", "Execute (*.exe)", 1 + 4 )

While 1;Repeat all
;Connect to Internet
$aCall = DllCall("wininet.dll", "int", "InternetAutodial", "dword", $INTERNET_AUTODIAL_FORCE_UNATTENDED, "hwnd", 0)
ConsoleWrite($aCall[0] & @CRLF)
Sleep(3000)

;Start Program
Run($var)
Sleep(15000)
WinActivate("CryptLoad")
WinSetState("CryptLoad", "", @SW_MAXIMIZE)

;Search a pixel
$plusz = PixelGetColor(14,96,0)
If $plusz = 0x707070 Then
    MouseMove(14,96)
    Sleep(100)
    MouseClick("Left")
    Sleep(100)
EndIf
    
If $s <> 2 Then;2nd Search
   do
      $coord = PixelSearch(25,92,60,140,0x9898b4)
         if not @error then
            $check = PixelGetColor($coord[0],$coord[1],0)
               If $check = 0x9898b4 Then
                    MouseMove($coord[0],$coord[1], 0)
                    Sleep(100)
                    MouseClick("Left")
                    Sleep(100)
                    MouseClick("Right")
                    Sleep(100)
                    MouseMove($coord[0]+30,$coord[1]+10, 0)
                    Sleep(100)
                    MouseClick("Left")
                  $s = $s+1
               EndIf
         EndIf
   Until $s = 2
EndIf   

;Waiting for a color
While $yellow = 0
    Sleep(7500)
    $coord2 = PixelSearch(42,110,57,159,0xF5DC00)
    If not @error Then
        $starcenter = PixelGetColor($coord2[0],$coord2[1],0)
        If $starcenter = 0xF5DC00 Then
            $yellow = 1
        EndIf
    EndIf   
WEnd

;Disconnect Internet
$aCall = DllCall("wininet.dll", "int", "InternetAutodialHangup", "dword", 0)
ConsoleWrite($aCall[0] & @CRLF)

;Stop the program
ProcessClose ( "cryptload.exe")
Sleep(2000)
WEnd

The 1st cycle is working without problem, but when the 2nd cycle starts it jump the "connect to internet" command and starts with "start the program", i don't know why, can somemone help me?

Link to comment
Share on other sites

This way it only connects once, and loops through the pixelgetcolor routines. Then when you exit the script it will close the connection.

Global Const $INTERNET_AUTODIAL_FORCE_ONLINE = 1
Global Const $INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
Global Const $INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4
Global Const $INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT = 8

Global $s = 0
Global $check = 1
Global $coord = 0
Global $plusz = 0
Global $starcenter = 0
Global $yellow = 0
Global $var = "C:\Cryptload\Cryptload.exe"
Global $coord2 = 0

HotKeySet("{ESC}", "Terminate")

If Not FileExists($var) Then
    MsgBox(4096, "Cryptload Manager v5.0", "Please point me to Cryptload.exe", 10)
    $var = FileOpenDialog("Cryptload Manager v5.0", "c:\", "Execute (*.exe)", 1 + 4)
EndIf

;Connect to Internet
$aCall = DllCall("wininet.dll", "int", "InternetAutodial", "dword", $INTERNET_AUTODIAL_FORCE_UNATTENDED, "hwnd", 0)
ConsoleWrite($aCall[0] & @CRLF)
Sleep(3000)

;Start Program
Run($var)
Sleep(15000)
WinActivate("CryptLoad")
WinSetState("CryptLoad", "", @SW_MAXIMIZE)

While 1

    ;Search a pixel
    $plusz = PixelGetColor(14, 96, 0)
    If $plusz = 0x707070 Then
        MouseMove(14, 96)
        Sleep(100)
        MouseClick("Left")
        Sleep(100)
    EndIf

    If $s <> 2 Then;2nd Search
        Do
            $coord = PixelSearch(25, 92, 60, 140, 0x9898b4)
            If Not @error Then
                $check = PixelGetColor($coord[0], $coord[1], 0)
                If $check = 0x9898b4 Then
                    MouseMove($coord[0], $coord[1], 0)
                    Sleep(100)
                    MouseClick("Left")
                    Sleep(100)
                    MouseClick("Right")
                    Sleep(100)
                    MouseMove($coord[0] + 30, $coord[1] + 10, 0)
                    Sleep(100)
                    MouseClick("Left")
                    $s = $s + 1
                EndIf
            EndIf
        Until $s = 2
    EndIf

    ;Waiting for a color
    While $yellow = 0
        Sleep(7500)
        $coord2 = PixelSearch(42, 110, 57, 159, 0xF5DC00)
        If Not @error Then
            $starcenter = PixelGetColor($coord2[0], $coord2[1], 0)
            If $starcenter = 0xF5DC00 Then
                $yellow = 1
            EndIf
        EndIf
    WEnd

WEnd

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func OnAutoItExit() ; will Automatically run this function on exit

    ;Disconnect Internet
    $aCall = DllCall("wininet.dll", "int", "InternetAutodialHangup", "dword", 0)
    ConsoleWrite($aCall[0] & @CRLF)

    ;Stop the program
    ProcessClose("cryptload.exe")
    Sleep(2000)
EndFunc   ;==>OnAutoItExit

******* NOT TESTED *****

8)

NEWHeader1.png

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