Author |
Topic |
|
JohntheApostle
4 Posts |
Posted - 03/16/2014 : 16:37:15
|
I'd like to have a stroke that will open a program, but if the program is already open, then it will bring it to the front/focus. I feel like this probably exists already, but I couldn't find it anywhere. |
|
Rob
USA
2615 Posts |
|
JohntheApostle
4 Posts |
Posted - 03/17/2014 : 00:44:32
|
Hey, thanks Rob! I'm sort of a newb with programming, so I tried to piece together the pieces you gave me, but it doesn't seem to be working. Here's what I got
local swnd = acFindWindow("MozillaWindowClass",nil) --this line would match on exact class name --local swnd = acFindWindowByTitleRegex(".* - firefox") --finds by title wildcard if swnd > 0 then acRestoreWindow(MozillaWindowClass) acActivateWindow(MozillaWindowClass) else acRunProgram("C:\\program files (x86)\\mozilla firefox\\firefox.exe","",0, 1) end
|
|
|
JohntheApostle
4 Posts |
Posted - 03/17/2014 : 00:48:26
|
I just noticed I should probably replace
acRestoreWindow(MozillaWindowClass) acActivateWindow(MozillaWindowClass)
with
acRestoreWindow(swnd) acActivateWindow(swnd)
But it didn't help... |
|
|
Rob
USA
2615 Posts |
Posted - 03/17/2014 : 01:04:21
|
Interesting, I copied exactly what you have (using the swnd parameter, of course) and it works perfectly!local swnd = acFindWindow("MozillaWindowClass",nil) --this line would match on exact class name
--local swnd = acFindWindowByTitleRegex(".* - firefox") --finds by title wildcard
if swnd > 0 then
acRestoreWindow(swnd)
acActivateWindow(swnd)
else
acRunProgram("C:\\program files (x86)\\mozilla firefox\\firefox.exe","",0, 1)
end So, let's see what could be causing this...
Does it do either of these events? Meaning, does it open FF or activate it?
If not, it seems like we're missing something.
Put this in place of your script just to confirm it's running:local swnd = acFindWindow("MozillaWindowClass",nil)
acMessageBox("swnd handle: "..swnd)
acMessageBox("swnd EXE: "..acGetExecutableName(swnd)) No matter what, you should see two message boxes when you execute the gesture; whether swnd is reflecting the correct handle and EXE is another matter, but if you see the message boxes, then we know it's running.
|
|
|
JohntheApostle
4 Posts |
Posted - 03/17/2014 : 04:21:02
|
Yeah, it opens FF when it's closed, but it doesn't do anything when it's open. I am using bblean as my windows shell, but that hasn't caused any problems in the past. I tried the script you gave me and both boxes came up. The handle was 1639972 and the exe was firefox. |
|
|
Rob
USA
2615 Posts |
Posted - 03/19/2014 : 01:54:50
|
I wish I had some advice. If you switch back to Explorer as the shell, does it work? If so, there's something missing from bblean to handle the API call. Maybe bblean has it's own API call to manage the foreground window that can be bound to via Alien/Lua.. |
|
|
control_freak
51 Posts |
Posted - 04/21/2016 : 16:42:54
|
hey rob if i put this it opens a new chrome window and doesn't put focus on existing chrome. and how do i get the class name of any application in case i try it with other applications?
local swnd = acFindWindow("Google chrome",nil) --this line would match on exact class name --local swnd = acFindWindowByTitleRegex(".* - chrome") --finds by title wildcard if swnd > 0 then acRestoreWindow(swnd) acActivateWindow(swnd) else acRunProgram("C:\\program files (x86)\\Google\\chrome\\application\\chrome.exe","",0, 1) end
|
|
|
chandisciple
75 Posts |
Posted - 04/21/2016 : 20:04:03
|
Control freak , try changing this line,
swnd = acFindWindowByTitleRegex(".* - chrome")
to this,
swnd = acFindWindowByTitleRegex(".* - Google Chrome")
I guess rob would suggest the tool he likes to find the class, WinSpy++ 1.7. Rob apologies if you have a different answer. |
Edited by - chandisciple on 04/21/2016 20:06:34 |
|
|
control_freak
51 Posts |
Posted - 04/21/2016 : 21:05:48
|
hey chandisciple thank you :P winspy++ worked. rob has just told me about this software this morning lol. heres what made it work
local swnd = acFindWindow("Chrome_WidgetWin_1",nil) --this line would match on exact class name --local swnd = acFindWindowByTitleRegex(".* -Google chrome") --finds by title wildcard if swnd > 0 then acRestoreWindow(swnd) acActivateWindow(swnd) else acRunProgram("C:\\program files (x86)\\Google\\chrome\\application\\chrome.exe","",0, 1) end |
|
|
control_freak
51 Posts |
Posted - 04/22/2016 : 18:46:29
|
hey i have another problem. if my chrome is minimized to the tray acMaximizeWindow doesnt work. i put my code like this
local swnd = acFindWindow("Chrome_WidgetWin_1",nil) --this line would match on exact class name --local swnd = acFindWindowByTitleRegex(".* -Google chrome") --finds by title wildcard if swnd > 0 then acMaximizeWindow(swnd) acRestoreWindow(swnd) acActivateWindow(swnd)
else acRunProgram("C:\\program files (x86)\\Google\\chrome\\application\\chrome.exe","",0, 1) end |
|
|
|
Topic |
|
|
|