Author |
Topic |
|
MDB
South Africa
5 Posts |
Posted - 05/29/2013 : 11:42:15
|
I would like top open die folder C:\Windows in explorer. This command works but it opens the explorer every time when I do this action. Is there a way to see if explorer is open and the only change the directory to C:\Windows.
Otherwise it opens the folder C:\Windows every time I do the Action
acShellExecute("explore","C:\\Windows","","",3)
Thanks for great program |
Manie |
|
Rob
USA
2615 Posts |
Posted - 05/29/2013 : 13:11:25
|
There's probably a better way to do this, but I was able to quickly hack this script together:local ExplorerFound = false
acGetAllWindows(1)
for num, handle in pairs(sp_all_windows) do
local exe = acGetExecutableName(handle,0,0)
local class = acGetClassName(handle,0,0)
if exe == "explorer.exe" and class == "CabinetWClass" then
acActivateWindow(handle)
acDelay(50)
acSendKeys("%d")
acDelay(25)
acSendKeys("{DELAY=10}c:\\windows~")
ExplorerFound = true
break
end
end
if ExplorerFound == false then
acShellExecute("explore","C:\\Windows","","",3)
end Basically, it looks through all top-level open windows and if it matches "explorer.exe" and "CabinetWClass" (the window class for Explorer [on my Win8 system, anyway]), it activates the first Explorer window found, sends ALT+D to set focus in the Address Bar, then types "C:\Windows" and sends ENTER.
If no Explorer window was found, it calls acShellExecute. |
|
|
MDB
South Africa
5 Posts |
Posted - 05/30/2013 : 02:13:54
|
Hallo rob
Thank you very much for your reply. I appreciated it very much. This script works 99.9999%. It does what I want. The only problem comes when explorer.exe is not active and I do the action it opens explorer and then opens the "preview pane"" is does not go to the specific folder.
But when explorer is open is does exactly the correct action
Thank you for your help |
Manie |
|
|
MDB
South Africa
5 Posts |
Posted - 05/30/2013 : 04:52:08
|
Hallo Rob
I have figured out the problem. but does not know how to fix it. Everything works but when explorer is minimized and this script file runs it opens explorer and then open ONLY the "preview pane" in explorer. But when explorer is closed or open and maximized this script works 100%.
Thank you for taking the time to help me Manie |
Manie |
|
|
MDB
South Africa
5 Posts |
Posted - 05/30/2013 : 05:24:17
|
Hallo Rob
I have inserted this command : acMaximizeWindow(handle,0,0)
It seems that it is working now: It does not open the preview pane anymore. Looks like it must be maximized.
Thanks for your help
local ExplorerFound = false acGetAllWindows(1) for num, handle in pairs(sp_all_windows) do local exe = acGetExecutableName(handle,0,0) local class = acGetClassName(handle,0,0) if exe == "explorer.exe" and class == "CabinetWClass" then acActivateWindow(handle) acMaximizeWindow(handle,0,0) acDelay(50) acSendKeys("%d") acDelay(25) acSendKeys("{DELAY=10}c:\\ncp~") ExplorerFound = true break end end if ExplorerFound == false then acShellExecute("explore","C:\\ncp","","",3) end |
Manie |
|
|
Rob
USA
2615 Posts |
Posted - 05/30/2013 : 09:54:04
|
You can also call the Windows API function IsIconic to see if the window is minimized.
Add this to your Global Lua:
aliencore = alien.core
user32 = aliencore.load("user32.dll")
-- ************ IsIconic ************
gIsIconic = user32.IsIconic
gIsIconic:types{ ret = 'long', abi = 'stdcall', 'long'}
function aIsIconic(iWnd)
return gIsIconic(iWnd)
end Then use this updated script:
local ExplorerFound = false
acGetAllWindows(1)
for num, handle in pairs(sp_all_windows) do
local exe = acGetExecutableName(handle,0,0)
local class = acGetClassName(handle,0,0)
if exe == "explorer.exe" and class == "CabinetWClass" then
if aIsIconic(handle) then
acRestoreWindow(handle)
acDelay(25)
end
acActivateWindow(handle)
acDelay(50)
acSendKeys("%d")
acDelay(25)
acSendKeys("{DELAY=10}c:\\windows~")
ExplorerFound = true
break
end
end
if ExplorerFound == false then
acShellExecute("explore","C:\\Windows","","",3)
end |
|
|
Noesis
25 Posts |
Posted - 05/30/2013 : 23:17:37
|
Nice one Rob, I've been checking window position for minimized window check, as minimized windows seem to be located at less than -31000 x & y coordinates i.e. well and truly outside the desktop area, but I've since read that in theory some systems may well put the windows in different positions, so your solution is definitely preferred. |
|
|
MDB
South Africa
5 Posts |
Posted - 05/31/2013 : 08:46:07
|
Thank you for your help. If I want to open an application with strokeplus and add an action for it. Can I use this script to open the application and if the application is open switch to it and maximized it ?
Thanks for your help Manie
local AppFound = false acGetAllWindows(1) for num, handle in pairs(sp_all_windows) do local exe = acGetExecutableName(handle,0,0) local class = acGetClassName(handle,0,0) if exe == "Logos4.exe" and class == "CabinetWClass" then acActivateWindow(handle) acMaximizeWindow(handle) AppFound = true break end end if AppFound == false then acShellExecute("open","C:\\Users\\H.J. de Bruin\\AppData\\Local\\Logos4\\Logos4.exe","","",3) end
|
Manie |
|
|
Rob
USA
2615 Posts |
Posted - 05/31/2013 : 10:19:31
|
Sure, but you don't need this part (as it's unlikely Logos4 happens to have the exact same class name as Windows Explorer:
and class == "CabinetWClass" |
|
|
|
Topic |
|
|
|