
Mudoch
Members-
Posts
6 -
Joined
-
Last visited
Mudoch's Achievements

Seeker (1/7)
0
Reputation
-
AutoIT Toggle between two desktop apps - (Moved)
Mudoch replied to Mudoch's topic in AutoIt General Help and Support
Well after an entire day digging I found enough on this subject and created a working solution. So since I wanted to avoid extra configuration outside the solution I now Launch AutoIt from within my VBA application to enable the toggle and processing trigger. The VBA does the heavy work, though AutoItX, to verify the Windows exist before launching the main script passing 2 parameters of the windows(apps) I want to control. Here is the script: ;AutoIt v3.x script for control of two Apps in windows 10 ;Equals(=) toggles between apps only ;Num Pad Add key toggles from Host1 to Host2 and starts processing data in Clipboard ;Created by Larry Sall Jan 2020. ;Windows are defined and checked in VBA then passed here as params #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> $cmdparms = $CmdLine[0] if $cmdparms > 1 Then ;Define our windows $sHost1_Win = $CmdLine[1] $sHost2_Win = $CmdLine[2] ;Insert our HotKeys HotKeySet("{=}", "ToggleWin") HotKeySet("!{ESC}", "Terminate") ;Alt{ESC} HotKeySet("{NUMPADADD}", "Host1Run") ;Stay in Memory and run While 1 Sleep(100) WEnd Else MsgBox($MB_SYSTEMMODAL,"App Window Error","Missing required parameters") EndIf Func ToggleWin() if winactive($sHost1_Win) then if winexists($sHost2_Win) Then Winactivate($sHost2_Win) EndIf ElseIf Winactive($sHost2_Win) Then if WinExists($sHost1_Win) Then WinActivate($sHost1_Win) EndIf Else ;allow normal keystroke in any other window HotKeySet("{=}") send("=") HotKeySet("{=}", "ToggleWin") endif EndFunc Func Terminate() Exit 0 EndFunc Func Host1Run() if WinActive($sHost2_Win) Then WinActivate($sHost1_Win) Send("^{F1}") Else ;allow normal functionality in any other window HotKeySet("{NUMPADADD}") Send("{NUMPADADD}") HotKeySet("{NUMPADADD}", "Host1Run") EndIf EndFunc Not sure if this is best way but it works. -
AutoIT Toggle between two desktop apps - (Moved)
Mudoch replied to Mudoch's topic in AutoIt General Help and Support
Melba23, like your tag line. I'm in the mindset of "Old enough to know better, young enough to not worry" -
AutoIT Toggle between two desktop apps - (Moved)
Mudoch replied to Mudoch's topic in AutoIt General Help and Support
Actually as far as a Hotkey functionality with AutoIt I've done nothing as I don't seem to find anything helpful as a simple sample. The product I work with has default "Hotkeys" that allow the program to toggle between apps and also to trigger a VBA event that allows us to ingest data to pass on to the main program. The product and the connectivity tool they use are built as 32bit solutions and do not recognize 64 bit applications. The vendor has told me at this time they have no plans of implementing a 64bit connectivity module for Windows applications. As I said the problem is Windows 10 and bit-ness of desktop applications. If the application is 64bit the Hotkey simply posts to the window the actual key and not toggle windows or trigger the VBA event. My time constraints did not allow me much time, less than an hour to be honest, to resolve the problem. So when I found both AutoIt and another program that offer the HotKey element it was the fix I needed. AutoIt had both needs a HotKey and the ability to replace SendKeys in VBA, the other application seemed to only offer HotKey tooling. I quickly got AutoIt Dll working for the data return, found plenty of samples, but I could not find how to use AutoIt for the desktop hot key functionality the samples I found what seemed to be all kinds of things mostly too complex for my needs and difficult to break down with the time constraint. With the other hotkey app I found there was plenty on the desktop hotkey samples but nothing on VBA integration, it does not seem to be available. Now I have a bit of time, off the clock, to step back and try to figure out how to do the HotKey toggle and sending of keystrokes through AutoIt. The goal being to reduce long term support needs and overhead of multiple applications installed and running on a system. For simple reasons I'll use Chrome and Notepad++ as the 2 apps I'm toggling between and Notepad++ as the main app I want to send a keystroke to activate a Menu option in. Here is the other tools script that allows this to work. I removed obvious references to that hotkey program from the script. The script is loaded with the other app through Windows C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup folder entry. ;IF Numpad+ switch to Notepad++, push Ctrl{F1} to Notepad++ #ifwinactive class Chrome_WidgetWin_1 Numpadadd:: winactivate, class Notepad++ sendinput, ^{F1} return ;If = key toggle beween Chrome and Notepad++ #ifwinactive class Chrome_WidgetWin_1 =:: winactivate, class Notepad++ return #ifwinactive class Notepad++ =:: winactivate, class Chrome_WidgetWin_1 return Any help is most appreciated, thanks. -
I need to replace a desktop applications functionality. I'll call it App "A". The application has defined 2 hot keys one that toggles between it and another window, App "B", and one that triggers keystrokes to App "B" to get data where App "A" can access it. Then tells app "A" to fire off processing of data.. Unfortunately when App "B" is a 64bit application this functionality no longer works. For now I've hobbled together a work a round solution by using 2 apps with what appears to be similar abilities. AutoIt and a desktop application that allows me to define the 2 hot keys. The SutoItX Dll is great for my processes within App "A" as it uses VBA for event driven tasks. The second app allows me to define the Hot keys and which windows they belong to. My fail is on how to use AutoIT to define the hot Keys and link to specific windows. So as I see this working: App "A" launches and fires off internal VBA code that in turn sets up HotKeys. If App "B" is not found code shuts down without enabling the hotkeys. A hot key of CTRL-F1 toggles, activates window, back and forth between App "A and "B" So the hotkey is captured only when either App "A" or "B" is currently the active focus. and swaps the active focus application window. A hot key of CTRL-F2 from App "B", Send Key strokes to App "B" to place App "B" windows' content into windows clip board then switch to App "A" and send a keystroke, CTRL-F3, to trigger processing the clip board through App "A"'s normal event handlers. App "A" already knows that CTRL-F3 means to run custom VBA code to process the clipboard. Any help would be appreciated here, thanks.
-
Sorry about that somehow the message got posted while I was typing..... The original VBA app worked as follows and used only VBA Functions/Methods to control the External app as follows: * Creates XML request * Starts external Application * Looks for Output File to be exclusively accessible * Processes return XML for for results The current version creates the result file immediately and releases it, then prompts operator to press OK then re-write the file. in the VBA class I now use AutoIT to look for the window with the prompt and to confirm the OK button exists, it does not until the process is finished. I then send Enter to window and then begin to validate the output file is accessible exclusively. As I said I want to port this functionality to C# Class. So I'm a bit stuck with the use of AutoIt under .net as I've seen a post or two regarding not able to find child windows and controls. Any sample c# code available to get me started? I've got 80% of the class written and was about to finish off the external app launch and control when they released the latest "glitch".
-
So first let me describe my challenge. I use an external windows application to process an XML file. the process provide a result XML file and a printed output both of which is needed by the enduser. The application is maintained by a company that offers 2 solutions for the process a desktop application and an API. The API is very limited and requires the use of the application for many functions. The API also limits the printed output, it's the API design or the highway. The Application allows the end user modifications to printed output. I've been using the Application for years but recently the manufacture has changed hands and of course changed focus. Recent changes has changed the desktop application to require a limited user interaction and that presents an issue with required output. I've reported this "glitch" and it's taken 40 hours of calls to support with no answer as to a fix to work as documented. Recently I've cobbled together using AutoITX.DLL a patch to my VBA class project that does this work. My goal and the reason for this post, I want to port to C# and .net core that vba Class. Here's what the VBA app does: