This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General Discussion
 General Discussion
 Mark window with gesture and then activate it
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

poweruser84

Russia
24 Posts

Posted - 08/27/2013 :  14:49:16  Show Profile
Hi all

I am trying to add two exceptionally useful gestures in S+. Hey, Rob, i think that those gestures might be implemented in default S+ configuration.

1. One gesture to mark specified window (for an example, "\ Down - \ Up")

2. Another gesture (simple one, "\ Up" in my case) should work in two ways:
- restore and activate marked window from minimized state
- bring the marked window to foreground from background(when the window IS NOT in minimized state) then activate it

The marked window's current size and its current status (normal or maximized) should be restored correctly on activation gesture.

"Mark window" gesture's code:
acActivateWindow(acGetOwnerWindowByPoint(acGetMouseLocationX(), acGetMouseLocationY()),0,0)
markedWindow = acGetForegroundWindow()
--- flash the marked window using free NirCMD utility for better clearness:
acRunProgram("C:\\Windows\\nircmd.exe","win flash foreground 2 500",0,3)


(works with no problems)

The second gesture "Activate marked window". Code:
acRestoreWindow(markedWindow, 0, 0)
acActivateWindow(markedWindow, 0, 0, 0)


It also works. But when the window is maximized and is in background (WITHOUT minimized state though), the gesture always fail to restore window's original state(maximized in this case).
I found that the acRestoreWindow function resets the state of window to normal. Is there way to avoid it?

Is there way to check:
- the state of window - normal or maximized ? then do some action.
- the state of window - minimized or not minimized? then do some action.

Please give me any suggestion.

Rob

USA
2615 Posts

Posted - 08/28/2013 :  08:00:19  Show Profile  Visit Rob's Homepage
I'm in the process of moving, so I do not have access to my computer.

The functionality you're looking for is available via Alien in the Global Lua tab.

The two functions you want are IsZoomed (is window maximized) and IsIconic (is window minimized).

Since I am posting from my phone, I can't really provide you the exact code, but the post below explains setting up the call to IsIconic. IsZoomed is exactly the same, just replace "Iconic" with "Zoomed" and call from your action. I hope this makes sense and you're able to get it working, otherwise I can help you next week.

http://www.strokesplus.com/forum/topic/615/cycle-through-programs-including-win8-apps?SearchTerms=isiconic
Go to Top of Page

Noesis

25 Posts

Posted - 08/28/2013 :  10:15:31  Show Profile
Try this...
Put the following function in Global Lua:

function IsIconic(iWnd) --Check if Window is Minimized
local Alien_IsIconic = alien.core.load("user32.dll").IsIconic
Alien_IsIconic:types{ ret = 'long', abi = 'stdcall', 'long'}
if Alien_IsIconic(iWnd) == 0 then
return false
else
return true
end
end

Then alter your "Activate Marked Window" code to:

if IsIconic(markedWindow) then
acRestoreWindow(markedWindow, 0, 0)
end
acActivateWindow(markedWindow, 0, 0, 0)
Go to Top of Page

poweruser84

Russia
24 Posts

Posted - 08/29/2013 :  05:52:03  Show Profile
Rob and Noesis, thank you!

Global Lua's part works well.

I modified a little bit the script "Activate Marked Window":

if IsIconic(markedWindow) then
acRestoreWindow(markedWindow, 0, 0)
acActivateWindow(markedWindow, 0, 0, 2)
else
acActivateWindow(markedWindow, 0, 0, 2)
end

Now it works more reliably (when activating and focusing the window from background to foreground). Also, i found that the acActivateWindow with method 2 (alt keypress) works every time unlike method 0....


Edited by - poweruser84 on 08/29/2013 06:12:50
Go to Top of Page

poweruser84

Russia
24 Posts

Posted - 08/31/2013 :  15:39:37  Show Profile
Unfortunately, IsIconic method doesn't work with some of my programs. The windows of those applications simply can't be restored from minimized state when IsIconic is used. So i want to add additional check for the app exe's name in order to bypass IsIconic for those apps.

"Mark window"'s code:
acActivateWindow(acGetOwnerWindowByPoint(acGetMouseLocationX(), acGetMouseLocationY()),0,0)
markedWindow = acGetForegroundWindow()
markedExename = acGetExecutableName(markedWindow, 0, 0)
acRunProgram("C:\\Windows\\nircmd.exe","win flash foreground 2 500",0,3)


Activate market window's code (single program in ignore list as an example):
if markedExename == keynote then
acRestoreWindow(markedWindow, 0, 0)
acActivateWindow(markedWindow, 0, 0, 2)
acDisplayText("TEST EXE CHECK", "Arial", 76, 0, 0, 0, 2000, 500, 400)
end
if IsIconic(markedWindow) then
acRestoreWindow(markedWindow, 0, 0)
acActivateWindow(markedWindow, 0, 0, 2)
else
acActivateWindow(markedWindow, 0, 0, 2)
end

The "Activate market window" doesn't work ("if markedExename construct" not working at all). I know that my logical construct is wrong. Please give suggestion how to modify the script.

Edited by - poweruser84 on 08/31/2013 15:43:18
Go to Top of Page

Noesis

25 Posts

Posted - 09/01/2013 :  02:04:05  Show Profile
Assuming the acDisplayText part is just for debugging, and that this window can actually be restored (some windows just can't seem to be restored other than manually eg if they minimize to the tray and don't leave an icon in the taskbar they're usually problematic.)

To get to you're question however, the easiest way would be something like:

if IsIconic(markedWindow) or markedExename == "keynote.exe" then ... rest is same.

i.e. the program name needs to be in quotes and most likely will have a .exe extension which needs to be included. This is also case sensitive so it may be Keynote.exe not keynote.exe or any other variation. To find the correct name to check for, you can run the program and look in windows task manager for the process name or alternatively temporarily put in an acMessageBox(markedExename) command in the marking window code to see what is actually being stored when you mark that window.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000