zoukankan      html  css  js  c++  java
  • 鼠标自动点击

    今天突然想看下汇编.....  呵呵写的很原始..不过能用..算是我第一个WIN32汇编程序..纪念一下

      1 .686p
      2 .mmx
      3 .xmm
      4 .Model Flat, StdCall
      5 Option Casemap :None
      6 
      7 
      8 include windows.inc
      9 include user32.inc
     10 include kernel32.inc
     11 include gdi32.inc
     12 include shell32.inc
     13 
     14 
     15 includelib user32.lib
     16 includelib kernel32.lib
     17 includelib gdi32.lib
     18 includelib shell32.lib
     19 
     20 
     21 
     22 
     23 ;***************************************************************************;
     24 ICON                    equ                  100
     25 UM_HOOK                 equ                  ( WM_USER + 2001 )
     26 UM_ACTIVATE             equ                  ( WM_USER + 2002 )
     27 ;***************************************************************************;
     28 
     29 
     30 
     31 ;***************************************************************************;
     32     WinMain         PROTO :DWORD, :DWORD, :DWORD, :DWORD
     33     WndProc         PROTO :DWORD, :DWORD, :DWORD, :DWORD
     34     HookProc        proto :DWORD, :DWORD, :DWORD
     35     InstallTrayIcon proto
     36     ActiveApp       proto
     37 ;***************************************************************************;
     38 
     39 
     40 ;***************************************************************************;
     41 .const
     42     szClassName             db                   'MouseClicker_Class', 0
     43     szWndName               db                   'MouseClicker', 0
     44     szTrayIcon              db                   'WM_TRAYICON', 0
     45     szText                  db                   'F3开始, F4停止. 最小化可隐藏窗口!', 0
     46     szSingle                db                   '0x437c2a59, 0x7d09, 0x4d4d, 0x83, 0x8d, 0x21, 0xe, 0x8d, 0xa3, 0xe2, 0xec', 0
     47 ;***************************************************************************;
     48 
     49 
     50 ;***************************************************************************;
     51 .data?
     52     g_hInstance             dd                  ?
     53     g_hWnd                  dd                  ?
     54     g_wmTrayIcon            dd                  ?
     55     g_hHook                 dd                  ?
     56     g_stNotifyIconData      NOTIFYICONDATA     <?>
     57     g_run                   dd                  ?
     58     g_hMutex                dd                  ?
     59 ;***************************************************************************;
     60 
     61 
     62 .code
     63 START:
     64 
     65 ;***************************************************************************;
     66     invoke CreateMutex, NULL, 0, offset szSingle
     67     mov g_hMutex, eax
     68     .if eax == NULL
     69         invoke ExitProcess, 0
     70     .endif
     71     invoke GetLastError
     72     .if eax == ERROR_ALREADY_EXISTS
     73         invoke ActiveApp
     74         invoke ExitProcess, 0
     75     .endif
     76 
     77 
     78 
     79     invoke GetModuleHandle, NULL
     80     mov g_hInstance, eax
     81     invoke WinMain, g_hInstance, NULL, NULL, SW_SHOWDEFAULT
     82     invoke ExitProcess, 0
     83 ;***************************************************************************;
     84 
     85 
     86 ;***************************************************************************;
     87 WinMain proc _hInst :DWORD, _hPrevInst :DWORD, _CmdLine :DWORD, _CmdShow :DWORD
     88     local @wc     :WNDCLASSEX
     89     local @msg    :MSG
     90 
     91     mov @wc.cbSize, sizeof WNDCLASSEX
     92     mov @wc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
     93     mov @wc.lpfnWndProc, offset WndProc
     94     mov @wc.cbClsExtra, NULL
     95     mov @wc.cbWndExtra, NULL
     96     push _hInst
     97     pop @wc.hInstance
     98     mov @wc.hbrBackground, COLOR_BTNFACE + 1
     99     mov @wc.lpszMenuName, NULL
    100     mov @wc.lpszClassName, offset szClassName
    101     invoke LoadIcon, _hInst, ICON
    102     mov @wc.hIcon, eax
    103     invoke LoadCursor, NULL, IDC_ARROW
    104     mov @wc.hCursor, eax
    105     mov @wc.hIconSm, 0
    106     invoke RegisterClassEx, addr @wc
    107     invoke CreateWindowEx, NULL, offset szClassName, offset szWndName, WS_OVERLAPPEDWINDOW and (not WS_MAXIMIZEBOX), 200, 200, 300, 100, NULL, NULL, _hInst, NULL
    108     invoke ShowWindow, g_hWnd, SW_SHOWNORMAL
    109     invoke UpdateWindow, g_hWnd
    110 
    111     StartLoop:
    112         invoke GetMessage, addr @msg, NULL, 0, 0
    113             cmp eax, 0
    114             je ExitLoop
    115                 invoke TranslateMessage, addr @msg
    116                 invoke DispatchMessage, addr @msg
    117             jmp StartLoop
    118     ExitLoop:
    119 
    120     mov eax, @msg.wParam
    121     ret
    122 WinMain endp
    123 ;***************************************************************************;
    124 
    125 
    126 ;***************************************************************************;
    127 WndProc proc _hWnd :DWORD, _uMsg :DWORD, _wParam :DWORD, _lParam :DWORD
    128     local @stPs:PAINTSTRUCT
    129     ;local @stRect:RECT
    130     local @hDc
    131     mov eax, _uMsg
    132 ;***************************************************************************;
    133     .if eax == WM_CREATE
    134         push _hWnd
    135         pop g_hWnd
    136         mov g_run, 0
    137         invoke SetProp, _hWnd, offset szSingle, 1
    138         invoke InstallTrayIcon
    139         .if eax != 0
    140             invoke SetWindowsHookEx, WH_KEYBOARD_LL, HookProc, g_hInstance, 0
    141             .if eax != 0
    142                 mov g_hHook, eax
    143                 ret
    144             .else
    145                 mov g_stNotifyIconData.uFlags, 0
    146                 invoke Shell_NotifyIcon, NIM_DELETE, offset g_stNotifyIconData
    147             .endif
    148         .endif
    149         invoke PostQuitMessage, NULL
    150 ;***************************************************************************;
    151     .elseif eax == WM_DESTROY
    152         invoke PostQuitMessage, NULL
    153 ;***************************************************************************;
    154     .elseif eax == WM_CLOSE
    155         invoke UnhookWindowsHookEx, g_hHook
    156         invoke KillTimer, _hWnd, 1
    157         mov g_stNotifyIconData.uFlags, 0
    158         invoke Shell_NotifyIcon, NIM_DELETE, offset g_stNotifyIconData
    159         invoke RemoveProp, _hWnd, offset szSingle
    160         invoke CloseHandle, g_hMutex
    161         invoke DestroyWindow, _hWnd
    162 ;***************************************************************************;
    163     .elseif eax == WM_PAINT
    164         invoke BeginPaint, _hWnd, addr @stPs
    165         mov @hDc, eax
    166         invoke SetBkMode, @hDc, TRANSPARENT
    167         ;invoke GetClientRect, _hWnd, addr @stRect
    168         ;invoke DrawText, @hDc, offset szText, -1, addr @stRect, DT_SINGLELINE or DT_CENTER or DT_VCENTER
    169         invoke TextOut, @hDc, 30, 25, offset szText, 33
    170         invoke EndPaint, _hWnd, addr @stPs
    171 ;***************************************************************************;
    172     .elseif eax == WM_SYSCOMMAND && _wParam == SC_MINIMIZE
    173         invoke ShowWindow, _hWnd, SW_HIDE
    174 ;***************************************************************************;
    175     .elseif eax == WM_TIMER
    176         invoke mouse_event, MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    177         invoke mouse_event, MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    178 ;***************************************************************************;
    179     .elseif eax == g_wmTrayIcon
    180         and _lParam, 0FFFFh
    181         .if _lParam == WM_LBUTTONDBLCLK
    182             invoke IsIconic, _hWnd
    183             .if eax != 0
    184                 invoke ShowWindow, _hWnd, SW_RESTORE
    185             .else
    186                 invoke IsWindowVisible, _hWnd
    187                 .if eax != 0
    188                     invoke ShowWindow, _hWnd, SW_HIDE
    189                 .else
    190                     invoke ShowWindow, _hWnd, SW_SHOW
    191                     invoke BringWindowToTop, _hWnd
    192                     invoke SetForegroundWindow, _hWnd
    193                 .endif
    194             .endif
    195         .endif
    196 ;***************************************************************************;
    197     .elseif eax == UM_ACTIVATE
    198         invoke IsIconic, _hWnd
    199         .if eax != 0
    200             invoke ShowWindow, _hWnd, SW_RESTORE
    201         .else
    202             invoke IsWindowVisible, _hWnd
    203             .if eax == 0
    204                 invoke ShowWindow, _hWnd, SW_SHOW
    205                 invoke BringWindowToTop, _hWnd
    206                 invoke SetForegroundWindow, _hWnd
    207             .endif
    208         .endif
    209 ;***************************************************************************;
    210     .elseif eax == UM_HOOK
    211         mov esi, _lParam
    212         assume esi : ptr KBDLLHOOKSTRUCT
    213         .if [esi].vkCode == VK_F3
    214             .if g_run == 0
    215                 mov g_run, 1
    216                 invoke SetTimer, _hWnd, 1, 99, NULL
    217             .endif
    218         .elseif [esi].vkCode == VK_F4
    219             .if g_run == 1
    220                 invoke KillTimer, _hWnd, 1
    221                 mov g_run, 0
    222             .endif
    223         .endif
    224         assume esi : nothing
    225 ;***************************************************************************;
    226     .else
    227         invoke DefWindowProc, _hWnd, _uMsg, _wParam, _lParam
    228 ;***************************************************************************;
    229     .endif
    230     ret
    231 WndProc endp
    232 ;***************************************************************************;
    233 
    234 
    235 
    236 ;***************************************************************************;
    237 HookProc proc _nCode, _wParam, _lParam
    238     invoke CallNextHookEx, g_hHook, _nCode, _wParam, _lParam
    239     push eax
    240     .if _nCode == HC_ACTION && _wParam == WM_KEYUP
    241         invoke SendMessage, g_hWnd, UM_HOOK, _wParam, _lParam
    242     .endif
    243     pop eax
    244     ret
    245 HookProc endp
    246 ;***************************************************************************;
    247 
    248 
    249 ;***************************************************************************;
    250 InstallTrayIcon proc
    251     local @dwIcon :DWORD
    252     invoke RtlZeroMemory, offset g_stNotifyIconData, sizeof g_stNotifyIconData
    253     mov g_stNotifyIconData.cbSize, sizeof g_stNotifyIconData
    254     mov g_stNotifyIconData.uFlags, NIF_MESSAGE or NIF_ICON
    255     push g_hWnd
    256     pop g_stNotifyIconData.hwnd
    257     invoke RegisterWindowMessage, offset szTrayIcon
    258     .if eax != 0
    259         mov g_stNotifyIconData.uCallbackMessage, eax
    260         mov g_wmTrayIcon, eax
    261         invoke GetSystemMetrics, SM_CXSMICON
    262         mov  @dwIcon, eax
    263         invoke LoadImage, g_hInstance, ICON, IMAGE_ICON, @dwIcon, @dwIcon, LR_DEFAULTCOLOR
    264         .if eax != 0
    265             mov g_stNotifyIconData.hIcon, eax
    266             invoke Shell_NotifyIcon, NIM_ADD, offset g_stNotifyIconData
    267         .endif
    268     .endif
    269     ret
    270 InstallTrayIcon endp
    271 ;***************************************************************************;
    272 
    273 
    274 ;***************************************************************************;
    275 ActiveApp proc
    276     local @hWndPre :DWORD
    277     invoke GetDesktopWindow
    278     invoke GetWindow, eax, GW_CHILD
    279     mov @hWndPre, eax
    280     invoke IsWindow, eax
    281     .while eax != 0
    282         invoke GetProp, @hWndPre, offset szSingle
    283         .if eax != 0
    284             invoke PostMessage, @hWndPre, UM_ACTIVATE, 0, 0
    285             .break
    286         .endif
    287         invoke GetWindow, @hWndPre, GW_HWNDNEXT
    288         mov @hWndPre, eax
    289         invoke IsWindow, eax
    290     .endw
    291     ret
    292 ActiveApp endp
    293 ;***************************************************************************;
    294 
    295 END START
  • 相关阅读:
    又发现新的QQ系统消息相关dll文件
    修改QQ版本号,解决QQ版本过低
    学DIV+CSS技术,如何入门?
    删除MSN广告及屏蔽MSN网页广告的方法
    制作网页需要掌握的几个基本技能
    陈晓薇的灿烂人生:比美丽更动人
    屏蔽QQ系统广播消息方法
    HTML结构化CSS网页布局入门指南
    Photoshop常用快捷键(逐步熟悉)
    如何去除视频上的水印?
  • 原文地址:https://www.cnblogs.com/javado/p/2815936.html
Copyright © 2011-2022 走看看