Mudoch Posted January 14, 2020 Posted January 14, 2020 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.
Moderators Melba23 Posted January 15, 2020 Moderators Posted January 15, 2020 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Nine Posted January 15, 2020 Posted January 15, 2020 What have you tried so far ? You seem to have done some tests with AutoIt. Please post the code you have so far, and tell us where you have issues. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Mudoch Posted January 18, 2020 Author Posted January 18, 2020 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.
Mudoch Posted January 18, 2020 Author Posted January 18, 2020 Melba23, like your tag line. I'm in the mindset of "Old enough to know better, young enough to not worry"
Mudoch Posted January 19, 2020 Author Posted January 19, 2020 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: expandcollapse popup;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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now