Next tip execution is safe. To perform the safety elimination of the 100MB boot partition you must to delete line 194.
Also you must read the remarks -real time help- (sorry it is in spanish).
Feel free to modify it for your requirements.
Code: Select all
Procedure.b SendKeys(window$,keys$,timing.b=0,beep.b=0)
; SendKeys procedure by PB -- do whatever you want with it. :)
; Syntax: r=SendKeys(handle,window$,keys$) ; r = 0 for failure.
; Specify either a handle or window$ title to type to, but not both!
; You cannot type curly braces { } as part of the keystrokes, sorry!
Protected handle.i,thread1.i,thread2.i,r.l,vk.l,vk$,s.l,s$,shifted.b
If window$:handle=FindWindow_(0,window$):EndIf ; Use window$ instead of handle.
If IsWindow_(handle) ; Does the target window actually exist?
; This block gives the target window the focus before typing.
thread1=GetWindowThreadProcessId_(GetForegroundWindow_(),0)
thread2=GetWindowThreadProcessId_(handle,0)
If thread1<>thread2:AttachThreadInput_(thread1,thread2,#True):EndIf
SetForegroundWindow_(handle) ; Target window now has the focus for typing.
Delay(125) ; 1/8 second pause before typing to prevent fast CPU problems.
; Now the actual typing starts.
keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT key before typing.
keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL key before typing.
keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT key before typing.
keybd_event_(#VK_LWIN,0,#KEYEVENTF_KEYUP,0) ; Release WINDOWS key before typing.
For r=1 To Len(keys$)
If GetAsyncKeyState_(#VK_ESCAPE):ProcedureReturn 0:EndIf
vk=0:vk$=Mid(keys$,r,1)
If vk$="{" ; Special key found.
s=FindString(keys$,"}",r+1)-(r+1) ; Get length of special key.
s$=Mid(keys$,r+1,s) ; Get special key name.
Select s$ ; Get virtual key code of special key.
Case "ALTDOWN":keybd_event_(#VK_MENU,0,0,0) ; Hold ALT down.
Case "ALTUP":keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT.
Case "BACKSPACE":vk=#VK_BACK
Case "CONTROLDOWN":keybd_event_(#VK_CONTROL,0,0,0) ; Hold CONTROL down.
Case "CONTROLUP":keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL.
Case "DELAY":vk=0:Delay(1000) ; Delay typing for one second.
Case "DELETE":vk=#VK_DELETE
Case "DOWN":vk=#VK_DOWN
Case "END":vk=#VK_END
Case "ENTER":vk=#VK_RETURN
Case "ESCAPE":vk=#VK_ESCAPE
Case "F1":vk=#VK_F1
Case "F2":vk=#VK_F2
Case "F3":vk=#VK_F3
Case "F4":vk=#VK_F4
Case "F5":vk=#VK_F5
Case "F6":vk=#VK_F6
Case "F7":vk=#VK_F7
Case "F8":vk=#VK_F8
Case "F9":vk=#VK_F9
Case "F10":vk=#VK_F10
Case "F11":vk=#VK_F11
Case "F12":vk=#VK_F12
Case "HOME":vk=#VK_HOME
Case "INSERT":vk=#VK_INSERT
Case "LEFT":vk=#VK_LEFT
Case "PAGEDOWN":vk=#VK_NEXT
Case "PAGEUP":vk=#VK_PRIOR
Case "PRINTSCREEN":vk=#VK_SNAPSHOT
Case "RIGHT":vk=#VK_RIGHT
Case "SCROLL":vk=#VK_SCROLL
Case "SPACE":vk=#VK_SPACE
Case "SHIFTDOWN":shifted=1:keybd_event_(#VK_SHIFT,0,0,0) ; Hold SHIFT down.
Case "SHIFTUP":shifted=0:keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT.
Case "TAB":vk=#VK_TAB
Case "UP":vk=#VK_UP
Case "WINDOWS":vk=#VK_LWIN
Default
If Left(s$,5)="DELAY"
vk=0:Delay(Val(RemoveString(s$,"DELAY",#PB_String_NoCase,1,1))) ; Delay typing for n millisecond
EndIf
EndSelect
If Left(s$,3)<>"ALT" And Left(s$,7)<>"CONTROL" And Left(s$,5)<>"SHIFT"
If vk
keybd_event_(vk,0,0,0):keybd_event_(vk,0,#KEYEVENTF_KEYUP,0) ; Press the special key.
EndIf
EndIf
r+s+1 ; Continue getting the keystrokes that follow the special key.
Else
vk=VkKeyScanEx_(Asc(vk$),GetKeyboardLayout_(0)) ; Normal key found.
If vk>303 And shifted=0:keybd_event_(#VK_SHIFT,0,0,0):EndIf ; Due to shifted character.
keybd_event_(vk,0,0,0):keybd_event_(vk,0,#KEYEVENTF_KEYUP,0) ; Press the normal key.
If vk>303 And shifted=0:keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0):EndIf ; Due to shifted character.
If beep:Beep_(100+vk*10,20):EndIf
If timing:Delay(timing):EndIf
EndIf
Next
If thread1<>thread2:AttachThreadInput_(thread1,thread2,#False):EndIf ; Finished typing to target window!
keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0) ; Release ALT key in case user forgot.
keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0) ; Release CONTROL key in case user forgot.
keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0) ; Release SHIFT key in case user forgot.
keybd_event_(#VK_LWIN,0,#KEYEVENTF_KEYUP,0) ; Release WINDOWS key in case user forgot.
ProcedureReturn 1 ; Report successful typing! :)
EndIf
ProcedureReturn 0 ; Nope, so report 0 for failure to type.
EndProcedure
Structure FindWindowData
hFW.l ; variable to store a handle
sFW$ ; variable to store a Window name
cFW$ ; variable to store a window class name
EndStructure
Global NewList WindowList.FindWindowData(),Found$,Found2$
Procedure.i EnumWindowsCallBack(hFind.i,lParam.i)
Protected WindowName$=Space(255),WindowClass$=Space(255),Result.i
If GetWindowText_(hFind,WindowName$,255)
Result=GetClassName_(hFind,WindowClass$,255)
AddElement(WindowList())
WindowList()\hFW=hFind
WindowList()\sFW$=WindowName$
WindowList()\cFW$=WindowClass$
;Debug WindowName$
EndIf
ProcedureReturn 1
EndProcedure
nProgram.i=RunProgram("cmd","","",#PB_Program_Open):Delay(100)
If nProgram=0:End:EndIf
Window$=LCase("system32\cmd.exe")
If EnumWindows_(@EnumWindowsCallBack(),0)
ResetList(WindowList())
While NextElement(WindowList())
;Debug("Window: " + WindowList()\sFW$)
If FindString(LCase(WindowList()\sFW$),Window$)
Found$=(WindowList()\sFW$)
;Debug "------- Found Our Window ---------"
;Debug "hwd : "+WindowList()\hFW
;Debug "Caption :"+#DQUOTE$+Found$+#DQUOTE$
win$=Found$
;comandos:
Read$ Typingvar$
While Typingvar$
If SendKeys(win$,Typingvar$+"{DELAY4000}",20,1)=0:Break:EndIf
If LCase(Left(Typingvar$,11))="exit{enter}"
win$=Found$
ElseIf LCase(Left(Typingvar$,15))="diskpart{enter}"
win$=Found$+" - diskpart"
ElseIf Right(Typingvar$,7)<>"{ENTER}"
While GetAsyncKeyState_(#VK_RETURN):Delay(20):Wend
While GetAsyncKeyState_(#VK_RETURN)=0:Delay(20):Wend
EndIf
Read$ Typingvar$
Wend
SendKeys(Found$+" - diskpart","exit{ENTER}{DELAY2500}",20,1)
SendKeys(Found$,"exit{ENTER}{DELAY500}",20,1)
Break
EndIf
Wend
EndIf
End
DataSection
Data$ "rem http://www.forosdelweb.com/f42/tutorial-eliminar-particion-system-reserved-boot-windows-7-a-829077/{ENTER}"
Data$ "rem He escrito este tutorial breve para eliminar la particion que crea windows 7 de manera predeterminada al instalarlo,{ENTER}"
Data$ "rem este crea una particion llamada "+#DOUBLEQUOTE$+"System Reserved"+#DOUBLEQUOTE$+" que contiene todos los archivos necesarios para iniciar Windows.{ENTER}"
Data$ "rem Bueno...{ENTER}"
Data$ "rem Iniciamos Windows 7 y vamos a Inicio, buscamos la consola (Command Prompt), y la abrimos como administrador. (click derecho, abrir como administrador){ENTER}"
Data$ "rem Y escribimos el siguiente comando: diskpart{ENTER}"
Data$ "diskpart{ENTER}{DELAY3500}"
Data$ "rem Escribimos los siguientes comandos:{ENTER}"
Data$ "List disk{ENTER}"
Data$ "rem Si se tiene un solo disco aparecera como disk 0.{ENTER}"
Data$ "rem veran algo como esto:{ENTER}"
Data$ "rem List disk{ENTER}"
Data$ "rem Disk### Status Size Free Dyn Gpt{ENTER}"
Data$ "rem Disk 0 Online 111GB 48GB{ENTER}"
Data$ "rem seleccionamos el disco -el de arriba es en mi caso-{ENTER}"
Data$ "Select disk "; 0{ENTER}"
Data$ "rem Disk 0 is now the selected disk.{ENTER}"
Data$ "rem le decimos que nos muestre las particiones{ENTER}"
Data$ "List partition{ENTER}"
Data$ "rem Partition ### Type Size Offset{ENTER}"
Data$ "rem Partition 1 Primary 100mb 1024KB *{ENTER}"
Data$ "rem Partition 2 Primary 62GB 101MB{ENTER}"
Data$ "rem Veran que la particion 1 cuenta con 100mb -system reserved (boot)-{ENTER}"
Data$ "Select partition "; 1{ENTER}"
Data$ "rem seleccionamos la particion de 100mb -system reserved- en mi caso es la 1, fijense que sea de 100mb y este activa{ENTER}"
Data$ "rem Partition 1 is now the selected partition.{ENTER}"
Data$ "rem le decimos que nos muestre los detalles de la particion{ENTER}"
Data$ "detail partition{ENTER}"
Data$ "rem Partition 1{ENTER}"
Data$ "rem Type: 07{ENTER}"
Data$ "rem Hidden: No{ENTER}"
Data$ "rem Active: Yes{ENTER}"
Data$ "rem Offset in Bytes: 1048576{ENTER}"
Data$ "rem nos dice que esta activa.{ENTER}"
Data$ "rem Volume ### Ltr label fs type size status{ENTER}"
Data$ "rem *volume 1 systen reserved ntfs partition 100MB healthy{ENTER}"
; BEWARE !!! Next line prevents program to continue. Delete it if you want the program to continue to erase the 100MB Windows 7 Original Boot Partition:
Data$ ""
Data$ "inactive{ENTER}"
Data$ "rem Diskpart marked the current partition as inactive.{ENTER}"
Data$ "rem la hemos marcado como inactiva.{ENTER}"
Data$ "Select partition "; 2{ENTER}"
Data$ "rem Partition 2 is now the selected partition.{ENTER}"
Data$ "rem seleccionamos ya la particion donde esta el sistema operativo [Windows 7]{ENTER}"
Data$ "detail partition{ENTER}"
Data$ "rem Partition 2{ENTER}"
Data$ "rem Type: 07{ENTER}"
Data$ "rem Hidden: no{ENTER}"
Data$ "rem Active: no{ENTER}"
Data$ "rem Offset in bytes: 105906176{ENTER}"
Data$ "rem Volume ### ltr label fs type size status{ENTER}"
Data$ "rem *volume 2 C ntfs partition 62GB healthy{ENTER}"
Data$ "rem ; nos mostro los detalles{ENTER}"
Data$ "active{ENTER}"
Data$ "rem Diskpart marked the current partition as active.{ENTER}"
Data$ "rem ; ahora le hemos dicho que nos marque como activa la particion del sistema operativo{ENTER}"
Data$ "detail partition{ENTER}"
Data$ "rem Partition 2{ENTER}"
Data$ "rem Type: 07{ENTER}"
Data$ "rem Hidden: no{ENTER}"
Data$ "rem Active: yes{ENTER}"
Data$ "rem Offset in bytes: 105906176{ENTER}"
Data$ "rem Volume ### ltr label fs type size status{ENTER}"
Data$ "rem *volume 2 c ntfs partition 62GB healthy{ENTER}"
Data$ "rem ; ahora nos mostro que esta activa.{ENTER}"
Data$ "rem ;salimos de diskpart{ENTER}"
Data$ "exit{ENTER}"
Data$ "rem ;Ahora en la misma consola (Command Prompt)"
Data$ "rem Con la utilidad del propio sistema operativo BCDBOOT copiar los archivos a C:{ENTER}"
Data$ "rem bcdboot c:\windows /s c:{ENTER}"
Data$ "rem boot files sucessfully created.{ENTER}"
Data$ "rem ; ahora reiniciamos{ENTER}"
Data$ "rem shutdown /r /t 0{ENTER}"
Data$ "rem ;Abrimos diskpart de nuevo como administrador.{ENTER}"
Data$ "rem ;seleccionamos el disco{ENTER}"
Data$ "Select disk "; 0{ENTER}"
Data$ "List partition{ENTER}"
Data$ "rem ;nos muestra las particiones{ENTER}"
Data$ "rem ; Partition ### Type Size Offset{ENTER}"
Data$ "rem ; Partition 1 Primary 100mb 1024KB *{ENTER}"
Data$ "rem ; Partition 2 Primary 62GB 101MB{ENTER}"
Data$ "rem ;borramos la particion de system reserved{ENTER}"
Data$ "Select partition " ;1 es en mi caso.{ENTER}"
Data$ "delete partition{ENTER}"
Data$ "exit" ;salimos{ENTER}"
Data$ "rem ; ahora reiniciamos{ENTER}"
Data$ "rem shutdown /r /t 0{ENTER}"
Data$ ""
EndDataSection