|
2
|
Programación / Programación C/C++ / Como madres muevo un control en run-time?
|
en: 13 Enero 2013, 20:52 pm
|
Hola buenos días. He buscado en muchos lugares y muy pocas webs hablan de como mover controles en tiempo de ejecución mas encima la web esta plagado de C# FoxPro .Net y otas variaciones que ni me interesan. Lo que yo uso es el estandart C99 o C11 que es el más nuevo.
PellesC es mi IDE. Usando Windows.h
Bueno, como muevo un insignificante boton? ...tambien debo ocultar otro boton, un textbox y un label además de cambiarle el texto al boton que voy a mover de posición.
La ayuda se agradece muchísimo pues estoy aprendiendo recien C99.
|
|
|
3
|
Programación / Programación Visual Basic / Re: Autoclick de Pixeles
|
en: 25 Noviembre 2012, 06:21 am
|
Busca como puedes obtener una captura de la imagen del sector que quieres analizar, en VB6 yo usaba (si recuerdo bien y corriganme si me equivoco) getDIBits() para obtener los pixeles en un array de bits. Una vez tengas los pixeles te ayudo.
También puedes usar la api getPixel() pero es mas lento que usar la api getDIBits(). Suerte.
Si a quien hablas es a mi, me refiero a que obtengas los pixeles en programación. Esto es Programacion en Visual Basic. Paso 1, buscar en google ( https://www.google.cl/search?q=obtener+pixeles+GetDIBITS+visua+basic)Paso 2, leer e implementar ( http://www.vb-helper.com/howto_getdibits.html)Paso 3, No hay paso 3! Ya tienes los pixeles!! Ahora falta que recorras la matriz "pixels()" en busca de los valores del pixel que deceas clickear (En el codigo: "Modify the pixels.") y cuando tengas el pixel, calcula la posición en la pantalla y manda el click! No cuesta nada usar un buscador.
|
|
|
4
|
Programación / Programación Visual Basic / Re: Navegar por carpetas mediante código
|
en: 19 Noviembre 2012, 19:00 pm
|
OK, gracias por sus aportes ^^ esto es lo que llevo hasta ahora espero prueben y me digan si algo anda mal. Administradores de archivos añadidos: - Explorer XP (solo con barra de direcciones) - Explorer W7 (sin probar) - XYplorer (con o sin barra de direcciones) - AcBrowser (la barra esta siempre) - CubicExplorer (con o sin barra de direcciones) - A43 (solo con barra de direcciones) - TotalCommander (solo primer bloque de carpetas) (Para probarlo creen un par de carpetas y ponganle el mismo nombre que el ejecutable a compilar)' ' mExplore ' Araon - 19/11/2012 ' Option Explicit 'declares para buscar ventanas y enviar mensajes Declare Function GetActiveWindow Lib "user32" () As Long Declare Function GetForegroundWindow Lib "user32" () As Long Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hwnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'declares para enviar texto y teclas Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Declare Function SendMessageByNum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'declares para ejecutar el explorador en caso de no poder navegar Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long 'para esperar hasta que aparezca la barra de dirección (W7) Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'declare para Ac Browser ¬¬ Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Const VK_F2 = &H71 Const VK_MENU = &H12 Const KEYEVENTF_KEYUP = &H2 'sendKeys "%({F2})" no funciona Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) ' ' La constante: Const WM_CHAR = &H102 'Const WM_SYSCHAR = &H106 Const WM_COMMAND = &H111 'Const WM_SYSCOMMAND = &H112 Const WM_KEYUP = &H101 'Const WM_SYSKEYUP = &H105 Const WM_KEYDOWN = &H100 'Const WM_SYSKEYDOWN = &H104 Const WM_SETTEXT = &HC Const WM_LBUTTONDOWN = &H201 Const WM_LBUTTONUP = &H202 'Const WM_RBUTTONDOWN = &H204 'Const WM_RBUTTONUP = &H205 ' lParam para WM_SYSCOMMAND 'Const SC_CLOSE = &HF060& 'Const SC_MAXIMIZE = &HF030& 'Const SC_MINIMIZE = &HF020& 'Const SC_RESTORE = &HF120&
Private hwnd As Long
Sub Main() Dim sPath As String sPath = App.Path If (Right$(sPath, 1) <> "\") Then sPath = sPath & "\" Call go(sPath & App.EXEName) End Sub
Public Sub go(ByVal sPath As String) 'NOTA: Cuidado con SendKeys puede interferir en otra ventana ' no relacionada con un explorer. Asegurarse primero de ' que se envia a la ventana correcta. If goExplorerXP(sPath) Then Exit Sub 'solo con barra de direcciones If goExplorerW7(sPath) Then Exit Sub If goXYplorer(sPath) Then Exit Sub 'con o sin barra de direcciones OK If goAcBrowser(sPath) Then Exit Sub 'no se puede desactivar la barra OK If goCubicExplorer(sPath) Then Exit Sub 'con o sin barra de direcciones OK If goA43(sPath) Then Exit Sub 'solo con barra de direcciones If goTotalCommander(sPath) Then Exit Sub 'solo primer bloque de carpetas 'default Call ShellExecute(0&, "open", "explorer", sPath, App.Path, vbNormalFocus) End Sub
Function gethWnd() As Long 'obtiene el hWnd de la ventana que tiene el foco 'o la que tiene en el titulo el texto App.Path 'NOTA: Si se ejecuta en un Form usar GetParent()?? hwnd = 0 hwnd = GetActiveWindow() If (hwnd = 0) Then hwnd = GetForegroundWindow() 'If (hwnd = 0) Then hwnd = FindWindow(vbNullString, App.Path) 'If (hwnd = 0) Then hwnd = FindWindow(vbNullString, Mid$(App.Path, InStrRev(App.Path, "\") + 1)) gethWnd = hwnd End Function
'------------------------------------------------------------------------------- ' EXPLORER FUNCTIONS TO USE ACTUAL WINDOW EXPLORER '-------------------------------------------------------------------------------
Function goExplorerXP(ByVal sPath As String) As Boolean 'explorer XP Dim lRet As Long hwnd = gethWnd() If (hwnd <> 0) Then lRet = FindWindowEx(hwnd, 0, "WorkerW", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ReBarWindow32", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ComboBoxEx32", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ComboBox", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "Edit", vbNullString) Else Exit Function If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) SendKeys "{TAB}", True 'enviar el foco al "FolderView" goExplorerXP = True End If End If End Function
Function goExplorerW7(ByVal sPath As String) As Boolean 'explorer W7 Dim lRet As Long hwnd = gethWnd() If (hwnd <> 0) Then lRet = FindWindowEx(hwnd, 0, "WorkerW", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ReBarWindow32", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "Address Band Root", vbNullString) Else Exit Function 'abrir la barra de direcciones If (lRet <> 0) Then Call SendKeys("{F4}{F4}", True) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "msctls_progress32", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ComboBoxEx32", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ComboBox", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "Edit", vbNullString) Else Exit Function If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) goExplorerW7 = True End If End If End If End Function
Function goXYplorer(ByVal sPath As String) As Boolean 'XYplorer v11.70.0100 Dim lRet As Long hwnd = gethWnd() If (hwnd <> 0) Then lRet = FindWindowEx(hwnd, 0, "ThunderRT6PictureBoxDC", vbNullString) If (lRet <> 0) Then 'XYplorer (debe buscar el edit) Dim hwnd2 As Long Do While (lRet <> 0) lRet = FindWindowEx(lRet, 0, "Edit", vbNullString) If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) goXYplorer = True Else lRet = FindWindowEx(hwnd, hwnd2, "ThunderRT6PictureBoxDC", vbNullString) If (lRet <> 0) Then hwnd2 = lRet End If Loop End If End If End Function
Function goAcBrowser(ByVal sPath As String) As Boolean 'AcBrowser Plus v4.13 sub version "a" Dim lRet As Long, buff As String hwnd = gethWnd() 'hwnd = GetForegroundWindow() 'AcBrowser usa MDI, obtener hWnd maestro If (hwnd <> 0) Then buff = String$(150, " ") lRet = GetClassName(hwnd, buff, Len(buff)) buff = Left$(buff, lRet) buff = Mid$(buff, 1, 13) & "b" & Mid$(buff, 15) buff = Mid$(buff, 1, 31) & "6" & Mid$(buff, 33) lRet = FindWindowEx(hwnd, 0, "MDIClient", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, buff, vbNullString) Else Exit Function 'hay que enviarle ALT+F2 para que aparezca le barra de direcciones If (lRet <> 0) Then 'con SendKeys no funciona "%({F2})" keybd_event VK_MENU, 0, 0, 0 keybd_event VK_F2, 0, 0, 0 keybd_event VK_F2, 0, KEYEVENTF_KEYUP, 0 keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 Else Exit Function End If If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "#32770", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "#32770", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ComboBoxEx32", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "ComboBox", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "Edit", vbNullString) Else Exit Function If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) Call PostMessage(lRet, WM_KEYUP, &HD&, ByVal &H1C0001) goAcBrowser = True End If End If End Function
Function goTotalCommander(ByVal sPath As String) As Boolean 'TotalCommander v8.01 ' * solo soporta un lado de las carpetas (IZQ). Mal uso de Sleep ' una fea forma de acceder. Dim lRet As Long hwnd = gethWnd() If (hwnd <> 0) Then lRet = FindWindowEx(hwnd, 0, "TMyPanel", vbNullString) If (lRet <> 0) Then 'TotalCommander (debe buscar el edit) Dim hwnd2 As Long Do While (lRet <> 0) lRet = FindWindowEx(lRet, 0, "TPathPanel", vbNullString) If (lRet <> 0) Then Call PostMessage(lRet, WM_LBUTTONDOWN, &H1&, ByVal &H80166) Call PostMessage(lRet, WM_LBUTTONUP, &H0&, ByVal &H80166) Sleep 1000& lRet = FindWindowEx(lRet, 0, "TInEdit", vbNullString) If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) goTotalCommander = True Exit Function End If Else lRet = FindWindowEx(hwnd, hwnd2, "TMyPanel", vbNullString) If (lRet <> 0) Then hwnd2 = lRet End If Loop End If End If End Function
Function goA43(ByVal sPath As String) As Boolean 'A43 v3.30 Dim lRet As Long hwnd = gethWnd() If (hwnd <> 0) Then lRet = FindWindowEx(hwnd, 0, "TPanel", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(hwnd, lRet, "TPanel", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "TPTSplitter", vbNullString) Else Exit Function If (lRet <> 0) Then 'A43 Explorer lRet = FindWindowEx(lRet, 0, "TPTPane", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "TJamShellCombo", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "TEdit", vbNullString) Else Exit Function If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) goA43 = True Else 'A43 sin barra de direcciones 'activar barra 'SendKeys "%(V{DOWN}~)", True 'SenKeys y keybd_event FALLAN End If End If End If End Function
Function goCubicExplorer(ByVal sPath As String) As Boolean 'CubicExplorer v0.95.1.1494 Dim lRet As Long hwnd = gethWnd() If (hwnd <> 0) Then lRet = FindWindowEx(hwnd, 0, "TSpTBXDock", vbNullString) If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "TCEAddressBarToolbar.UnicodeClass", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "TCEAddressBar", vbNullString) Else Exit Function If (lRet <> 0) Then lRet = FindWindowEx(lRet, 0, "TCE_AMemo.UnicodeClass", vbNullString) Else Exit Function If (lRet <> 0) Then Call SendMessage(lRet, WM_SETTEXT, 0, ByVal sPath) Call PostMessage(lRet, WM_KEYDOWN, &HD&, ByVal &H1C0001) goCubicExplorer = True End If End If End Function
Dependo mucho de la barra de direcciones me gustaría mejorar eso.
|
|
|
5
|
Programación / Programación Visual Basic / Re: Autoclick de Pixeles
|
en: 15 Noviembre 2012, 00:14 am
|
Busca como puedes obtener una captura de la imagen del sector que quieres analizar, en VB6 yo usaba (si recuerdo bien y corriganme si me equivoco) getDIBits() para obtener los pixeles en un array de bits. Una vez tengas los pixeles te ayudo.
También puedes usar la api getPixel() pero es mas lento que usar la api getDIBits(). Suerte.
|
|
|
6
|
Programación / Programación Visual Basic / Re: Como desbloquear archivos bloqueados por otra Aplicación
|
en: 14 Noviembre 2012, 21:41 pm
|
Ya tengo cómo listar las aplicaciones: agregar un ListBox al proyecto para listar las apps. Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessID As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Const MAX_PATH = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szexeFile As String * MAX_PATH End Type Public Sub appList() Const PROCESS_ALL_ACCESS = 0 Dim uProcess As PROCESSENTRY32 Dim rProcessFound As Long Dim hSnapshot As Long Dim szExename As String Dim exitCode As Long Dim myProcess As Long Dim AppKill As Boolean Dim appCount As Integer Dim i As Integer On Local Error GoTo Finish appCount = 0 Const TH32CS_SNAPPROCESS As Long = 2& uProcess.dwSize = Len(uProcess) hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) rProcessFound = ProcessFirst(hSnapshot, uProcess) Do While rProcessFound i = InStr(1, uProcess.szexeFile, Chr(0)) szExename = LCase$(Left$(uProcess.szexeFile, i - 1)) List1.AddItem szExename rProcessFound = ProcessNext(hSnapshot, uProcess) Loop Call CloseHandle(hSnapshot) Finish: End Sub Private Sub Form_Load() appList End Sub
Ahora algo tedioso... modificar el code que me diste para revisar los handles (creo que se puede).
|
|
|
7
|
Sistemas Operativos / Windows / Re: Que Explorador de Archivos utilizas?
|
en: 14 Noviembre 2012, 19:27 pm
|
Gracias buen buscador de archivos ^^ que por cierto no me tomó mi microSD (C:\) y lo extraño es que sí me tomó mis 2 unidades virtuales (X:\ y B:\) que son RamDisk. Al parecer no son muchos los que usan un Administrador de Archivos diferente al Explorer.exe ...mejor para mi ^^
|
|
|
8
|
Programación / Programación Visual Basic / Re: Como desbloquear archivos bloqueados por otra Aplicación
|
en: 14 Noviembre 2012, 19:03 pm
|
Muy buen código, gracias. Pero solo desbloquea archivos abiertos desde la misma aplicación por lo que no pude eliminar otros archivos.
Mirando el source-code me doy cuenta del porqué, si pudiera revisar otros procesos para ver que archivos tienen abiertos seria una buena solución para éste codigo-fuente lo malo es que no sé como saber los archivos abiertos por otros procesos. Buscaré un poco más a ver si puedo hacer algo ^^
|
|
|
9
|
Programación / Programación Visual Basic / Como desbloquear archivos bloqueados por otra Aplicación
|
en: 14 Noviembre 2012, 06:24 am
|
Hola, después de buscar en este foro y en Google no di con la respuesta asi que pido vuestra ayuda gentiles personas.
Ya probé con UnlockFile(fp, 0,FileLen(spath), 0) y nada. MoveFileEx tampoco y no me sirve que se borre en el próximo reinicio.
Leí en un post que cobein habia hecho un código similar al de Unlocker.exe pero encontre.
De antemano Gracias ^^
|
|
|
|
|
|
|