Jump to content

Recommended Posts

Posted

just a simple program to remember all my serial codes and put them in for me.

get fed up of typing them in, (TOO LAZY to look for them too).

#include <GUIConstants.au3>

AutoItSetOption("SendKeyDelay", 45);
AutoItSetOption("SendKeyDownDelay", 45);


$my_gui = GUICreate("", 300, 150, 200, 200)

$code=0
$win=""
$list = GUICtrlCreateList("",5,5, 200, 100,BitOR($WS_BORDER, $WS_VSCROLL,$WS_HSCROLL,$WS_EX_TOPMOST))
$check = GUICtrlCreateButton("Read Drive(s)", 210,125, 85 ,20)
$stat=GUICtrlCreateLabel("",5,110,200,20)
$paste=GUICtrlCreateButton("Paste Key",210,95,85,20)
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetState()

While 1

    $msg = GUIGetMsg()

    Select
        Case $msg = $check
            $found=0
            $var = DriveGetDrive("CDROM")
            GUICtrlSetState($paste,$GUI_DISABLE)
            GUICtrlSetData($list,"")
            GUICtrlSetData($list,"There are "&$var[0]&" Drives found")
            guictrlsetdata($stat,"READING DRIVES.... PLEASE WAIT")
            If Not @error Then
                For $i = 1 To $var[0]

                    $drive_label = DriveGetLabel($var[$i])
                    data()
                Next
            GUICtrlSetData($stat,"OK! Scan Complete!!")
            
        if $found>0 then 
                gUICtrlSetState($paste,$GUI_ENABLE)
        ElseIf $found=0 Then
            GUICtrlSetData($list,"No Match found")
        EndIf
        EndIf
        
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        case $msg = $paste
)   
        sleep(500)
        ;   MsgBox(0,"",$code,0)
        $code_split=StringSplit($code,"-")
    
    $wa=WinActivate($win)
    
    sleep(500)
    if $wa =1 Then

    for $i2= 1 to $code_split[0]
;MsgBox(0,"",$code_split[$i2],)
    send($code_split[$i2])
    sleep(500)
    Next
EndIf
MsgBox(0,"","Complete",1)
    EndSelect
WEnd


func data()



If $drive_label = "BF2142 DVD" Then
$code="xxxx-xxxx-xxxx-xxxx-xxxx"
$win="Battlefield 2142"
ok()
EndIf
EndFunc


func ok()
$found=$found+1
GUICtrlSetData($list,"")
GUICtrlSetData($list, "Found: " & $drive_label)
GUICtrlSetData($list,$code)
EndFunc

i have ommited my other serials which i have about 30.... you get the idea.

i have had no problems when i used to run this in XP.

everything worked.

untill i installed vista.

Posted

Sorry it took so long, had to acquire and boot the work laptop.

It shows one drive found with no matches. The only error I get is on line 48 because of the ). I assume that was a copy/paste error though.

What error are you getting if any?

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Posted

This works for me.

#include <GUIConstants.au3>

AutoItSetOption("SendKeyDelay", 45);
AutoItSetOption("SendKeyDownDelay", 45);

Global $code = 0, $win = ""
$my_gui = GUICreate("", 300, 150, 200, 200)
$list = GUICtrlCreateList("", 5, 5, 200, 100, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL, $WS_EX_TOPMOST))
$check = GUICtrlCreateButton("Read Drive(s)", 210, 125, 85, 20)
$stat = GUICtrlCreateLabel("", 5, 110, 200, 20)
$paste = GUICtrlCreateButton("Paste Key", 210, 95, 85, 20)
GUICtrlSetState(Default, $GUI_DISABLE)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $check
            $found = 0
            $var = DriveGetDrive("CDROM")
            $error = @error
            GUICtrlSetState($paste, $GUI_DISABLE)
            GUICtrlSetData($list, "")
            GUICtrlSetData($list, "There are " & $var[0] & " Drives found")
            GUICtrlSetData($stat, "READING DRIVES.... PLEASE WAIT")
            If Not $error Then
                For $i = 1 To $var[0]
                    $drive_label = DriveGetLabel($var[$i])
                    If Not @error Then
                        data()
                    EndIf
                Next
                GUICtrlSetData($stat, "OK! Scan Complete!!")
                If $found Then
                    GUICtrlSetState($paste, $GUI_ENABLE)
                Else
                    GUICtrlSetData($list, "No Match found")
                EndIf
            EndIf

        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $paste
            Sleep(500)
            $code_split = StringSplit($code, "-")
            FileWrite('Battlefield 2142.txt', ''); test only *
            ShellExecute('Battlefield 2142.txt'); test only *
            WinWait($win)
            WinActivate($win)
            If WinWaitActive($win, '', 60) Then
                For $i = 1 To $code_split[0]
                    Send($code_split[$i])
                    Sleep(500)
                Next
            Else
                MsgBox(0x40030, @ScriptName, 'Window Title: ' & $win & @CRLF & 'was not found')
            EndIf
            FileDelete('Battlefield 2142.txt'); test only *
            Sleep(500)
            MsgBox(0, "", "Complete", 1)
            WinKill('Battlefield 2142'); test only *
    EndSelect
WEnd

Exit

Func data()
    If $drive_label = "BF2142 DVD" Then
        $code = "xxxx-xxxx-xxxx-xxxx-xxxx"
        $win = "Battlefield 2142"
        ok()
    EndIf
EndFunc

Func ok()
    $found += 1
    GUICtrlSetData($list, "")
    GUICtrlSetData($list, "Found: " & $drive_label)
    GUICtrlSetData($list, $code)
EndFunc

:whistle:

Posted

Have you tried to send it to the Serial input box of a game....

i still have not succeded.

I normally use ControlSetText() for Games and various software installations. They usually have Edit1, Edit2...

Global $serial[5] = ['abcd', 'efgh', 'ijkn', 'opqr', 'stuv']
WinWait('title', 'text', 1)
For $i = 0 To UBound($serial) -1
;~  ControlSetText('title', 'text', 'Edit' & ($i + 1))
    MsgBox(0, 'pasting into Edit' & ($i + 1), $serial[$i], 1); test only
Next

:whistle:

Posted

is there way of determining how many inputboxes there are.

You could have a button for pasting into multiple controls and a button for a single input control. Each button can call a function suitable to handle the single/multiple control/s.

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
×
×
  • Create New...