shorterxp Posted July 23, 2018 Posted July 23, 2018 (edited) Hi, VBS question: I open the program and bring it to front, then pressing CTRL+TAB desired operation occurs. When I try to replicate actions / macro via vbs script with iswindowactive followed by sendkeys it doesn't work. Research suggests CTRL+TAB is equivalent to WshShell.SendKeys "^+({TAB})" but nope it doesn't work. Also tried WshShell.SendKeys "^({TAB})" and nothing. Set WshShell = CreateObject("WScript.Shell") WshShell.Run """%PROGRAMFILES%\Folder\App.exe""" < this works WScript.Sleep 1000 < allows time to load Set WshShell = WScript.CreateObject("WScript.Shell") IsWindowActive = WshShell.AppActivate("Audio Control Panel") If IsWindowActive Then WScript.Sleep 1000 WshShell.SendKeys "^+{TAB}" < movement is seen on the buttons of window, but it is not the desired one. End If Any clues? Edited July 23, 2018 by shorterxp
jaclaz Posted July 24, 2018 Posted July 24, 2018 The code "^+{TAB}" doesn't look like valid. The "^" means CTRL, but the "+" means SHIFT: https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/sendkeys-statement The "^({TAB})" seems correct though braces shouldn't be needed, i.e. "^{TAB}" Sendkeys is very tricky, and has often timing issues, maybe the 1000 is too low. In this example, 5000 is used: https://filedb.experts-exchange.com/incoming/2011/01_w02/386787/Cycle-And-Reload.txt jaclaz
shorterxp Posted July 30, 2018 Author Posted July 30, 2018 (edited) This worked once! then never again!! The timer isn't a problem, 1000 or 5000 its the same, ctrl doesn't register. I've read online that this is unfortunately a inhernant problem with VBS. SendKeys just isn't reliable. What I want to do is open a .exe but on a specific TAB. This is not a browser tab but a set of options in tabular form. I wonder if there is anyway to do with with a shortcut in windows XP? Edited August 2, 2018 by shorterxp
jaclaz Posted July 31, 2018 Posted July 31, 2018 Autoit usually works fine, but of course you need to either compile the script or install the program. Since Send in itself can in some cases be not reliable, they also have a controlsend, said to be more reliable: https://www.autoitscript.com/autoit3/docs/functions/Send.htm https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm jaclaz
shorterxp Posted July 31, 2018 Author Posted July 31, 2018 (edited) Thanks There is a command line utility called sendkeys.exe written by Orlando Magalhaes Filho. It accepts similar commands, the documentation says it can be invoked from VBS, CMD and LNK (shortcut). So far it looks promising but how do I invoke an executable to a .LNK? Target Box? with sendkeys.exe in als o working directory The documentaiton gives no examples - I emailed the dev no reply yet. With sendkeys.exe you can define a delay prior to key strokes too which is ideal. The goal is to activate a shortcut (by using a keyboard shortcut - a feature of .LNK files) and then that shortcut starts sendkeys.exe alongside the desired applet.exe. Edited July 31, 2018 by shorterxp
jaclaz Posted July 31, 2018 Posted July 31, 2018 20 minutes ago, shorterxp said: The goal is to activate a shortcut (by using a keyboard shortcut - a feature of .LNK files) and then that shortcut starts sendkeys.exe alongside the desired applet.exe. Hmmm. The goal is seemingly to use a shortcut (special key combo pressed on the keyboard) and that should open a given app and switch its windows to another tab. The use of a .LNK file is some means to the goal that you believe is a suitable one. If the goal is confirmed, I would rather use AutoHotKey (that has AFAICR very good provisions to send keys to programs): https://autohotkey.com/docs_1.0/commands/Send.htm and - as the name says - can be invoked/started with a hot key. If you want to use sendkeys.exe with a shortcut: http://cpap.com.br/orlando/SendKeysMore.asp you will need to make a batch file (or a VB script) that first runs the "target" app and then runs sendkeys.exe and point the shortcut to the script. jaclaz
shorterxp Posted August 1, 2018 Author Posted August 1, 2018 (edited) Grazie ========================================================================= Edit AHK works perfectly, I made a notepad file contaning Run, CTAudCSA.exe Sleep, 750 IfWinExist Audio Control Panel WinActivate send ^{TAB} Then used "Ahk2EXE.exe" to convert it to .exe, - this can now be executed from shortcut. My only complaint is its 808kb footprint! Now when I press a key, this opens shortcut, runs the Script above, the result: Luckily when the program is installed OptimumX shortcut.exe utility allows user to define Hotkey with /H:<keyboard numeric value>. I used 145 which is Scroll Lock. shortcut /a:c /f:"%allusersprofile%\start menu\programs\Auzentech\Control Panel.lnk" /t:"%programfiles%\Auzentech\X-Fi Forte 7.1\AudioCS\AutoMode.exe" /w:"%programfiles%\Auzentech\X-Fi Forte 7.1\AudioCS" /i:"%programfiles%\Auzentech\X-Fi Forte 7.1\AudioCS\CTAudCSA.exe" /h:145 Heres a list of keyboard numeric vlues: http://virtuawin.sourceforge.net/?page_id=171. I'm new to coding world, free command line utilities can be powerful. Edited August 15, 2018 by shorterxp
Tripredacus Posted August 2, 2018 Posted August 2, 2018 I have read a couple people with Auzen card use this thing called X-Fi Mode Changer. It wasn't designed for your specific hardware or software. https://web.archive.org/web/20080721034415/http://www.freewebs.com/spectra9/xfmc.html
jaclaz Posted August 2, 2018 Posted August 2, 2018 15 hours ago, shorterxp said: Then used "Ahk2EXE.exe" to convert it to .exe, - this can now be executed from shortcut. My only complaint is its 808kb footprint! Yep , that is a common issue with "compilers" (like the AutoHotKey one) that are essentially an assembly of the interpreter .exe + the actual script. Since your script is extemely simple, maybe (it has to be tested) it will work with AutoHotKey v.1.0 (once called "Basic") that should allow to make .exe's in the around 200-300 KB size range. jaclaz 1
shorterxp Posted August 2, 2018 Author Posted August 2, 2018 (edited) 202KB Thanks Mode changer needs extras installed notebaly console launcher, a skinned control panel. I did try it before but prefer this new HotKey method (a good compromise) On a clean install, my WinRAR SFX quickly installs control panel and drivers only. I ran original 280mb Installer by Creative (InstallShield), monitored registry changes with InstallWatchPro (by Gavin Stark) then exported changes to .txt use in SFX setup... Some of entries contained therein define absolutes i.e. "C:\". For security, I used Find And Replace Text utility replaces all instances of "C:\" to current drive (which may not be C at time of install). Windows Move command then converts that .txt back to .reg during setup, resultant .reg is imported silently. Here is example of setup.cmd inside SFX installer: Quote PF.exe PUSHD "%allusersprofile%\start menu\programs" md Auzentech POPD shortcut /a:c /f:"%allusersprofile%\start menu\programs\Auzentech\Control Panel.lnk" /t:"%programfiles%\Auzentech\X-Fi Forte 7.1\AudioCS\AutoMode.exe" /w:"%programfiles%\Auzentech\X-Fi Forte 7.1\AudioCS" /i:"%programfiles%\Auzentech\X-Fi Forte 7.1\AudioCS\CTAudCSA.exe" /H:145 fart -c --count install.txt C:\ %systemdrive%\ delay.vbs move install.txt install.reg delay.vbs regedit /s install.reg @ECHO Do not close / wait for setup to finish! Setup.exe People miss the fact that inside creative XP driver pack, usually in 'Driver' folder theres a setup.exe, which installs drivers only. Not sure if equivalent exists for win 7 (which uses UAA not WDM). The setup.exe dialog looks like this: Example of custom SFX: Edited August 4, 2018 by shorterxp
shorterxp Posted August 2, 2018 Author Posted August 2, 2018 I'm really diggin the new hotkey, so fluid and easy to use, wouldn't have been possible without msfn! TBH I'm surprised creative didn't make the modes tab the first one that shows.... oh well. 1
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now