I'm doing some code for my logitech mouse with lua but I can't find any way to communicate with my pc at all. No lib available here so I can't even send smth to cmd, write file, launch .bat and etc. At least I wasn't successful at this.
The only place where you can output some info is the log window. So the title asks main problem of this topic: Is there any way to get data from logitech lua log console?
To run a .bat file from LGS Lua script:
Create a shortcut action
Run 'Logitech Gaming Software' application
Open 'Customise buttons' tab
Select profile
In the left side you will see the 'Commands' pane (list of bindable actions such as keyboard keys, macros, etc), press the big 'plus' sign to add new command.
In the 'Command Editor', select the 'Shortcut' in the left pane
Set the 1st text field 'Name' to RUN_BAT_FILE
Set the 2nd text field 'Enter a shortcut' to your_bat_file.bat
Set the 3rd text field 'Working Directory' to C:\Path\to\folder
Press 'OK' button to close the 'Command Editor'
Now you can:
either bind this action to a mouse button (drag-n-drop action RUN_BAT_FILE from Commands pane to the big picture of the mouse)
or invoke this action from your LGS Lua script by PlayMacro("RUN_BAT_FILE")
Please note that console window will be brought to the front, and your game will switch off fullscreen mode and will lose keyboard focus.
That is a very nasty thing while you're playing.
But you can invoke windowless applications without interfering the game.
To pass a long message from LGS Lua script to external program:
You can send strings by invoking OutputDebugMessage in your LGS script
and receive them in your external program by means of LGS Debug Interceptor.dll.
To pass information from your external program to your LGS Lua script:
The best way I'm aware of is the following:
Your external program can create a .lua-file and your LGS Lua script can execute it and receive the result (a tuple of Lua values returned by this script)
data = dofile[[c:\some_script.lua]]
Related
I have found the answer myself but I am documenting this for myself in the future or for other fellow content creators in case if I would ever forget it.
What I would like to achieve in the grand scheme of things is to play music that is locally stored on my computer on stream. I want the ability to change moods based on a button that is configured on my stream deck. Currently no plugins in the stream deck allow this (I do not count Spotify) so I am going custom.
The best tool for the job is VLC. They have a command line that can be used. I have considered things like media player or groove music but there is no support.
What I need to do is:
Open VLC
Add my specific playlist to the player
Whenever I click another button on my stream deck, clear the playlist, add that specific playlist.
VLC command line is documented here: https://wiki.videolan.org/VLC_command-line_help/
Do a CTRL+F on that page for the word: "Clear" and you will find there is no command for clearing a playlist that is currently playing.
How did I solve this? --> Powershell. (see answer below)
THE ANSWER:
You need to configure a global key that can be pressed anywhere to clear the playlist. This enables you to clear a playlist without being focused in the VLC window. This setting is configured during the startup of VLC. Then send a key stroke of the key you just configured. This is done by adding the following attribute:
--global-key-clear-playlist='CTRL+W' You can choose your own keys to your liking by changing CTRL+W to what you desire.
Example command:
Powershell.exe cd 'C:\Program Files\VideoLAN\VLC\';./vlc.exe --loop -Z --global-key-clear-playlist='CTRL+W' --one-instance --directx-device="DISPLAY1" --directx-volume=1.00 '"Path\To\Your\Playlist\playlist.m3u'"
Once VLC has started this way, send over a key stroke for example, through PowerShell, to press the key.
Example command:
powershell.exe $wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{w}');
If you want to send over other kind of keys, check out the following stack overflow article: How to send CTRL or ALT + any other key? OR the official documentation: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ff731008(v=technet.10)?redirectedfrom=MSDN
The ';' means end the current code line and start a new line. Then read that line and execute what is written. This can be used to write down multiple commands that have to be executed in PowerShell even though you can only write down one line of text in your solution. (mine being the stream deck)
If you are a streamer or youtuber using the stream deck, keep reading. Otherwise above is the answer and you can adapt it to your needs with the above logic.
STEP BY STEP GUIDE IF YOU ARE A STREAM DECK USER:
I have my stream deck configured with the following commands:
a multi action button. Inside the multi action button I have 2 tasks:
Clear Playlist --> Open program action. (the rocket)
Add playlist. --> Open program action. (the rocket)
For the first action I have the following command in the App / file section:
powershell.exe $wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{w}');
--> This will send over the key stroke CTRL + W. In case you don't have anything open or you have not started VLC yet because this is your first press, this has no effect.
The second action is adding the playlist to VLC. This is done with the following command:
Powershell.exe cd 'C:\Program Files\VideoLAN\VLC\';./vlc.exe --loop -Z --global-key-clear-playlist='CTRL+W' --one-instance --directx-device="DISPLAY1" --directx-volume=1.00 '"Path\To\Your\Playlist\playlist.m3u'"
--> This command will navigate to the directory where VLC is installed. It will then open vlc with the attributes:
--loop --> Loop all music without stopping
-Z --> Randomize every play and next play
--global-key-clear-playlist --> The key stroke that can be pressed, no matter what window you are focused in
--one-instance --> Only one instance of VLC can run at a time, forcing every vlc.exe command to go to the same instance
--directx-device="DISPLAY1" --> My display where I want VLC to appear. You can find this under the settings: Tools > Preferences > Video > Full screen
-volume=1.00 --> The volume that will be used.
HOW TO ROUTE AUDIO TO A SPECIFIC AUDIO DEVICE IN VLC
For some people that have a GO-XLR or any special device they want to route their music to, open up the GUI of VLC first, navigate to: Tools > Preferences > Audio
Change the device you want VLC to output to. I have tried forcing it through windows 10 settings but it did not seem to work every time I restarted the computer.
If you are a stream deck user:
First of all, enable remote control of VLC. You do this by doing the following:
Activating the Web Interface
To activate the web interface, click the
Tools menu in VLC and select Preferences. Click the All option under
Show settings to view VLC’s advanced settings. Scroll down in the list
of advanced settings and select Main interfaces under the Interface
header. Click the Web checkbox to enable the HTTP interface. Click on
LUA under the Main interfaces. Set a password under the LUA-HTTP
settings. Save your settings and restart VLC. Each time you start VLC,
the web server will be started in the background – Windows will prompt
you to allow VLC firewall access when you restart it, indicating that
the web server is running.
Configuring Stream Deck VLC Control In your stream deck configuration
manager, add a VLC Control button. Click on this button, and set the
following parameters, replacing password with the password you
previously set. Host: localhost Port: 8080 Password: {PASSWORD SET IN
VLC}
This is to have an extra plugin installed https://github.com/RGPaul/streamdeck-vlc --> This will enable you to stop and start your music on the stream deck. (you can find it on the product page inside of the stream deck application) However it is not necessary for clearing the playlist.
I want to set up an Automator Quick Action that runs the bbdiff command, and passes it the selected files in the Finder.
I created a Quick Action, and set it to receive "files or folders" in "Finder.app".
Then I added the "Run Shell Script" action, and set the shell to "/bin/bash", and to Pass Input "as arguments". The script is:
/usr/local/bin/bbdiff "$1" "$2"
If I run that script manually from Automator or Terminal (replacing the arguments with real filenames) it prompts me to authorize the host program to control BBEdit, and then it works.
But if I run it from the Finder, I get this error:
The action “Run Shell Script” encountered an error: “You must allow bbdiff to send events to the BBEdit application.
Use tccutil reset AppleEvents to reset the system's permissions, and try again.
bbdiff: error: -1743”
I tried running tccutil reset AppleEvents and running the action again, but it showed the same error.
I also tried adding bbdiff, /bin/bash, and Finder to the Accessibility and Full Disk Access tabs of System Preferences > Privacy, but nothing changed. It looks like you need to add something to the Automation tab, which can't be done manually.
How can I get it to allow a UNIX command like bbdiff to control an application?
UPDATE:
I managed to work around this by using a "Run AppleScript" action, instead of "Run Shell Script", with this script:
on run {input, parameters}
tell application "BBEdit" to compare (item 1 of input) against (item 2 of input)
return input
end run
The first time I ran it, I got the prompt to allow Finder to control BBEdit, and then it worked.
But this wouldn't work for other shell scripts, so the question is still open.
In my case, I was able to fix it simply by closing the currently opened BBEdit then opening it again. In my case, I was doing a BBEdit update before the error appears.
I want to create a custom plugin which gets displayed on the tool bar in wireshark GUI. When the user clicks on the new custom option, then the custom lua script should be executed.
How can I achieve this?
Simply go through the following steps:
In your plugin Lua file (which you should make sure Wireshark loads), start by adding a function which does the job you want your plugin to do:
local function runPlugin()
--here your plugin does its job
end
Then you register the runPlugin() function to be launched from the wireshark toolbar:
register_menu("Lua/Launch my plugin", launhing_function, MENU_TOOLS_UNSORTED);
Now when you open Wireshark and click on Tools > Lua > Launch my plugin the runPlugin() function is called.
Hope this helps!
I am looking for allready for hours how to do this. So don't tell me to use search function. I know there are many things related.
There is many stuff on the internet and here, but no one works for me.
And I need a solution for Selenium IDE or something intergrated with it (if there is anything). Not RC and not WebDriver etc.
I need to simulate a key for an JavaScript confirmation popup, which has "OK" and "Cancel" buttons.
The problem is that I cannot select anything.
Popup appears when the site is opened. The Website itself is visible in the background, but no element can be selected (Firebug shows nothing as well, empty html(?)).
If I press ENTER key the confirmation box disappear (so it works fine manually).
This example seems good, but I can't find any interface in Selenium IDE to do this:
driver.switchTo().alert().accept();
(from Click in OK button inside an Alert (Selenium IDE))
I have only the following pattern:
Or write the test in html, which uses the "Command", "Target", "Value" pattern.
Appreciate any help.
EDIT1:
With the link provided by Janesh Kodikara
I have found that my problem is:
Selenium IDE will not be able to handle alerts that are within the page's onload() function. It will only be able to handle alerts that are generated after the page has completely loaded.
There is no "onload" function in my website, but the script part which creates the alert is inside html which is called with page (not in any function). This must be the same as "onload", because the alert comes immediately when the website is opened.
Once you have a confirmation box, you must consume it (Click OK or Cancel button)
You can use "chooseOkOnNextConfirmation" command to instruct Selenium IDE to simulate clicking OK button.
See http://www.guru99.com/enhancing-selenium-ide-script.html for more details.
You will not see the Javascript popup when IDE script is run.
Selenium IDE
Command : runScript
target : {window.onbeforeunload=function(e){};}
Command :click
target : xpath of button.
This will work fine but you are not able to see popup.
When submitting SAS code via the SAS Toolbar (eg cmjohns response) the compiler knows that the code is being "DM'd" and will not run certain code (eg %window).
Is there a way to trick SAS into believing that code submitted from the Toolbar is coming from the Editor, therefore allowing interfaces (using %window) to be triggered via point and click?
It isn't super clean, but this will do it. The only downside is a program editor window will be open after it runs. There's probably a way to close it when it's done but I don't know what that is off hand.
pgm; clear;include "C:\path\code.sas"; submit;
Basically, this says to open a new program editor window and make sure no other code is in it, then include the contents of code.sas into the editor, then submit all the code that's in the program editor.
As a side note, in addition to a toolbar button, I think you could map a function key to a command like this as well. Press F9 to pull up the current mapping. There is a limit to the length of the command mapped to a key though so no long paths.