[AHK]文华财经 补数据 自动点击 下载按钮

有用文华财经 ,补数据嫌烦的吗,写了个小脚本,自动点击下载按钮

#Persistent
#Singleinstance force
#f1::
i:=0
outer:
Loop
{
    ;如果出现没有数据对话框结束点击动作循环
    IfWinExist,《文华财经》 ahk_exe wh8.exe,指定的时段没有数据。
    {
        ControlClick,Button1,《文华财经》 ahk_exe wh8.exe 
        break
    }
    ;识别 下载 按钮 状态是否可以点击
    controlget,outputvar,Enabled,,Button1,补数据 ahk_exe wh8.exe 
    if outputvar=1  ;若可以点击
    {
        ;点击下载按钮
        ControlClick,Button1,补数据 ahk_exe wh8.exe 
        i+=1
        ToolTip,已经点击%i%次。
        ;等待直到不能点击
        Loop{
            controlget,outputvar,Enabled,,Button1,补数据 ahk_exe wh8.exe 
            Sleep,500
            ControlClick,Button1,补数据 ahk_exe wh8.exe 
            Sleep,500
            ControlFocus,Button1,补数据 ahk_exe wh8.exe 
        }until outputvar=0
    }
    else                    ;若禁止点击
    {    
        ;等待直到能点击
        Loop{
            controlget,outputvar,Enabled,,Button1,补数据 ahk_exe wh8.exe 
            Sleep,1000
            ;等待过程如果提示 没有数据则结束点击动作。
            IfWinExist,《文华财经》 ahk_exe wh8.exe,指定的时段没有数据。
            {
                ControlClick,Button1,《文华财经》 ahk_exe wh8.exe 
                break outer
            }
        }until outputvar=1
    }

}
MsgBox 下载完成!
ToolTip
return





发布了333 篇原创文章 · 获赞 272 · 访问量 289万+
展开阅读全文

C# 无法获取Syslistview32 内容

11-15

``` #include <windows.h> #include <commctrl.h> TCHAR* ClassName = TEXT("FC数据下载 [运行监控] 日志检测"); //类名和窗口名 TCHAR* TitleName = TEXT("FC数据下载 [运行监控] 日志检测"); HWND hwnd; int total,column; HDC hdc; PAINTSTRUCT ps; HFONT hFont; CHAR szText[100] = TEXT("日志总数:"); CHAR hint[20]; int i; char itemText[100]={0}; LVITEM lvitem, *plvitem; char ItemBuf[512],*pItem; DWORD PID; HANDLE hProcess; static HWND hwndPB; //FC数据下载 [运行监控] CHAR hint1[20] = TEXT("成功:"); CHAR hint2[20] = TEXT("失败:"); CHAR hint3[20] = TEXT("未关闭文件:"); int a = 0; int b = 0; int c = 0; LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpszCmdLine,int nCmdShow){ HWND hwnd; //主窗口句柄,在CreateWindow中赋值 MSG msg; //消息变量,在GetMessage中使用 WNDCLASS wndclass; //窗口类 wndclass.hbrBackground = (HBRUSH)COLOR_WINDOW;//窗口背景 wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); //鼠标 wndclass.hIcon = LoadIcon(NULL,IDI_QUESTION); //图标 wndclass.lpszClassName = ClassName; //类名 wndclass.cbClsExtra = 0; //类的额外参数 wndclass.cbWndExtra = 0; //窗口的额外参数.用于基于同一窗口类的窗口各自区分. //在自定义对话框类时必须指定为DLGWINDOWEXTRA的大小 wndclass.lpszMenuName = NULL; //菜单名.可以用作子窗口的id wndclass.style =CS_HREDRAW | CS_VREDRAW; //窗口风格 wndclass.lpfnWndProc = WndProc; //窗口过程 wndclass.hInstance = hInstance; //包含窗口过程的实例句柄 if( !RegisterClass(&wndclass) ){ //注册窗口类 MessageBox(NULL, "窗口注册失败!","错误",MB_ICONEXCLAMATION|MB_OK); return 0; } hwnd = CreateWindowEx( //创建窗口 WS_EX_TOPMOST, ClassName, //窗口类名 TitleName, //窗口标题 WS_OVERLAPPEDWINDOW, //窗口风格 CW_USEDEFAULT, //初始的x坐标 CW_USEDEFAULT, //初始的y坐标 500, //初始的宽度 700, //初始的高度 NULL, //父窗口 NULL, //菜单 hInstance, //和窗口相关的实例句柄 NULL //额外参数 ); //窗口居中 RECT rect; int xLeft,yTop; GetWindowRect(hwnd,&rect); xLeft = (GetSystemMetrics(SM_CXFULLSCREEN)-(rect.right-rect.left))/2; yTop = (GetSystemMetrics(SM_CYFULLSCREEN)-(rect.bottom-rect.top))/2; SetWindowPos(hwnd, HWND_TOPMOST, xLeft,yTop,-1,-1, SWP_NOSIZE | SWP_NOZORDER); ShowWindow( hwnd,nCmdShow ); //显示窗口 UpdateWindow( hwnd ); //更新窗口 if(hwnd == NULL) { MessageBox(NULL, "窗口创建失败!","错误",MB_ICONEXCLAMATION|MB_OK); return 0; } while( GetMessage(&msg,NULL,0,0) ) { //消息循环 TranslateMessage(&msg); //将WM_XXXKEYXXX消息翻译为WM_CHAR消息 DispatchMessage(&msg); //传递消息到窗口过程 } return msg.wParam; //返回 } DWORD WINAPI PBThreadProc( LPVOID lpParameter ){ //FC数据下载 [运行监控] hwnd = FindWindowEx(0,0,"Afx:400000:b:10003:6:e002c3","FC数据下载 [ 运行监控 ]"); hwnd = FindWindowEx(hwnd,NULL,"AfxMDIFrame42s",""); hwnd = FindWindowEx(hwnd,NULL,"#32770",""); hwnd = FindWindowEx(hwnd,NULL,"#32770",""); hwnd = FindWindowEx(hwnd,NULL,"SysListView32","List1"); if(!hwnd){ HWND hwnd_box = FindWindowEx(0,0,ClassName,TitleName); MessageBox(hwnd_box,"FC数据下载 [运行监控] 未启动","友情提示",MB_ICONEXCLAMATION); } //获取总条数 total = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0); HWND hwndPB = (HWND) lpParameter; //进度条的窗口句柄 PBRANGE range; //进度条的范围 SendMessage( hwndPB, PBM_SETRANGE, //设置进度条的范围 (WPARAM)0, (LPARAM)(MAKELPARAM(0,total)) ); SendMessage( hwndPB, PBM_GETRANGE, //获取进度条的范围 (WPARAM)TRUE, //TRUE 表示返回值为范围的最小值,FALSE表示返回最大值 (LPARAM)&range ); while(TRUE){ SendMessage( hwndPB, PBM_DELTAPOS, //设置进度条的新位置为当前位置加上范围的1/40 (WPARAM)1, (LPARAM)0 );//((range.iHigh-range.iLow)/20) if( SendMessage( hwndPB, PBM_GETPOS, (WPARAM)0, (LPARAM)0 ) == range.iHigh ){ //取得进度条当前位置 break; } } } LRESULT WINAPI WndProc( HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam ){ switch( message ){ case WM_CREATE:{ //InitCommonControls(); //确保已注册了进度条类PROGRESS_CLASS hwndPB = CreateWindowEx( 0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE, 0,0,0,0, //位置和大小在WM_SIZE中设置 hwnd, (HMENU)0, ((LPCREATESTRUCT)lParam)->hInstance, NULL); CreateThread( //操作进度条的线程 NULL, 0, (LPTHREAD_START_ROUTINE)PBThreadProc, hwndPB, 0, 0 ); return 0; } case WM_PAINT:{ hdc = BeginPaint (hwnd, &ps); hFont=CreateFont(20,0,0,0,0,0,0,0,GB2312_CHARSET,0,0,0,0,TEXT("微软雅黑")); SetBkMode(hdc,TRANSPARENT); (HFONT)SelectObject(hdc,hFont); TextOut(hdc, 10, 10, szText, lstrlen(szText)); TextOut(hdc, 10, 75, hint1, lstrlen(hint1)); TextOut(hdc, 10, 98, hint2, lstrlen(hint2)); TextOut(hdc, 10, 125, hint3, lstrlen(hint3)); //FC数据下载 [运行监控] hwnd = FindWindowEx(0,0,"Afx:400000:b:10003:6:e002c3","FC数据下载 [ 运行监控 ]"); hwnd = FindWindowEx(hwnd,NULL,"AfxMDIFrame42s",""); hwnd = FindWindowEx(hwnd,NULL,"#32770",""); hwnd = FindWindowEx(hwnd,NULL,"#32770",""); hwnd = FindWindowEx(hwnd,NULL,"SysListView32","List1"); total = ListView_GetItemCount(hwnd); TextOut(hdc, 80, 10, _itoa(total,hint,10), lstrlen(_itoa(total,hint,10))); GetWindowThreadProcessId(hwnd,&PID); hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,PID); plvitem=(LVITEM*)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); pItem=(char*)VirtualAllocEx(hProcess, NULL, 128, MEM_COMMIT, PAGE_READWRITE); if(hProcess != NULL){ int j = 155; for(i=0; i < total; i++){ lvitem.mask = LVIF_TEXT; lvitem.cchTextMax=512; //FC数据下载 [运行监控] lvitem.iSubItem=2; lvitem.pszText=pItem; WriteProcessMemory(hProcess, plvitem, &lvitem, sizeof(LVITEM), NULL); SendMessage(hwnd, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)plvitem); ReadProcessMemory(hProcess, pItem, ItemBuf, 512, NULL); //FC数据下载 [运行监控] if(strcmp(ItemBuf,"成功") == 0){ // strcmp 相等 a+=1; } if(strcmp(ItemBuf,"失败") == 0){ // strstr 包含 b+=1; } if(strstr(ItemBuf,"Z:") != NULL && strstr(ItemBuf,".") != NULL ){ //&& strstr(ItemBuf,".") != NULL c+=1; //打印出未关闭的文件路径 TextOut(hdc, 10, j, ItemBuf, lstrlen(ItemBuf)); j+=30; } } //FC数据下载 [运行监控] TextOut(hdc, 60, 76, _itoa(a,hint,10), lstrlen(_itoa(a,hint,10))); TextOut(hdc, 60, 99, _itoa(b,hint,10), lstrlen(_itoa(b,hint,10))); TextOut(hdc, 98, 125, _itoa(c,hint,10), lstrlen(_itoa(c,hint,10))); } CloseHandle(hwnd); CloseHandle(hProcess); VirtualFreeEx(hProcess, plvitem, 0, MEM_RELEASE); VirtualFreeEx(hProcess, pItem, 0, MEM_RELEASE); return 0 ; } case WM_SIZE:{ RECT rc; GetClientRect(hwnd, &rc); MoveWindow( hwndPB, 10,//rc.left 距离左边距 40,//(rc.bottom - rc.top )/9 距离上边距 (rc.right - rc.left)-20,// 进度条长度 25,//(rc.bottom - rc.top )/12 进度条高度 TRUE); return 0; } case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc( hwnd,message,wParam,lParam ); } ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览