diff --git a/.classpath b/.classpath index 4589d57..e1de34c 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,8 @@ - - - + + + + diff --git a/.project b/.project index 966e7f6..5b866ac 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - jna-test + jlibwinapi diff --git a/src/main/java/test/Amount.java b/src/main/java/test/Amount.java deleted file mode 100644 index 3e4300a..0000000 --- a/src/main/java/test/Amount.java +++ /dev/null @@ -1,13 +0,0 @@ -package test; -public enum Amount { - DECREASE_MUCH ("--"), - DECREASE_LITTLE ("-"), - INCREASE_LITTLE ("+"), - INCREASE_MUCH ("++"); - - public String value; - - Amount(String value) { - this.value = value; - } -} diff --git a/src/main/java/test/Slider.java b/src/main/java/test/Slider.java deleted file mode 100644 index 1f8bb6b..0000000 --- a/src/main/java/test/Slider.java +++ /dev/null @@ -1,20 +0,0 @@ -package test; -public enum Slider { - EXPOSURE, - CONTRAST, - HIGHLIGHTS, - SHADOWS, - BLACKS, - WHITES, - CLARITY, - VIBRANCE; - - public String getLabel() { - String name = this.name(); - return String.format("%s%s", name.substring(0, 1), name.toLowerCase().substring(1)); - } - - public String getLabel(Amount amount) { - return String.format("%s %s", getLabel(), amount.value); - } -} diff --git a/src/main/java/test/Test.java b/src/main/java/test/Test.java deleted file mode 100644 index 6e3fef3..0000000 --- a/src/main/java/test/Test.java +++ /dev/null @@ -1,113 +0,0 @@ -package test; -import java.util.HashMap; -import java.util.Random; - -import org.synthuse.Api; -import org.synthuse.objects.MenuItem; - -import com.sun.jna.platform.win32.WinDef.HWND; - -public class Test { - protected Api api; - - protected HashMap> sliderMap; - protected HashMap valueMap; - - public Test() { - api = new Api(); - sliderMap = new HashMap>(); - valueMap = new HashMap(); - } - - public static void main(String[] args) throws Exception { - Test test = new Test(); - test.start(); - - //test.moveSlider(Slider.CONTRAST, Amount.INCREASE_LITTLE); - - for (int k = 0; k < 5; ++k) { - Slider slider = Slider.values()[new Random().nextInt(Slider.values().length)]; - for (int j = 0; j < 5; ++j) { - for (int i = 0; i < 10; ++i) { - test.moveSlider(slider, Amount.INCREASE_LITTLE); - System.out.println(test.getValue(slider)); - Thread.sleep(200); - } - Thread.sleep(400); - for (int i = 0; i < 10; ++i) { - test.moveSlider(slider, Amount.INCREASE_LITTLE); - Thread.sleep(200); - } - } - } - } - - protected void moveSlider(Slider slider, Amount amount) throws Exception { - MenuItem menuItem = sliderMap.get(slider).get(amount); - api.activateItem(menuItem); - } - - protected float getValue(Slider slider) { - if (valueMap.containsKey(slider)) { - HWND hWnd = valueMap.get(slider); - String text = Api.getWindowText(hWnd); - return Float.valueOf(text.replace(" ", "")); - } else { - return 0; - } - } - - public void start() throws Exception { - // Find Lightroom window - HWND hWndTopWindow = api.findTopWindow("Lightroom", "AgWinMainFrame"); - if (hWndTopWindow == null) { - throw new Exception("Can't find top window"); - } - - // Find menu options from Keyboard Tamer - String[] path = {"&File", "Pl&ug-in Extras", ""}; - for (Slider slider : Slider.values()) { - HashMap amountMap = new HashMap(); - for (Amount amount : Amount.values()) { - String label = slider.getLabel(amount); - path[2] = String.format(" %s", label); - MenuItem menuItem = api.loadMenuItem(hWndTopWindow, true, path); - amountMap.put(amount, menuItem); - } - sliderMap.put(slider, amountMap); - } - - // Find develop sliders - path = new String[]{"", "Top", "Main", "Panel", "Last Panel", "View", "ClipView", "Accordion", "Accordion"}; - HWND hWnd = api.findChildWindow(hWndTopWindow, path); - if (hWnd == null) { - throw new Exception("Can't find window"); - } - for (HWND hWndLoop : api.findAllChildWindow(hWnd, "Collapsible")) { - path = new String[]{"Basic", "View"}; - hWnd = api.findChildWindow(hWndLoop, path); - if (hWnd != null) { - Slider slider = null; - for (HWND hWndSubLoop : api.findAllChildWindow(hWnd, "")) { - //String className = Api.getWindowClassName(hWndSubLoop); - String text = Api.getWindowText(hWndSubLoop); - if (!text.contains("Bridge") && !text.contains("View") && text.length() > 0) { - if (slider != null) { - System.out.printf("%s = %s (%.2f)\n", slider.getLabel(), text, Float.valueOf(text.replace(" ", ""))); - valueMap.put(slider, hWndSubLoop); - slider = null; - } else { - for (Slider sliderLoop : Slider.values()) { - if (sliderLoop.getLabel().equals(text)) { - slider = sliderLoop; - } - } - } - } - } - } - } - } - - -} \ No newline at end of file