StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
 All Forums
 General Discussion
 General Discussion
 Activate Window in Background

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
3di Posted - 09/25/2015 : 14:02:43
Hi Folks,

first of all i like to say thanks to Rob an all of you for your ongoing support and great toolkits.

I am working as a Account Manager, and I have to use a lot of Windows, 3 Monitors, CRM, Outlook, Office and so on.

On the phone, i often have to overview and generate dates with customers very quickly. So i like to get a gesture that brings my Outlook in foreground and sets it to the calender (that‘s STRG+2).

I tried myself, maybe for to long but i didn’t get the result that i like to get.

My script is working if Outlook is open and on the top, not active but in foreground. Unfortunately if it is hidden by another window it doesn’t work and my keystroke is sent to the application thats in forground of the Outlook Window.

I‘ll paste my Suggestion here, maybe one of you can give me a hint where’s my fault.



local iHandle = acFindWindow(OutlookGrid,nil) --Pass nil in place of either parameter to exclude
acSetTopmost(iHandle,nil,nil) --sample uses the gesture start coordinates (gsx and gsy)
acActivateWindow(iHandle,nil,nil,0) --sample uses the gesture start coordinates (gsx and gsy) and the standard method for activating a window
--acSetTopmost(iHandle, nil, nil) --sample uses the gesture start coordinates (gsx and gsy)
acDelay(200)
acSendKeys("^2")


Thanks in advance and
Best Regards 3di

14   L A T E S T    R E P L I E S    (Newest First)
Rob Posted - 03/05/2016 : 17:31:09
Well I don't have Outlook 2013, I have 2016. However, for 2016 this works because the new message window doesn't have " - Outlook" at the end. So that is a limitation, but if no other Outlook window title bars end in that pattern, this should work fine.
local handle = acFindWindowByTitleRegex(".* - Outlook") --regular expression, matches any windows ending in " - Outlook"

-- Get Outlook in on if minimized or activate if in background
if handle ~= 0 then
if gIsIconic(handle) == 1 then
acRestoreWindow(handle)
end
acActivateWindow(handle, 0, 0, 0) 
end

acActivateWindow(handle) --Activate Outlook
acDelay(200) --Allow time for Outlook to get application focus
acSendKeys("^2") --Send CTRL+2
3di Posted - 03/05/2016 : 04:46:16
Hi,

I'm using Outlook 2013 in 32Bit Edition on W10 64.

I tried again, here's step to step how to generate the Problem.

1. Start outlook
2. Start a new EMail - Message window
3. Type some text
4. Open Firefox or something in foreground of outlook - don't minimize outlook bevor
5. Stroke the gesture
--> the message Window comes in forground

Thanks for your help.
Regards 3di
Rob Posted - 03/04/2016 : 17:20:35
What version of Outlook are you running? It doesn't happen for me.
3di Posted - 03/01/2016 : 09:06:18
quote:
Originally posted by Rob

Exactly what steps do I need to use to get a "Email Texteditor Window" to be open? I'd like to try to replicate and see if I can come up with something.



Hi,

Simply press the create new Email Button (sorry for my bad explanation above).

Best Regards
Rob Posted - 02/29/2016 : 10:19:46
Exactly what steps do I need to use to get a "Email Texteditor Window" to be open? I'd like to try to replicate and see if I can come up with something.
3di Posted - 02/24/2016 : 08:29:38
Hi Folks,

unfortunately it doesn't work very reliable.

For Example if there is a Email Texteditor Window open and i call Outlook to change into the Inbox via the following script the Email Texteditor Window is set to be in foreground.

Have you any suggestions to solve?

-------------------------- I use this code--------------------------

--Get process ID for Outlook, assumes your Outlook EXE (check Task Manager) is upper case like mine

local pid = acGetProcessIDFromPattern("OUTLOOK.*")
local handle = acGetWindowFromProcessID(pid) --Get Outlook's main window handle

-- Get Outlook in on if minimized or activate if in background
if handle ~= 0 then
if gIsIconic(handle) == 1 then
acRestoreWindow(handle)
end
acActivateWindow(handle, 0, 0, 0)
end

acActivateWindow(handle) --Activate Outlook
acDelay(200) --Allow time for Outlook to get application focus
acSendKeys("^2") --Send CTRL+2
---------------------------------------------------------------------

Thanks for your Help.

Best Regards


Christian Berthold
3di Posted - 09/28/2015 : 11:42:13
Hi Rob, Hi Mike,

i've made it to work!
Thanks to Rob for his tutorial about the Lua.

My Code is:

-----------------------------------------------------------------------------------------

--Get process ID for Outlook, assumes your Outlook EXE (check Task Manager) is upper case like mine
local pid = acGetProcessIDFromPattern("OUTLOOK.*")
local handle = acGetWindowFromProcessID(pid) --Get Outlook's main window handle
-- Get Outlook in on if minimized or activate if in background
if handle ~= 0 then
if gIsIconic(handle) == 1 then
acRestoreWindow(handle)
end
acActivateWindow(handle, 0, 0, 0)
end

-- Wait a second and send STRG+1 to Outlook to open Email
acDelay(200) --Allow time for Outlook to get application focus
acSendKeys("^1") --Send CTRL+2

-----------------------------------------------------------------------------------------

As in the following Link i copied this to the Lua Engine

http://www.strokesplus.com/forum/topic/1081/script-for-firefox-in-application-bar?SearchTerms=IsIconic


user32 = alien.core.load("user32.dll")

-- ************ IsIconic (if window minimized) ************

gIsIconic = user32.IsIconic
gIsIconic:types{ ret = 'long', abi = 'stdcall', 'long'}
function aIsIconic(iWnd)
return gIsIconic(iWnd)
end

-----------------------------------------------------------------------------------------


It works for my case, which does't mean it's completly correct but I works.


I am not very proud of my Copy/Past Programing Skills, but i’m very happy i made it work. (with a little help from my friends)

Best Regards
3di
Rob Posted - 09/27/2015 : 16:58:42
I've made a new forum for tutorials which will hopefully help beginners. I'll expand it over time, but for now I've covered some basics along with a guide on finding windows.

http://www.strokesplus.com/forum/27/tutorials/
Mike Posted - 09/26/2015 : 17:16:47
Hi Rob:
I'm trying to learn how to send a string to a window that is not active.
I browsed the site, help, forum, applied some advices, but I have not gotten that I'm trying
I am in the Notepad and I wont to find a selected term in the "EveryThing locator" and then remain in the 'Everythig' window.
I tried:
acActivateWindow ("* - Everything.exe") - the variable name of the opened window
acSendKeys("{DELAY=100}^c") - to copy the selected word
acDelay (200)
acSendKeys ("^v") - Not requires a click to 'enter' key for to search immediately
acSetTopmost ("* - Everything") - in order to go to the window "Everything" to see the search results

Regardless I do not know the basic things about StrokesPlus, I'm using it for 4 years and I am very grateful for your gift

I will be happy if someone give me one or more links in the site to find a detailed help for this novice.
Thank you, Rob
Mike

Rob Posted - 09/26/2015 : 15:56:40
Still on my phone, but yes, you'll need to copy that section for IsIconic from the thread you referenced into your Global Lua. Note that if you copy that section, the function exposed is aIsIconic (not IsIconic, that's the name of the API call itself within Windows. So your script would need to be changed to:

if aIsIconic(handle) then

Regarding sample list...ironically, I don't actually do much automation! I really only use a handful of simple gestures, but I (obviously) know S+ inside and out and love to figure out how to automate things for people :)
3di Posted - 09/26/2015 : 10:02:45
Hi Rob,

i've tried several things but, it returns as if i am trying to attempt a nil value.

Thats my code.


--Get process ID for Outlook, assumes your Outlook EXE (check Task Manager) is upper case like mine
local pid = acGetProcessIDFromPattern("OUTLOOK.*")
local handle = acGetWindowFromProcessID(pid) --Get Outlook's main window handle
if IsIconic(handle) then
acRestoreWindow(handle)
else
acActivateWindow(handle) --Activate Outlook
end
acDelay(500) --Allow time for Outlook to get application focus
acSendKeys("^2") --Send CTRL+2

Do I have to ad something to the global lua as in this one?
http://www.strokesplus.com/forum/topic/694/acshellexecute?SearchTerms=IsIconic

Sorry im not shure what global lua does..

Thanks in Advance.
Best regards

Ps - is there such a list?
Is it possible to get a list of things you automated with gestures so i can have a look and copy / build similar things?







Rob Posted - 09/25/2015 : 16:37:08
On my phone, so I can't get into detail. Search the forum for IsIconic, it should lead you to some scripts that will handle checking if a window is minimized. acSetTopmost flags the window as above all windows at all times. There aren't many cases where you really want to do that. acRestoreWindow would unminimize it, but if it's already maximized, it will restore the window. That's why I suggest the search above as it will conditionally restore the window.
3di Posted - 09/25/2015 : 16:32:36
Hi Rob,

i've played a little with your script.
It works fine, thanks, but I think i have to ad something. If outlook is in background it also works, but not if it is minimized. Is there a way to hook up this case in this script?

Is this the right action?
--acSetTopmost(iHandle,nil,nil)


Best regards

Ps
Is it possible to get a list of things you automated with gestures so i can have a look and copy / build similar things?



Rob Posted - 09/25/2015 : 15:36:22
3di,

This never had a chance of working: local iHandle = acFindWindow(OutlookGrid,nil)

I'm assuming you're not a programmer/script wizard, which is totally cool.

Moving on, the script below works on my system, and should work for you as well. I've added comments to explain the steps. Note that acFindWindow could be used as well, but Outlook can have so many windows open with varying text in the title bars that it's just worth going straight to the source.
--Get process ID for Outlook, assumes your Outlook EXE (check Task Manager) is upper case like mine
local pid = acGetProcessIDFromPattern("OUTLOOK.*") 
local handle = acGetWindowFromProcessID(pid) --Get Outlook's main window handle
acActivateWindow(handle) --Activate Outlook
acDelay(200) --Allow time for Outlook to get application focus
acSendKeys("^2") --Send CTRL+2
It's possible the that you may have to increase the value in acDelay, but I'm guessing your system is pretty fast, so it shouldn't be an issue. But you will need to have SOME delay no matter what to give Windows a few milliseconds to bring Outlook into focus before firing the keystrokes.

StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000