idle和linux命令行环境下,用input()和raw_input()就可以了注意3X中没有raw_input();
如果是tk图形界面,你用Entry控件就可以了,获取输入可以用Entry的get()方法。
#-- coding:utf-8 --
import time
from selenium import webdriver
driver = webdriverChrome()
driverget("file:///C:/Users/hunk/Desktop/bootstrap-datetimepicker/bootstrap-datetimepicker/demo/indexhtml")
js = "$('input:eq(0)')removeAttr('readonly')" # jQuery,移除属性
# js = "$('input:eq(0)')attr('readonly',false)" # jQuery,设置为false
driverexecute_script(js)
input_datetime = driverfind_element_by_xpath('/html/body/div[1]/form/fieldset/div/div[1]/input[1]')
input_datetimesend_keys("2017-09-21")
input_datetimeclick()
timesleep(5)
driverquit()
调用execute_script方法来执行js,来处理时间控件,然后我们可以直接输入日期。
①SysListView32
#define TEXTSIZE 256
void Func()
{
HWND hYF; //SysListView32的父窗口句柄
HWND hLV = FindWindowEx(hYF, NULL, _T("SysListView32"), _T(""));
DWORD PID;
HWND hWnd; //hWnd 应用程序的句柄
GetWindowThreadProcessId(hWnd, &PID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
TCHAR buf[TEXTSIZE];
TCHAR lpClassName[TEXTSIZE];
while(1 && (NULL != hLV))
{
GetClassName(hLV, (LPWSTR)lpClassName, TEXTSIZE-1); //获得窗口类名
CString className(lpClassName);
if (className != _T("SysListView32"))
continue;
CListView pListView = (CListView)CWnd::FromHandle(hLV);
CListCtrl& listCtrl = pListView->GetListCtrl();
LVCOLUMN plvcolumn =(LVCOLUMN)VirtualAllocEx(hProcess, NULL, sizeof(LVCOLUMN), MEM_COMMIT, PAGE_READWRITE);
TCHAR pColumnTitle = (TCHAR)VirtualAllocEx(hProcess, NULL, TEXTSIZE, MEM_COMMIT, PAGE_READWRITE);
LVCOLUMN lvcol;
lvcolpszText = pColumnTitle;
lvcolcchTextMax = TEXTSIZE;
lvcolmask = LVCF_TEXT;
WriteProcessMemory(hProcess, plvcolumn, &lvcol, sizeof(LVCOLUMN), NULL);
listCtrlGetColumn(0, plvcolumn);
ReadProcessMemory(hProcess, pColumnTitle, buf, TEXTSIZE, NULL);
VirtualFreeEx(hProcess, plvcolumn, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, pColumnTitle, 0, MEM_RELEASE);
CString lvcolTitle(&buf[0]);
if (lvcolTitle == _T("图像名称"))
{
break;
}
hLV = ::GetWindow(hLV, GW_HWNDNEXT);
}
BOOL bRet = TRUE;
CListView pListView = (CListView)CWnd::FromHandle(hLV);
CListCtrl& listCtrl = pListView->GetListCtrl();
int nCount = ListView_GetItemCount(hLV);
for (int i = 0; i < nCount; ++i)
{
LVITEM plvitem =(LVITEM)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
TCHAR pItemTitle = (TCHAR)VirtualAllocEx(hProcess, NULL, TEXTSIZE, MEM_COMMIT, PAGE_READWRITE);
LV_ITEM lvi;
lviiSubItem = 1;
lvipszText = pItemTitle;
lvicchTextMax = TEXTSIZE;
WriteProcessMemory(hProcess, plvitem, &lvi, sizeof(LVITEM), NULL);
SendMessage(hLV, LVM_GETITEMTEXT, i, (LPARAM)plvitem);
ReadProcessMemory(hProcess, pItemTitle, buf, TEXTSIZE, NULL);
VirtualFreeEx(hProcess, plvitem, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, pItemTitle, 0, MEM_RELEASE);
CString strText(&buf[0]);
if (0 == strTextCompareNoCase(_T("缺图")))
{
//XXXXXXXXXXXXXXXXXXX
}
}
};
②SysTreeView32
HTREEITEM GetNextTreeItem(HWND hWnd, HTREEITEM hCurTreeItem)
{
if (NULL == hWnd || NULL == hCurTreeItem)
return NULL;
HTREEITEM hResultItem = TreeView_GetNextItem(hWnd, hCurTreeItem, TVGN_CHILD);
if (NULL == hResultItem)
{
hResultItem = TreeView_GetNextItem(hWnd, hCurTreeItem, TVGN_NEXT);
}
if (NULL == hResultItem)
{
HTREEITEM hParentItem = TreeView_GetNextItem(hWnd, hCurTreeItem, TVGN_PARENT);
hResultItem = TreeView_GetNextItem(hWnd, hParentItem, TVGN_NEXT);
}
return hResultItem;
}
void Func()
{
//获取树控件的内容
HWND hParent; //SysTreeView32父窗口句柄
HWND hTree = FindWindowEx(hParent, NULL, _T("SysTreeView32"), _T(""));
HWND hWnd; //主程序句柄
DWORD PID;
GetWindowThreadProcessId(hWnd, &PID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
ASSERT( NULL != hProcess);
UINT vItemCount = TreeView_GetCount(hTree);
HTREEITEM hTreeItem = TreeView_GetRoot(hTree);
TCHAR buf[MAXLENGTH];
std::vector<CString> vecItemText;
CTreeView pTreeView = (CTreeView)CWnd::FromHandle(hTree);
CTreeCtrl& treeCtrl = pTreeView->GetTreeCtrl();
for (int i = 0; i < vItemCount; i++)
{
LPTV_ITEM pTreeItem =(LPTV_ITEM)VirtualAllocEx(hProcess, NULL, sizeof(TV_ITEM), MEM_COMMIT, PAGE_READWRITE);
TCHAR pItemText = (TCHAR)VirtualAllocEx(hProcess, NULL, MAXLENGTH, MEM_COMMIT, PAGE_READWRITE);
TV_ITEM item;
itemmask = TVIF_TEXT;
itemhItem = hTreeItem;
itempszText = pItemText;
itemcchTextMax = MAXLENGTH;
WriteProcessMemory(hProcess, pTreeItem, &item, sizeof(TV_ITEM), NULL);
treeCtrlGetItem(pTreeItem);
ReadProcessMemory(hProcess, pItemText, buf, MAXLENGTH, NULL);
VirtualFreeEx(hProcess, pTreeItem, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, pItemText, 0, MEM_RELEASE);
if (TreeView_GetRoot(hTree) != hTreeItem)
{
CString sTreeItemText(buf);
vecItemTextpush_back(sTreeItemText);
}
hTreeItem = GetNextTreeItem(hTree, hTreeItem);
}
for (auto it = vecItemTextbegin(); it != vecItemTextend(); ++it)
{
//可根据Item内容判断转出的pdf是否可用
}
}
以上就是关于python 如何获取窗口输入全部的内容,包括:python 如何获取窗口输入、python3有没有时间控件、使用pywinauto如何 获取systreeview32内的item(python语言)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)