elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


Páginas: 1 2 3 4 [5] 6 7 8 9 10
 41 
 en: 13 Abril 2024, 12:42 pm 
Iniciado por Eleкtro - Último mensaje por Songoku
Tendrás que seleccionar el idioma español en los ajustes del firefox. Creo que está en el la pestaña 'General', por ahí en lo de 'Idioma', asegúrate de que esté seleccionado el 'Español (ES)', y en lo de 'Elegir el idioma preferido para mostrar las paginas web' pica en 'Seleccionar' y pon arriba del todo los idiomas españoles.

EDITDO: bueno veo que ya e llegado tarde y mientras estaba escribiendo as editado y solucionado el tema. Creo que haciendo lo que te dicho seguramente se habría cambiado a español eso del menú contextual que as cambiado tu. Normalmente al instalar el diccionario si no hay otro idioma instalado y si tienes en las preferencias que te dicho seleccionado el idioma español pues por defecto el firefox selecciona el diccionario español y no el inglés como tu tenías.

Y ahora que me fijo... veo que tienes el firefox en inglés, luego es normal que por defecto seleccione el diccionario inglés en vez del español y que por tanto hayas tenido que tu seleccionar el español manualmente. ¿Se que no es de mi incumbencia pero por qué no te bajas e instalas el firefox en español en vez de en inglés?.
Saludos...

Songoku

 42 
 en: 13 Abril 2024, 12:28 pm 
Iniciado por Eleкtro - Último mensaje por Eleкtro
Yo también pienso que es cosa de tu navegador osea del firefox. Instálate esta extensión o mas bien diccionario: https://addons.mozilla.org/es/firefox/addon/diccionario-de-espa%C3%B1ol-espa%C3%B1a/

Songoku, ya tenía instalado ese diccionario. :-\

De todas formas lo he eliminado y vuelto a instalar. Nada, todas las palabras que estoy escribiendo ahora mismo en este post se siguen resaltando como si estuvieran mal escritas.

Y para colmo, al reinstalar la extensión, de repente me ha cambiado la fuente de texto de algunos elementos del foro (se ve con una letra difícil de leer), es alucinante, ¿¡por qué me pasa esto!?. xD Lo de la fuente de texto se ha solucionado por si solo reiniciando el proceso del navegador.



Ya he averiguado como solucionarlo. Hay que hacer click derecho sobre un espacio en blanco del editor de texto, y seleccionar el idioma Español:



Al parecer solo necesito hacerlo una vez, y ya se queda así en el foro, y al parecer este cambio solo afecta al foro, ya que en otros sitios web sigo teniendo seleccionado el idioma Inglés por defecto.

Nunca me había fijado en esa opción del menú contextual, por que nunca lo he necesitado (como ya digo en otras páginas esto no me pasa), me ha dado por mirar ahora a ver si me salía algo relevante en el menú contextual.

Qué fácil era, joder. ¡Y qué alivio!. xD

Tampoco es que le haya dado mucha importancia hasta ahora, pero se hacía incómodo escribir así.

¡Gracias a los dos por la ayuda!.

 43 
 en: 13 Abril 2024, 11:59 am 
Iniciado por Eleкtro - Último mensaje por Songoku
Yo también pienso que es cosa de tu navegador osea del firefox. Instálate esta extensión o mas bien diccionario: https://addons.mozilla.org/es/firefox/addon/diccionario-de-espa%C3%B1ol-espa%C3%B1a/
No es un corrector de terceros, es algo que necesita el firefox para cuando entras e intentas escribir en paginas en español. En paginas en inglés se te activa el corrector en ese idioma por que es el ÚNICO que lleva el propio firefox, de modo que si también escribes en paginas de otros idiomas como en este caso en español necesitas el diccionario español que te linkado antes.
Saludos...

Songoku

 44 
 en: 13 Abril 2024, 11:55 am 
Iniciado por Eleкtro - Último mensaje por Eleкtro
Lo más probable es que se pueda solucionar agregando un corrector ortográfico al navegador que utilices en cada momento. Una vez instalado hay que seleccionar el idioma, entre los instalados, que se quiera en cada momento o definir como preferido el que sea igual a la lengua que se escriba.

Pero no necesito instalar un corrector de terceros. Cuando estoy escribiendo en otra página española, se me activa automáticamente el corrector en Español. Y si estoy en una página de EEUU, se me activa el corrector en Inglés. Solo me pasa en este foro que se me activa el corrector en Inglés.

Yo supongo, en mi ignorancia, que esto se debe a Cloudflare, o lo que sea, que hace que el servidor de la página esté en EEUU:



...pero no se como solucionar este problema del correcto de forma eficiente. No se si es posible configurar el navegador para que en esta página (el foro) se me active el corrector en Español y no en Inglés, sin tener que cambiar drasticamente el corrector de forma permanente para que afecte a mi experiencia en otros sitios web.

A ver, quizás lo primero de todo que yo debería haber preguntado es: ¿soy el único al que le pasa esto (con Firefox)?, ¿a ustedes se le activa el correcto en Español en el foro?.

 45 
 en: 13 Abril 2024, 11:33 am 
Iniciado por Eleкtro - Último mensaje por nobie
Hola:

Lo más probable es que se pueda solucionar agregando un corrector ortográfico al navegador que utilices en cada momento. Una vez instalado hay que seleccionar el idioma, entre los instalados, que se quiera en cada momento o definir como preferido el que sea igual a la lengua que se escriba.

Solo hay que buscar el corrector ortográfico acorde al navegador que se tenga.

Saludos.

 46 
 en: 13 Abril 2024, 11:23 am 
Iniciado por SrTrp - Último mensaje por Eleкtro
Solución al problema

El siguiente código fuente está elaborado mediante porciones de código que he extraído y posteriormente los he combinado, de un proyecto mucho más amplio (una librería de clases comercial que tengo a la venta, por lo que no puedo compartirlo todo), y originalmente escrito en VB.NET, por lo que he tenido que convertido a C#.

Aqui está todo lo necesario para que puedas simular una pulsación o 'click' del ratón, mediante una de las siguientes funciones:

  • SimulateMouseButtonAction (que internamente llamará a la función SendMessage)
  • SimulateMouseButtonActionAsync (que internamente llamará a la función PostMessage)

Al final de este post comparto un ejemplo de como utilizar el código. Es bien sencillo.

Cabe mencionar que todo esto también podrías llevarlo a cabo utilizando la función SendInput:


De hecho, esa sería la forma óptima.

Para poder utilizar la función SendInput es necesario implementar ciertas estructuras y enumeraciones (INPUT, MOUSEINPUT, etc). Yo lo tengo todo implementado en mi librería de clases comercial, si necesitas puedo extraerlo, adaptarlo, y convertirlo a C#, pero me llevaría otro rato.

De todas formas creo que con el siguiente código es más que suficiente, ya que te debería funcionar de igual forma.

(EL SIGUIENTE CÓDIGO HA SIDO REFACTORIZADO Y PUBLICADO A LAS 16:35 HORA ESPAÑOLA, SIMPLIFICANDO Y MEJORANDO VARIOS ASPECTOS GENERALES. HE TENIDO QUE LIMITAR BASTANTE LA DOCUMENTACIÓN Y LOS ENLACES EXTERNOS, POR QUE NO CABE TODO EL CÓDIGO DEBIDO AL LÍMITE DE CARACTERES)

DevCase.cs
Código
  1. using System;
  2. using System.ComponentModel;
  3. using System.Diagnostics;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Runtime.InteropServices;
  7. using System.Security;
  8. using System.Threading;
  9. using System.Windows.Forms;
  10.  
  11. using DevCase.Win32;
  12. using DevCase.Win32.Enums;
  13.  
  14. namespace DevCase {
  15.  
  16.    namespace Core.IO.Devices.Input {
  17.  
  18.        /// <summary>
  19.        /// Provides mouse interaction related utilities.
  20.        /// </summary>
  21.        internal sealed class UtilMouse {
  22.  
  23.            /// <summary>
  24.            /// Prevents a default instance of the <see cref="UtilMouse"/> class from being created.
  25.            /// </summary>
  26.            [DebuggerNonUserCode]
  27.            private UtilMouse() { }
  28.  
  29.            /// <summary>
  30.            /// Defines a button message to send to a window.
  31.            /// </summary>
  32.            internal enum MouseButtonMessage : int {
  33.  
  34.                /// <summary>
  35.                /// Hold down the left mouse button.
  36.                /// </summary>
  37.                LeftDown = WindowMessages.WM_LButtonDown,
  38.  
  39.                /// <summary>
  40.                /// Release up the left mouse button.
  41.                /// </summary>
  42.                LeftUp = WindowMessages.WM_LButtonUp,
  43.  
  44.                /// <summary>
  45.                /// Hold down the right mouse button.
  46.                /// </summary>
  47.                RightDown = WindowMessages.WM_RButtonDown,
  48.  
  49.                /// <summary>
  50.                /// Release up the right mouse button.
  51.                /// </summary>
  52.                RightUp = WindowMessages.WM_RButtonUp,
  53.  
  54.                /// <summary>
  55.                /// Hold down the middle mouse button.
  56.                /// </summary>
  57.                MiddleDown = WindowMessages.WM_MButtonDown,
  58.  
  59.                /// <summary>
  60.                /// Release up the middle mouse button.
  61.                /// </summary>
  62.                MiddleUp = WindowMessages.WM_MButtonUp,
  63.  
  64.                /// <summary>
  65.                /// Move down the mouse wheel.
  66.                /// </summary>
  67.                WheelDown,
  68.  
  69.                /// <summary>
  70.                /// Move up the mouse wheel.
  71.                /// </summary>
  72.                WheelUp,
  73.  
  74.                /// <summary>
  75.                /// Tilt horizontal mouse wheel to left.
  76.                /// </summary>
  77.                WheelLeft,
  78.  
  79.                /// <summary>
  80.                /// Tilt horizontal mouse wheel to right.
  81.                /// </summary>
  82.                WheelRight
  83.  
  84.            }
  85.  
  86.            /// <summary>
  87.            /// Defines a click of a mouse button.
  88.            /// </summary>
  89.            internal enum MouseButtonClick : int {
  90.  
  91.                /// <summary>
  92.                /// Left mouse button click.
  93.                /// </summary>
  94.                LeftButton,
  95.  
  96.                /// <summary>
  97.                /// Right mouse button click.
  98.                /// </summary>
  99.                RightButton,
  100.  
  101.                /// <summary>
  102.                /// Middle mouse button click.
  103.                /// </summary>
  104.                MiddleButton
  105.            }
  106.  
  107.            /// <summary>
  108.            /// Sends a mouse button message to the specified window,
  109.            /// on the specified coordinates relative to its client-area,
  110.            /// by calling <see cref="Win32.NativeMethods.SendMessage"/> function.
  111.            /// </summary>
  112.            ///
  113.            /// <param name="hWnd">
  114.            /// A handle to the target window.
  115.            /// </param>
  116.            ///
  117.            /// <param name="button">
  118.            /// The mouse button message to send.
  119.            /// </param>
  120.            ///
  121.            /// <param name="pt">
  122.            /// The coordinates within the client area of the window,
  123.            /// where to send the mouse button message.
  124.            /// </param>
  125.            ///
  126.            /// <returns>
  127.            /// <see langword="True"/> if the function succeeds; otherwise, <see langword="False"/>.
  128.            /// </returns>
  129.            [DebuggerStepThrough]
  130.            internal static bool SendMouseButtonMessage(IntPtr hWnd, MouseButtonMessage button, Point pt) {
  131.                return UtilMouse.SendMouseButtonMessage_Internal(hWnd, button, pt, async: false);
  132.            }
  133.  
  134.            /// <summary>
  135.            /// Asynchronouslly sends a mouse button message to the specified window,
  136.            /// on the specified coordinates relative to its client-area,
  137.            /// by calling <see cref="Win32.NativeMethods.PostMessage"/> function.
  138.            /// </summary>
  139.            ///
  140.            /// <param name="hWnd">
  141.            /// A handle to the target window.
  142.            /// </param>
  143.            ///
  144.            /// <param name="button">
  145.            /// The mouse button message to send.
  146.            /// </param>
  147.            ///
  148.            /// <param name="pt">
  149.            /// The coordinates within the client area of the window,
  150.            /// where to send the mouse button message.
  151.            /// </param>
  152.            ///
  153.            /// <returns>
  154.            /// <see langword="True"/> if the function succeeds; otherwise, <see langword="False"/>.
  155.            /// </returns>
  156.            [DebuggerStepThrough]
  157.            internal static bool SendMouseButtonMessageAsync(IntPtr hWnd, MouseButtonMessage button, Point pt) {
  158.                return UtilMouse.SendMouseButtonMessage_Internal(hWnd, button, pt, async: true);
  159.            }
  160.  
  161.            /// <summary>
  162.            /// Sends a mouse button click to the specified window,
  163.            /// on the specified coordinates relative to its client-area,
  164.            /// by calling <see cref="Win32.NativeMethods.SendMessage"/> function.
  165.            /// </summary>
  166.            ///
  167.            /// <param name="hWnd">
  168.            /// A handle to the target window.
  169.            /// </param>
  170.            ///
  171.            /// <param name="button">
  172.            /// The mouse button click to send.
  173.            /// </param>
  174.            ///
  175.            /// <param name="pt">
  176.            /// The coordinates within the client area of the window,
  177.            /// where to send the mouse button click.
  178.            /// </param>
  179.            ///
  180.            /// <returns>
  181.            /// <see langword="True"/> if the function succeeds; otherwise, <see langword="False"/>.
  182.            /// </returns>
  183.            [DebuggerStepThrough]
  184.            internal static bool SendMouseButtonClick(IntPtr hWnd, MouseButtonClick button, Point pt) {
  185.                return UtilMouse.SendMouseButtonClick_Internal(hWnd, button, pt, async: false);
  186.            }
  187.  
  188.            /// <summary>
  189.            /// Asynchronouslly sends a mouse button click to the specified window,
  190.            /// on the specified coordinates relative to its client-area,
  191.            /// by calling <see cref="Win32.NativeMethods.PostMessage"/> function.
  192.            /// </summary>
  193.            ///
  194.            /// <param name="hWnd">
  195.            /// A handle to the target window.
  196.            /// </param>
  197.            ///
  198.            /// <param name="button">
  199.            /// The mouse button click to send.
  200.            /// </param>
  201.            ///
  202.            /// <param name="pt">
  203.            /// The coordinates within the client area of the window,
  204.            /// where to send the mouse button click.
  205.            /// </param>
  206.            ///
  207.            /// <returns>
  208.            /// <see langword="True"/> if the function succeeds; otherwise, <see langword="False"/>.
  209.            /// </returns>
  210.            [DebuggerStepThrough]
  211.            internal static bool SendMouseButtonClickAsync(IntPtr hWnd, MouseButtonClick button, Point pt) {
  212.                return UtilMouse.SendMouseButtonClick_Internal(hWnd, button, pt, async: true);
  213.            }
  214.  
  215.            /// <summary>
  216.            /// *** FOR INTERNAL USE ONLY ***
  217.            /// <para></para>
  218.            /// Sends a mouse button message to the specified window,
  219.            /// on the specified coordinates relative to its client-area.
  220.            /// </summary>
  221.            ///
  222.            /// <param name="hWnd">
  223.            /// A handle to the target window.
  224.            /// </param>
  225.            ///
  226.            /// <param name="button">
  227.            /// The mouse button message to send.
  228.            /// </param>
  229.            ///
  230.            /// <param name="pt">
  231.            /// The coordinates within the client area of the window,
  232.            /// where to send the mouse button message.
  233.            /// </param>
  234.            ///
  235.            /// <param name="async">
  236.            /// If <see langword="True"/>, calls PostMessage function rather than SendMessage.
  237.            /// </param>
  238.            ///
  239.            /// <returns>
  240.            /// <see langword="True"/> if the function succeeds; otherwise, <see langword="False"/>.
  241.            /// </returns>
  242.            private static bool SendMouseButtonMessage_Internal(IntPtr hWnd, MouseButtonMessage button, Point pt, bool async) {
  243.  
  244.                if (pt == null) {
  245.                    pt = Point.Empty;
  246.                }
  247.  
  248.                Delegate msgFunc = async ?
  249.                    (Delegate)(new Func<IntPtr, WindowMessages, IntPtr, IntPtr, bool>(NativeMethods.PostMessage)) :
  250.                    (Delegate)(new Func<IntPtr, WindowMessages, IntPtr, IntPtr, IntPtr>(NativeMethods.SendMessage));
  251.  
  252.                WindowMessages msg = (WindowMessages)button;
  253.                IntPtr lParam = UtilWin32.MakeLParam(pt.X, pt.Y);
  254.                IntPtr wParam = System.IntPtr.Zero;
  255.  
  256.                switch (button) {
  257.                    case MouseButtonMessage.LeftUp:
  258.                    case MouseButtonMessage.RightUp:
  259.                    case MouseButtonMessage.MiddleUp:
  260.                        wParam = IntPtr.Zero;
  261.                        break;
  262.  
  263.                    case MouseButtonMessage.LeftDown:
  264.                        wParam = new IntPtr((int)WParams.MK_LButton);
  265.                        break;
  266.  
  267.                    case MouseButtonMessage.RightDown:
  268.                        wParam = new IntPtr((int)WParams.MK_RButton);
  269.                        break;
  270.  
  271.                    case MouseButtonMessage.MiddleDown:
  272.                        wParam = new IntPtr((int)WParams.MK_MButton);
  273.                        break;
  274.  
  275.                    case MouseButtonMessage.WheelDown:
  276.                        msg = WindowMessages.WM_MouseWheel;
  277.                        wParam = UtilWin32.MakeLParam(0, -120);
  278.                        break;
  279.  
  280.                    case MouseButtonMessage.WheelUp:
  281.                        msg = WindowMessages.WM_MouseWheel;
  282.                        wParam = UtilWin32.MakeLParam(0, 120);
  283.                        break;
  284.  
  285.                    case MouseButtonMessage.WheelLeft:
  286.                        msg = WindowMessages.WM_MouseHWheel;
  287.                        wParam = UtilWin32.MakeLParam(0, -120);
  288.                        break;
  289.  
  290.                    case MouseButtonMessage.WheelRight:
  291.                        msg = WindowMessages.WM_MouseHWheel;
  292.                        wParam = UtilWin32.MakeLParam(0, 120);
  293.                        break;
  294.  
  295.                    default:
  296.                        throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(MouseButtonMessage));
  297.                }
  298.  
  299.                // Ensures the target window has focus.
  300.                NativeMethods.SetFocus(hWnd);
  301.  
  302.                object success = msgFunc.DynamicInvoke(hWnd, msg, wParam, lParam);
  303.                return (async ? (bool)success : (IntPtr)success == IntPtr.Zero);
  304.            }
  305.  
  306.            /// <summary>
  307.            /// *** FOR INTERNAL USE ONLY ***
  308.            /// <para></para>
  309.            /// Sends a mouse button click to the specified window,
  310.            /// on the specified coordinates relative to its client-area.
  311.            /// </summary>
  312.            ///
  313.            /// <param name="hWnd">
  314.            /// A handle to the target window.
  315.            /// </param>
  316.            ///
  317.            /// <param name="button">
  318.            /// The mouse button click to send.
  319.            /// </param>
  320.            ///
  321.            /// <param name="pt">
  322.            /// The coordinates within the client area of the window,
  323.            /// where to send the mouse button click.
  324.            /// </param>
  325.            ///
  326.            /// <param name="async">
  327.            /// If <see langword="True"/>, calls PostMessage function rather than SendMessage.
  328.            /// </param>
  329.            ///
  330.            /// <returns>
  331.            /// <see langword="True"/> if the function succeeds; otherwise, <see langword="False"/>.
  332.            /// </returns>
  333.            private static bool SendMouseButtonClick_Internal(IntPtr hWnd, MouseButtonClick button, Point pt, bool async) {
  334.  
  335.                MouseButtonMessage msgButtonDown;
  336.                MouseButtonMessage msgButtonUp;
  337.  
  338.                switch (button) {
  339.                    case MouseButtonClick.LeftButton:
  340.                        msgButtonDown = MouseButtonMessage.LeftDown;
  341.                        msgButtonUp = MouseButtonMessage.LeftUp;
  342.                        break;
  343.  
  344.                    case MouseButtonClick.RightButton:
  345.                        msgButtonDown = MouseButtonMessage.RightDown;
  346.                        msgButtonUp = MouseButtonMessage.RightUp;
  347.                        break;
  348.  
  349.                    case MouseButtonClick.MiddleButton:
  350.                        msgButtonDown = MouseButtonMessage.MiddleDown;
  351.                        msgButtonUp = MouseButtonMessage.MiddleUp;
  352.                        break;
  353.  
  354.                    default:
  355.                        throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(MouseButtonClick));
  356.                }
  357.  
  358.                // Milliseconds to wait between sequentially sendig WM_#BUTTON_DOWN + WM_#BUTTON_UP message combination.
  359.                const int msgIntervalMs = 100;
  360.  
  361.                bool successButtonDown = UtilMouse.SendMouseButtonMessage_Internal(hWnd, msgButtonDown, pt, async);
  362.                Thread.Sleep(msgIntervalMs);
  363.                bool successButtonUp = UtilMouse.SendMouseButtonMessage_Internal(hWnd, msgButtonUp, pt, async);
  364.  
  365.                return successButtonDown & successButtonUp;
  366.            }
  367.  
  368.        }
  369.  
  370.    }
  371.  
  372.    namespace Win32 {
  373.  
  374.        /// <summary>
  375.        /// Platform Invocation (P/Invoke) methods, access unmanaged code.
  376.        /// </summary>
  377.        [SuppressUnmanagedCodeSecurity]
  378.        internal sealed class NativeMethods {
  379.  
  380.            /// <summary>
  381.            /// Prevents a default instance of the <see cref="NativeMethods"/> class from being created.
  382.            /// </summary>
  383.            [DebuggerNonUserCode]
  384.            private NativeMethods() { }
  385.  
  386.            #region  User32.dll
  387.  
  388.            /// <summary>
  389.            /// Sets the keyboard focus to the specified window.
  390.            /// <para></para>
  391.            /// The window must be attached to the calling thread's message queue.
  392.            /// </summary>
  393.            ///
  394.            /// <param name="hWnd">
  395.            /// A handle to the window that will receive the keyboard input.
  396.            /// <para></para>
  397.            /// If this parameter is <see cref="IntPtr.Zero"/>, keystrokes are ignored.
  398.            /// </param>
  399.            ///
  400.            /// <returns>
  401.            /// If the function succeeds, the return value is the handle to the window that previously had the keyboard focus.
  402.            /// <para></para>
  403.            /// If the <paramref name="hWnd"/> parameter is invalid or
  404.            /// the window is not attached to the calling thread's message queue,
  405.            /// the return value is <see cref="IntPtr.Zero"/>.
  406.            /// <para></para>
  407.            /// To get extended error information, call <see cref="Marshal.GetLastWin32Error"/>.
  408.            /// </returns>
  409.            [DllImport("User32.dll", SetLastError = true)]
  410.            internal static extern IntPtr SetFocus([In, Optional] IntPtr hWnd);
  411.  
  412.            /// <summary>
  413.            /// Sends the specified message to a window or windows.
  414.            /// <para></para>
  415.            /// The SendMessage function calls the window procedure for the specified window
  416.            /// and does not return until the window procedure has processed the message.
  417.            /// </summary>
  418.            ///
  419.            /// <param name="hWnd">
  420.            /// A handle to the window whose window procedure will receive the message.
  421.            /// </param>
  422.            ///
  423.            /// <param name="msg">
  424.            /// The message to be sent.
  425.            /// </param>
  426.            ///
  427.            /// <param name="wParam">
  428.            /// Additional message-specific information.
  429.            /// </param>
  430.            ///
  431.            /// <param name="lParam">
  432.            /// Additional message-specific information.
  433.            /// </param>
  434.            ///
  435.            /// <returns>
  436.            /// The return value specifies the result of the message processing; it depends on the message sent.
  437.            /// </returns>
  438.            [DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto, SetLastError = true)]
  439.            [return: MarshalAs(UnmanagedType.SysInt)]
  440.            internal static extern IntPtr SendMessage([In, MarshalAs(UnmanagedType.SysInt)] IntPtr hWnd,
  441.                                                      [In, MarshalAs(UnmanagedType.I4)] WindowMessages msg,
  442.                                                      [In, MarshalAs(UnmanagedType.SysInt)] IntPtr wParam,
  443.                                                      [In, MarshalAs(UnmanagedType.SysInt)] IntPtr lParam);
  444.  
  445.            /// <summary>
  446.            /// Places (posts) a message in the message queue associated with the thread that created
  447.            /// the specified window and returns without waiting for the thread to process the message.
  448.            /// </summary>
  449.            ///
  450.            /// <param name="hWnd">
  451.            /// Handle to the window whose window procedure will receive the message.
  452.            /// <para></para>
  453.            /// If this parameter is WindowMessages.HWND_Broadcast,
  454.            /// the message is sent to all top-level windows in the system,
  455.            /// including disabled or invisible unowned windows, overlapped windows, and pop-up windows;
  456.            /// but the message is not sent to child windows.
  457.            /// </param>
  458.            ///
  459.            /// <param name="msg">
  460.            /// The message to be sent.
  461.            /// </param>
  462.            ///
  463.            /// <param name="wparam">
  464.            /// Additional message-specific information.
  465.            /// </param>
  466.            ///
  467.            /// <param name="lparam">
  468.            /// Additional message-specific information.
  469.            /// </param>
  470.            ///
  471.            /// <returns>
  472.            /// If the function succeeds, the return value is <see langword="true"/>.
  473.            /// <para></para>
  474.            /// If the function fails, the return value is <see langword="false"/>.
  475.            /// <para></para>
  476.            /// To get extended error information, call <see cref="Marshal.GetLastWin32Error"/>.
  477.            /// </returns>
  478.            [DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto, SetLastError = true)]
  479.            [return: MarshalAs(UnmanagedType.Bool)]
  480.            internal static extern bool PostMessage([In, Optional, MarshalAs(UnmanagedType.SysInt)] IntPtr hWnd,
  481.                                                    [In, MarshalAs(UnmanagedType.I4)] WindowMessages msg,
  482.                                                    [In, MarshalAs(UnmanagedType.SysInt)] IntPtr wparam,
  483.                                                    [In, MarshalAs(UnmanagedType.SysInt)] IntPtr lparam);
  484.  
  485.            #endregion
  486.        }
  487.  
  488.        /// <summary>
  489.        /// Provides Windows API related utilites.
  490.        /// </summary>
  491.        internal sealed class UtilWin32 {
  492.  
  493.            /// <summary>
  494.            /// Prevents a default instance of the <see cref="UtilWin32"/> class from being created.
  495.            /// </summary>
  496.            [DebuggerNonUserCode]
  497.            private UtilWin32() { }
  498.  
  499.            /// <summary>
  500.            /// Creates a LONG Param (LParam) value for a window message, from two <see cref="Integer"/> values.
  501.            /// <para></para>
  502.            /// You must call this method if you need to use negative values.
  503.            /// <para></para>
  504.            /// <seealso cref="Message.LParam"/>
  505.            /// </summary>
  506.            ///
  507.            /// <remarks>
  508.            /// <see href="https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-makelparam"/>
  509.            /// </remarks>
  510.            ///
  511.            /// <example> This is a code example.
  512.            /// <code language="VB.NET">
  513.            /// Dim lParam as IntPtr = MakeLParam(Integer.MaxValue, Integer.MaxValue)
  514.            /// </code>
  515.            /// </example>
  516.            ///
  517.            /// <param name="lo">
  518.            /// The low-order <see cref="Integer"/> value.
  519.            /// </param>
  520.            ///
  521.            /// <param name="hi">
  522.            /// The high-order <see cref="Integer"/> value.
  523.            /// </param>
  524.            ///
  525.            /// <returns>
  526.            /// The resulting LParam value.
  527.            /// </returns>
  528.            [DebuggerStepThrough]
  529.            internal static IntPtr MakeLParam(int lo, int hi) {
  530.                byte[] loBytes = { BitConverter.GetBytes(lo)[0], BitConverter.GetBytes(lo)[1] };
  531.                byte[] hiBytes = { BitConverter.GetBytes(hi)[0], BitConverter.GetBytes(hi)[1] };
  532.                byte[] combined = loBytes.Concat(hiBytes).ToArray();
  533.  
  534.                return new IntPtr(BitConverter.ToInt32(combined, 0));
  535.            }
  536.  
  537.            /// <summary>
  538.            /// Creates a LONG Param (LParam) value for a window message, from two <see cref="UShort"/> values.
  539.            /// <para></para>
  540.            /// <seealso cref="Message.LParam"/>
  541.            /// </summary>
  542.            ///
  543.            /// <remarks>
  544.            /// <see href="https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-makelparam"/>
  545.            /// </remarks>
  546.            ///
  547.            /// <example> This is a code example.
  548.            /// <code language="VB.NET">
  549.            /// Dim lParam as IntPtr = MakeLParam(UShort.MaxValue, UShort.MaxValue)
  550.            /// </code>
  551.            /// </example>
  552.            ///
  553.            /// <param name="loWord">
  554.            /// The low-order WORD value.
  555.            /// </param>
  556.            ///
  557.            /// <param name="hiWord">
  558.            /// The high-order WORD value.
  559.            /// </param>
  560.            ///
  561.            /// <returns>
  562.            /// The resulting LParam value.
  563.            /// </returns>
  564.            [DebuggerStepThrough]
  565.            internal static IntPtr MakeLParam(ushort loWord, ushort hiWord) {
  566.                return new IntPtr(UtilWin32.MakeDWord(loWord, hiWord));
  567.            }
  568.  
  569.            /// <summary>
  570.            /// Creates a Double WORD (DWORD, 32-Bit Unsigned Integer) value from a LOWORD and a HIWORD value.
  571.            /// </summary>
  572.            ///
  573.            /// <example> This is a code example.
  574.            /// <code language="VB.NET">
  575.            /// Dim value as UInteger = MakeDWord(UShort.MaxValue, UShort.MaxValue)
  576.            /// </code>
  577.            /// </example>
  578.            ///
  579.            /// <param name="loWord">
  580.            /// The low-order WORD.
  581.            /// </param>
  582.            ///
  583.            /// <param name="hiWord">
  584.            /// The high-order WORD.
  585.            /// </param>
  586.            ///
  587.            /// <returns>
  588.            /// The resulting DWORD value.
  589.            /// </returns>
  590.            [DebuggerStepThrough]
  591.            internal static uint MakeDWord(ushort loWord, ushort hiWord) {
  592.                byte[] loBytes = BitConverter.GetBytes(loWord);
  593.                byte[] hiBytes = BitConverter.GetBytes(hiWord);
  594.                byte[] combined = loBytes.Concat(hiBytes).ToArray();
  595.  
  596.                return BitConverter.ToUInt32(combined, 0);
  597.            }
  598.        }
  599.    }
  600.  
  601.    namespace Win32.Enums {
  602.  
  603.        /// <summary>
  604.        /// Defines additional message-specific information for the WORD Param (WParam) value of window messages.
  605.        /// </summary>
  606.        ///
  607.        /// <remarks>
  608.        /// <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms644927%28v=vs.85%29.aspx#system_defined"/>
  609.        /// </remarks>
  610.        internal enum WParams : int {
  611.            /// <summary>
  612.            /// A null WParam.
  613.            /// </summary>
  614.            Null = 0x0,
  615.  
  616.            /// <summary>
  617.            /// The left mouse button is down.
  618.            /// <para></para>
  619.            /// wParam to use with <see cref="WindowMessages.WM_LButtonDown"/> message.
  620.            /// </summary>
  621.            MK_LButton = 0x1,
  622.  
  623.            /// <summary>
  624.            /// The middle mouse button is down.
  625.            /// <para></para>
  626.            /// wParam to use with <see cref="WindowMessages.WM_LButtonDown"/> and <see cref="WindowMessages.WM_LButtonUp"/> messages.
  627.            /// </summary>
  628.            MK_MButton = 0x10,
  629.  
  630.            /// <summary>
  631.            /// The right mouse button is down.
  632.            /// <para></para>
  633.            /// wParam to use with <see cref="WindowMessages.WM_LButtonDown"/> and <see cref="WindowMessages.WM_LButtonUp"/> messages.
  634.            /// </summary>
  635.            MK_RButton = 0x2
  636.        }
  637.  
  638.        /// <summary>
  639.        /// Defines window messages.
  640.        /// <para></para>
  641.        /// The system sends or posts a system-defined message when it communicates with an application.
  642.        /// <para></para>
  643.        /// It uses these messages to control the operations of applications and to provide input and other information for applications to process.
  644.        /// <para></para>
  645.        /// An application can also send or post system-defined messages.
  646.        /// <para></para>
  647.        /// Applications generally use these messages to control the operation of control windows created by using preregistered window classes.
  648.        /// </summary>
  649.        ///
  650.        /// <remarks>
  651.        /// <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms644927%28v=vs.85%29.aspx"/>
  652.        /// </remarks>
  653.        internal enum WindowMessages : int {
  654.  
  655.            /// <summary>
  656.            /// The message is posted when the user presses the left mouse button while the cursor is in the
  657.            /// client area of a window.
  658.            /// <para></para>
  659.            /// If the mouse is not captured the message is posted to the window beneath the cursor.
  660.            /// <para></para>
  661.            /// Otherwise the message is posted to the window that has captured the mouse.
  662.            /// </summary>
  663.            WM_LButtonDown = 0x201,
  664.  
  665.            /// <summary>
  666.            /// The message is posted when the user releases the left mouse button while the cursor is in the
  667.            /// client area of a window.
  668.            /// <para></para>
  669.            /// If the mouse is not captured the message is posted to the window beneath the cursor.
  670.            /// <para></para>
  671.            /// Otherwise the message is posted to the window that has captured the mouse.
  672.            /// </summary>
  673.            WM_LButtonUp = 0x202,
  674.  
  675.            /// <summary>
  676.            /// The message is posted when the user presses the middle mouse button while the cursor is in the
  677.            /// client area of a window.
  678.            /// <para></para>
  679.            /// If the mouse is not captured the message is posted to the window beneath the cursor.
  680.            /// <para></para>
  681.            /// Otherwise the message is posted to the window that has captured the mouse.
  682.            /// </summary>
  683.            WM_MButtonDown = 0x207,
  684.  
  685.            /// <summary>
  686.            /// The message is posted when the user releases the middle mouse button while the cursor is in the
  687.            /// client area of a window.
  688.            /// <para></para>
  689.            /// If the mouse is not captured the message is posted to the window beneath the cursor.
  690.            /// <para></para>
  691.            /// Otherwise the message is posted to the window that has captured the mouse.
  692.            /// </summary>
  693.            WM_MButtonUp = 0x208,
  694.  
  695.            /// <summary>
  696.            /// The message is posted when the user presses the right mouse button while the cursor is in the
  697.            /// client area of a window.
  698.            /// <para></para>
  699.            /// If the mouse is not captured the message is posted to the window beneath the cursor.
  700.            /// <para></para>
  701.            /// Otherwise the message is posted to the window that has captured the mouse.
  702.            /// </summary>
  703.            WM_RButtonDown = 0x204,
  704.  
  705.            /// <summary>
  706.            /// The message is posted when the user releases the right mouse button while the cursor is in the
  707.            /// client area of a window.
  708.            /// <para></para>
  709.            /// If the mouse is not captured the message is posted to the window beneath the cursor.
  710.            /// <para></para>
  711.            /// Otherwise the message is posted to the window that has captured the mouse.
  712.            /// </summary>
  713.            WM_RButtonUp = 0x205,
  714.  
  715.            /// <summary>
  716.            /// Posted when the user presses the first or second X button while the cursor is in the client area of a window.
  717.            /// <para></para>
  718.            /// If the mouse is not captured, the message is posted to the window beneath the cursor.
  719.            /// <para></para>
  720.            /// Otherwise, the message is posted to the window that has captured the mouse.
  721.            /// </summary>
  722.            WM_XButtonDown = 0x20B,
  723.  
  724.            /// <summary>
  725.            /// Posted when the user releases the first or second X button while the cursor is in the client area of a window.
  726.            /// <para></para>
  727.            /// If the mouse is not captured, the message is posted to the window beneath the cursor.
  728.            /// <para></para>
  729.            /// Otherwise, the message is posted to the window that has captured the mouse.
  730.            /// </summary>
  731.            WM_XButtonUp = 0x20C,
  732.  
  733.            /// <summary>
  734.            /// The message is sent to the focus window when the mouse wheel is rotated.
  735.            /// <para></para>
  736.            /// The <c>DefWindowProc</c> function propagates the message to the window's parent.
  737.            /// <para></para>
  738.            /// There should be no internal forwarding of the message since <c>DefWindowProc</c> propagates it up the
  739.            /// parent chain until it finds a window that processes it.
  740.            /// </summary>
  741.            WM_MouseWheel = 0x20A,
  742.  
  743.            /// <summary>
  744.            /// The message is sent to the focus window when the mouse's horizontal scroll wheel is tilted or rotated.
  745.            /// <para></para>
  746.            /// The <c>DefWindowProc</c> function propagates the message to the window's parent.
  747.            /// <para></para>
  748.            /// There should be no internal forwarding of the message since <c>DefWindowProc</c> propagates it up
  749.            /// the parent chain until it finds a window that processes it.
  750.            /// </summary>
  751.            WM_MouseHWheel = 0x20E
  752.  
  753.        }
  754.  
  755.    }
  756.  
  757. }



Ejemplo de uso:

Código
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. using DevCase.Core.IO.Devices.Input;
  6.  
  7. namespace WindowsFormsApp1 {
  8.  
  9.    public partial class Form1 : Form {
  10.        public Form1() {
  11.            this.InitializeComponent();
  12.        }
  13.  
  14.        private void Button1_Click(object sender, EventArgs e) {
  15.            IntPtr hWnd = this.button2.Handle;
  16.            Point pt = Point.Empty;
  17.            bool success = UtilMouse.SendMouseButtonClick(hWnd, MouseButtonClick.LeftButton, pt);
  18.  
  19.            // O también:
  20.            // bool success =
  21.            //     UtilMouse.SendMouseButtonMessage(hWnd, MouseButtonMessage.LeftDown, point) &
  22.            //     UtilMouse.SendMouseButtonMessage(hWnd, MouseButtonMessage.LeftUp, point);
  23.  
  24.            Console.WriteLine($"{nameof(success)}: {success}");
  25.        }
  26.  
  27.        private void Button2_Click(object sender, EventArgs e) {
  28.            MessageBox.Show("Button Clicked!");
  29.        }
  30.    }
  31. }

Aténtamente,
Elektro.

 47 
 en: 13 Abril 2024, 11:17 am 
Iniciado por SrTrp - Último mensaje por Eleкtro
Claves para entender el manejo de mensajes de ventana y sus parámetros

1. La diferencia entre las funciones SendMessage y PostMessage es que la primera es sincrónica, y la otra es asincrónica. Es decir, SendMessage encola un mensaje en la cola de mensajes de la ventana objetivo, y no retorna hasta que la ventana haya terminado de procesar el mensaje. Por otro lado, PostMessage retorna inmediatamente tras haber encolado el mensaje, y esto significa que el mensaje de ventana puede no ser procesado de inmediato después de haber retornado.

2. El valor de retorno de las funciones SendMessage y PostMessage son muy distintos, puesto que el propósito de estas funciones es igual de distinto, como ya expliqué en el punto anterior. La función SendMessage devuelve un valor específico que depende del mensaje de ventana enviado, mientras que la función PostMessage devuelve un valor booleano indicando si el mensaje de ventana se encoló de forma satisfactoria. El valor de retorno de la función PostMessage no indica el éxito del mensaje procesado, de hecho, no está asegurado que el mensaje sea procesado.

Esa es su principal diferencia, y ello deriva en que algunas personas - sin suficiente entendimiento - acaben experimentando y utilizando PostMessage de forma incorrecta, esperando resultados que no van a obtener, para acabar concluyendo, de forma equivocada, que PostMessage no funciona como debería.

3. Las coordenadas que estás utilizando son relativas al área cliente de la ventana objetivo, no a la pantalla del monitor. Es decir, las coordenadas 0,0 (x,y) hacen referencia a la esquina superior izquierda del área cliente de la ventana objetivo. Del mismo, modo, la distancia de las coordenadas 500,500 que pusiste como ejemplo, se miden desde la esquina superior izquierda (coordenadas 0,0) de la ventana objetivo.

4. La función MakeLParam de la que hablaste, es una implementación de la macro MAKELPARAM para C++, que toma como parámetros dos valores (en este caso, dos coordenadas, x e y) para combinarlos en un único valor de 32 bits, definido como "LPARAM"; y este valor "LPARAM" (combinación de las coordenadas x e y) es el que hay que utilizar en el parámetro lParam de las funciones Sendmessage y PostMessage (entre otras varias funciones) al usar los mensajes de ventana para simular las pulsaciones de los botones del ratón WM_LBUTTONDOWN, WM_LBUTTONUP, etc.

5. El tipo de valores que se deben utilizar en los parámetros lParam y wParam de las funciones SendMessage y PostMessage siempre dependerá del mensaje de ventana en cuestión.

En el sitio web de Microsoft siempre podrás encontrar a tu disposición la documentación necesaria para entender como se debe utilizar cada mensaje de ventana, donde se especificará el tipo de valor que se debe utilizar para los parámetros lParam y wParam en caso de que se deban usar para ese mensaje.

Te invito a que leas la documentación de los mensajes de ventana WM_LBUTTONDOWN y WM_LBUTTONUP:


CONTINÚO EN EL SIGUIENTE POST, POR QUE EL FORO TIENE UN LÍMITE DE CARACTERES, ASÍ QUE NO ME CABE TODA LA RESPUESTA EN ESTE POST.  :rolleyes:

 48 
 en: 13 Abril 2024, 11:08 am 
Iniciado por Eleкtro - Último mensaje por Eleкtro
Este problema me sucede desde... no sé, desde hace años, pero no me ha dado por pedir ayuda, hasta ahora.

Quien me conozca un poco sabrá que suelo editar mucho mis posts, para corregir faltas, mejorar la redacción, añadir o borrar información (y a veces, cosas que me arrepiento de haber escrito tras haber reflexionado un poco xD), y cosas así. En parte es por que soy (o me considero) perfeccionista, y en parte también es por este problema que voy a explicar, que no me ayuda en nada para darme cuenta de algunos errores ortográficos o algunas teclas que acabo tecleando sin pretender hacerlo...

El caso es que, siempre que escribo algo en el foro, se me activa de forma automática el corrector de palabras EN INGLÉS.

Y no sé por qué se activa en Inglés, pero creo que no es una configuración de mi navegador (Firefox), por que en el resto de páginas no me sucede esto, solo en el foro.

Y entonces, cuando escribo algo, prácticamente todas las palabras en Español me aparecen así como si estuvieran mal escritas:



¿Alguien tiene idea de como puedo hacer para que se active el corrector en Español, o desactivarlo del todo (solo para el foro)?.

Gracias.

 49 
 en: 13 Abril 2024, 04:34 am 
Iniciado por Tachikomaia - Último mensaje por Tachikomaia
Por ejemplo en Paint de Windows 7 tengo una imagen de 462x230 pixeles, la copio.

La pego en Macromedia Flash 5 y queda 346.8x172.1 y para colmo reflejada verticalmente, de cabeza.

Si la pego en Word 2013 y desde ahí la copio y la pego en Flash queda de 720x368 (no reflejada).

No sé qué explicación o lógica tiene eso. Se puede arreglar en Flash pero si tengo muchas imágenes a copiar y pegar quisiera un método más rápido. Tengo una imagen de Paint a la que quiero ir copiando distintas partes, si no fuese por eso la abriría con Chrome, la copiaba entera y de ahí al ponerla en Flash queda bien. Pero no puedo pegar un trozo en Chrome ¿no? Tampoco quiero guardar esos trozos en Paint, abrirlos con  Chrome, y copiarlos de ahí a Flash.

Yo antes usaba algún programa como puente, no sé si Photoed.

Las preguntas son ¿por qué se cambia el tamaño e incluso la rotación cuando se copia desde Paint? Desde Word también, se cambia distinto. Desde Chrome no ¿por qué?
¿Con qué puedo copiar los trozos y pegarlos directamente en Flash y que queden bien? ¿o qué programa puedo usar de puente para pegarlos ahí, copiarlos de ahí y que se peguen como deben en Flash?

Puedo abrir la imagen con Flash y separarla en trozos, pero se pone un poco pesado me parece, no creo que sea buena idea.

 50 
 en: 13 Abril 2024, 03:14 am 
Iniciado por aaroncxs - Último mensaje por gmd32
https://github.com/sapics/ip-location-db

Páginas: 1 2 3 4 [5] 6 7 8 9 10
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines