Jump to content

New to AutoIt and am stuck... :(


RDKamikaze
 Share

Recommended Posts

Okay, I'm new to AutoIt (not even 10 hours in yet) and I'm trying to figure out what I want to do lol!! Here's my situation:

I made a GUI with Koda (which is AMAZING!!!)

I made the code with AutoIt (can I make it in Koda?)

I want a progress bar (have in Koda) but how do I use it?

Now what? I have no idea where to go from here :boggled:

I copied the extracted code from Koda, which is as follows:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$SoupRoot = GUICreate("Soup or Root 2.0 by RDKamikaze", 380, 201, 225, 146)
$root = GUICtrlCreateButton("Root Me!!", 48, 24, 281, 57)
$Progress1 = GUICtrlCreateProgress(24, 128, 329, 49, $PBS_SMOOTH)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

And here is a small sampling of the code that I wish to implement:

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x/NT
; Author:         Jonathan Bennett (jon@hiddensoft.com)
; Soup or Root Author: RDKamikaze from AndroidForums.com
; Script Function:
;  This is Soup or Root 2.0!
;

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "Soup or Root 2.0", "Continue?")

; Value for Command Prompt
$hWnd = "Administrator: C:\Windows\system32\cmd.exe"

; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "Exiting...", "Maybe next time!")
    Exit
EndIf

; Run cmd
Run("cmd.exe", "", @SW_HIDE)

; Wait for cmd to become active
WinWaitActive($hWnd , "", 15)

; Now that cmd is active enter commands
ControlSend($hWnd,"","","taskkill /f /im adb.exe")
ControlSend($hWnd,"","","{ENTER}")
;ControlSend($hWnd,"","","@echo off")
;ControlSend($hWnd,"","","{ENTER}")
ControlSend($hWnd,"","","cd C:\souproot\android-sdk-windows\tools")
ControlSend($hWnd,"","","{ENTER}")
ControlSend($hWnd,"","","adb devices")
ControlSend($hWnd,"","","{ENTER}")
ControlSend($hWnd,"","","adb push c:\souproot\droidroot\rageagainstthecage-arm5.bin /data/local/tmp")
ControlSend($hWnd,"","","{ENTER}")
sleep(800)
ControlSend($hWnd,"","","adb shell")
ControlSend($hWnd,"","","{ENTER}")
sleep(5000)
ControlSend($hWnd,"","","cd /data/local/tmp")
ControlSend($hWnd,"","","{ENTER}")
sleep(800)
ControlSend($hWnd,"","","chmod 0755 rageagainstthecage-arm5.bin")
ControlSend($hWnd,"","","{ENTER}")
sleep(800)
ControlSend($hWnd,"","","./rageagainstthecage-arm5.bin")
ControlSend($hWnd,"","","{ENTER}")
sleep(30000)
ControlSend($hWnd,"","","adb devices")
ControlSend($hWnd,"","","{ENTER}")
ControlSend($hWnd,"","","adb shell")
ControlSend($hWnd,"","","{ENTER}")
sleep(5000)
ControlSend($hWnd,"","","mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system")
ControlSend($hWnd,"","","{ENTER}")
*******THERE IS A LOT MORE CODE WHICH IS JUST ENTERING MORE COMMANDS WITH CONTROLSEND*******
sleep(800)
ControlSend($hWnd,"","","taskkill /f /im adb.exe")
ControlSend($hWnd,"","","{ENTER}")
ControlSend($hWnd,"","","exit")
ControlSend($hWnd,"","","{ENTER}")

No, you can't make a batch file so please don't ask. Batch files cannot enter data in a shell within the cmd shell (I make .bat files regularly, trust me). AutoIt seems like the only (and easiest) solution for automating cmd while giving me the ability to enter commands from a shell within the cmd shell.

Let's discuss getting AutoIt GUI and the code merged, not why I'm using AutoIt. Thanks! ;)

Edited by RDKamikaze
Link to comment
Share on other sites

Here is a start. You didn't show how you want to use the progress so I left that part out.

#Include <ButtonConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <ProgressConstants.au3>
#Include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$SoupRoot = GUICreate("Soup or Root 2.0 by RDKamikaze", 380, 201, 225, 146)
$root = GUICtrlCreateButton("Root Me!!", 48, 24, 281, 57)
$Progress1 = GUICtrlCreateProgress(24, 128, 329, 49, $PBS_SMOOTH)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $root
            _Root()
    EndSwitch
WEnd

Func _Root()
    ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
    $answer = MsgBox(4, "Soup or Root 2.0", "Continue?")

    ; Value for Command Prompt
    $hWnd = "Administrator: C:\Windows\system32\cmd.exe"

    ; Check the user's answer to the prompt (see the help file for MsgBox return values)
    ; If "No" was clicked (7) then exit the script
    If $answer = 7 Then
        MsgBox(0, "Exiting...", "Maybe next time!")
        Exit
    EndIf

    ; Run cmd
    Run("cmd.exe", "", @SW_HIDE)

    ; Wait for cmd to become active
    WinWaitActive($hWnd, "", 15)

    ; Now that cmd is active enter commands
    ControlSend($hWnd, "", "", "taskkill /f /im adb.exe")
    ControlSend($hWnd, "", "", "{ENTER}")
    ;ControlSend($hWnd,"","","@echo off")
    ;ControlSend($hWnd,"","","{ENTER}")
    ControlSend($hWnd, "", "", "cd C:\souproot\android-sdk-windows\tools")
    ControlSend($hWnd, "", "", "{ENTER}")
    ControlSend($hWnd, "", "", "adb devices")
    ControlSend($hWnd, "", "", "{ENTER}")
    ControlSend($hWnd, "", "", "adb push c:\souproot\droidroot\rageagainstthecage-arm5.bin /data/local/tmp")
    ControlSend($hWnd, "", "", "{ENTER}")
    Sleep(800)
    ControlSend($hWnd, "", "", "adb shell")
    ControlSend($hWnd, "", "", "{ENTER}")
    Sleep(5000)
    ControlSend($hWnd, "", "", "cd /data/local/tmp")
    ControlSend($hWnd, "", "", "{ENTER}")
    Sleep(800)
    ControlSend($hWnd, "", "", "chmod 0755 rageagainstthecage-arm5.bin")
    ControlSend($hWnd, "", "", "{ENTER}")
    Sleep(800)
    ControlSend($hWnd, "", "", "./rageagainstthecage-arm5.bin")
    ControlSend($hWnd, "", "", "{ENTER}")
    Sleep(30000)
    ControlSend($hWnd, "", "", "adb devices")
    ControlSend($hWnd, "", "", "{ENTER}")
    ControlSend($hWnd, "", "", "adb shell")
    ControlSend($hWnd, "", "", "{ENTER}")
    Sleep(5000)
    ControlSend($hWnd, "", "", "mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system")
    ControlSend($hWnd, "", "", "{ENTER}")
     ;;* * * * * * * THERE IS A LOT MORE CODE WHICH IS JUST ENTERING MORE COMMANDS With CONTROLSEND * * * * * * *
    Sleep(800)
    ControlSend($hWnd, "", "", "taskkill /f /im adb.exe")
    ControlSend($hWnd, "", "", "{ENTER}")
    ControlSend($hWnd, "", "", "exit")
    ControlSend($hWnd, "", "", "{ENTER}")
EndFunc   ;==>_Root

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Wow thanks a ton!!! I was forgetting the underscore on _Root() when I tried it myself over and over (after I posted and researched more) and was wondering why it wouldn't work. I want the progress bar to fit in between every command sent to cmd. Example: I send 20 commands to cmd, I want the progress bar to move 20 times (and say step X of 20).

Thanks again for your help!!

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