diff --git a/src/main/java/com/xxx/winio/PbcApp.java b/src/main/java/com/xxx/winio/PbcApp.java index 971913f..318a80d 100644 --- a/src/main/java/com/xxx/winio/PbcApp.java +++ b/src/main/java/com/xxx/winio/PbcApp.java @@ -22,6 +22,7 @@ public static void main(String[] args) throws Exception { int sleepTimes = 0; final PbcService pbc = new PbcService(); while (true){ + Util.sleep(1000); List list = pbc.listPassSrc(); if (list.size() > 0){ loop(pbc, list); @@ -47,6 +48,8 @@ public boolean callback(WinDef.HWND root, WinDef.HWND current) { Util.sleep(2000); String passSrc = pbcPass.getPassSrc(); pbc.inputPassword(passSrc); +// sleep(300 * passSrc.length()); + User32.INSTANCE.ShowWindow(root, SW_SHOWNOACTIVATE); // User32.INSTANCE.ShowWindow(root, SW_MINIMIZE); //打开控制台 pbc.showIEDevelopTool(new Callback() { diff --git a/src/main/java/com/xxx/winio/Test.java b/src/main/java/com/xxx/winio/Test.java new file mode 100644 index 0000000..2a52716 --- /dev/null +++ b/src/main/java/com/xxx/winio/Test.java @@ -0,0 +1,39 @@ +package com.xxx.winio; + +import com.sun.jna.platform.win32.WinDef; +import com.xxx.winio.jna.User32; +import com.xxx.winio.model.Callback; +import com.xxx.winio.pbc.PbcService; +import com.xxx.winio.utils.Util; + +import static com.sun.jna.platform.win32.WinUser.SW_SHOWNOACTIVATE; + +public class Test { + public static void main(String[] args) { + final PbcService pbc = new PbcService(); + pbc.showIEBrowser(new Callback() { + public boolean callback(WinDef.HWND root, WinDef.HWND current) { + //ie 打开后输入密码 + Util.sleep(2000); + String passSrc = "12345"; + pbc.inputPassword(passSrc); +// sleep(300 * passSrc.length()); + User32.INSTANCE.ShowWindow(root, SW_SHOWNOACTIVATE); +// User32.INSTANCE.ShowWindow(root, SW_MINIMIZE); + //打开控制台 + pbc.showIEDevelopTool(new Callback() { + public boolean callback(WinDef.HWND root, WinDef.HWND current) { + //调用JS + Util.sleep(2000); +// sendJSCmd(pbcPass); + //Sleep等待JS调用完成 +// sleep(1000); + User32.INSTANCE.ShowWindow(root, SW_SHOWNOACTIVATE); + return false; + } + }); + return false; + } + }); + } +} diff --git a/src/main/java/com/xxx/winio/config/Config.java b/src/main/java/com/xxx/winio/config/Config.java index 1e24ef9..de2fad4 100644 --- a/src/main/java/com/xxx/winio/config/Config.java +++ b/src/main/java/com/xxx/winio/config/Config.java @@ -6,8 +6,8 @@ public class Config { /** * IE句柄 */ - public final static String IE_EDIT = "203E4"; - public final static String DEV_EDIT = "10392"; + public final static String IE_EDIT = "303FE"; + public final static String DEV_EDIT = "20486"; public static final String API_LIST = "https://loannode.renrendai.com/credit/list"; diff --git a/src/main/java/com/xxx/winio/model/PbcPass.java b/src/main/java/com/xxx/winio/model/PbcPass.java index bd1bdbc..ccd75f7 100644 --- a/src/main/java/com/xxx/winio/model/PbcPass.java +++ b/src/main/java/com/xxx/winio/model/PbcPass.java @@ -16,7 +16,7 @@ public class PbcPass { @JSONField(name = "random_factor") private String randomFactor; - private String created; + private long created; public long getId() { return id; @@ -66,11 +66,11 @@ public void setRandomFactor(String randomFactor) { this.randomFactor = randomFactor; } - public String getCreated() { + public long getCreated() { return created; } - public void setCreated(String created) { + public void setCreated(long created) { this.created = created; } diff --git a/src/main/java/com/xxx/winio/pbc/PbcService.java b/src/main/java/com/xxx/winio/pbc/PbcService.java index e4ac788..21c1d8b 100644 --- a/src/main/java/com/xxx/winio/pbc/PbcService.java +++ b/src/main/java/com/xxx/winio/pbc/PbcService.java @@ -21,7 +21,6 @@ import static com.xxx.winio.config.Config.IE_EDIT; public class PbcService { - /** * 激活IE * @param callback @@ -62,12 +61,10 @@ public boolean callback(WinDef.HWND hWnd, Pointer data) { */ public void showIEDevelopTool(final Callback callback) { Logger.i("Start IE Development Tools"); - WinDef.HWND hwnd = User32.INSTANCE.FindWindow("IEDEVTOOLS", null); + WinDef.HWND hwnd = User32.INSTANCE.FindWindow("F13FrameWindow", null); final WinDef.HWND root = hwnd; User32.INSTANCE.ShowWindow(hwnd, SW_RESTORE); // SW_RESTORE User32.INSTANCE.SetForegroundWindow(hwnd); // bring to front - hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "SysTabControl32", null); - hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "#32770", null); hwnd = User32.INSTANCE.FindWindowEx(hwnd, null, "WTL_SplitterWindow", null); User32.INSTANCE.EnumChildWindows(hwnd, new WinUser.WNDENUMPROC() { @@ -76,7 +73,7 @@ public boolean callback(WinDef.HWND hWnd, Pointer data) { if (addr.contains(DEV_EDIT)) { Logger.i("Found Out IE Dev Window :" + hWnd.getPointer()); User32.INSTANCE.SetFocus(hWnd); - User32.INSTANCE.ShowWindow(hWnd, SW_NORMAL); // SW_RESTORE + User32.INSTANCE.ShowWindow(hWnd, SW_NORMAL); User32.INSTANCE.SetForegroundWindow(hWnd); // bring to front if (callback != null) { callback.callback(root, hWnd); diff --git a/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java b/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java index 83e737e..d59a24f 100644 --- a/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java +++ b/src/main/java/com/xxx/winio/utils/KeyBoardUtil.java @@ -15,8 +15,11 @@ public class KeyBoardUtil { + public static String KBLOG = ""; + /** * 删除 + * * @param length 数量 * @throws Exception */ @@ -29,35 +32,56 @@ public static void delete(int length) throws Exception { /** * 使用WinIO发送字符串 + * * @param string * @throws Exception */ public static void sendString(String string) throws Exception { + KBLOG = ""; for (int i = 0; i < string.length(); i++) { + Character last = null, next = null; char c = string.charAt(i); + if (i != 0) { + last = string.charAt(i - 1); + } + if (i < string.length() - 1) { + next = string.charAt(i + 1); + } + if (Character.isDigit(c)) { - pressLowerCase(c); + pressLowerCase(c, last, next); } else if (Character.isUpperCase(c)) { - pressUpperCase(c); + pressUpperCase(c, last, next); } else { - pressLowerCase(c); + pressLowerCase(c, last, next); } } + Logger.i("Real Input: " + KBLOG); } - private static void pressLowerCase(char c) throws Exception { + private static void pressLowerCase(Character c, Character last, Character next) throws Exception { + KBLOG += c; KeyPress(VKMapping.toScanCode("" + c)); - Util.sleep(800); + Util.sleep(300); } - private static void pressUpperCase(char c) throws Exception { + private static void pressUpperCase(Character c, Character last, Character next) throws Exception { c = Character.toLowerCase(c); - KeyDown(User32.MapVirtualKeyA(KeyEvent.VK_SHIFT)); - Util.sleep(1000); + if (last == null || Character.isLowerCase(last) || Character.isDigit(last)) { + KBLOG += "#shift_d#"; + KeyDown(User32.MapVirtualKeyA(KeyEvent.VK_SHIFT)); + Util.sleep(300); + } + + KBLOG += c; KeyPress(VKMapping.toScanCode("" + c)); - Util.sleep(1000); - KeyUp(User32.MapVirtualKeyA(KeyEvent.VK_SHIFT)); - Util.sleep(1000); + Util.sleep(300); + + if (next == null || Character.isLowerCase(next) || Character.isDigit(next)) { + KBLOG += "#shift_u#"; + KeyUp(User32.MapVirtualKeyA(KeyEvent.VK_SHIFT)); + Util.sleep(300); + } } private static WinUser.INPUT input = new WinUser.INPUT(); @@ -65,12 +89,14 @@ private static void pressUpperCase(char c) throws Exception { /** * 使用WIN32_API虚拟信号发送字符串 * 效率较高 + * * @param string */ public static void sendVirtualString(String string) { for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); sendVChar(c); + Util.sleep(10); } } @@ -121,7 +147,7 @@ public static void sendVK(int k) { } public static void main(String[] args) { - String a = "AbCD123ABCqwe"; + String a = "wuJSDi8023J82asdbJ8JDBc"; try { sendString(a); } catch (Exception e) {