How to multiply a variable received from a GUI with a number? - global-variables

I am trying to make a very simple message spammer in AutoHotKey (just to have fun with friends)
(I've only found autohotkey recently and I am pretty knew to coding, so any feedback/improvements is welcomed, Thanks)
This is the code until now
#SingleInstance force
^6::
Gui, Add, Text, W200 +Center,"Message"
Gui, Add, Edit, W200 vTextt
Gui, Add, Text, W200 +Center,"Number Of Messages"
Gui, Add, Edit, W200 vLooop
Gui, Add, Text, W200 +Center,"Interval Between Messages"
Gui, Add, Edit, W200 vInterval
Gui, Add, Button, W200 gStart, Start Auto Spamming
Gui, Show
Return
Start:
Gui, Submit
Sleep, 5000
Loop, %Looop%
{
Send, %Textt%
Sleep, %Interval% * 1000
Send, {Enter}
}
Gui, Destroy
Return
esc::exitapp
Its works fine right until
Sleep, %Interval% * 1000
this line
When I run the scrip it prompts me with the correct Gui
For vTextt I put in my text
For vLooop I put in the number of loops
For vInterval I put in 1(as in 1 second)(delay between every message)
But in AutoHotKey 1 second must be written as 1000 (that is at least how I've been doing it)
So I multiply the variable(vInterval) with 1000 in the Sleep command , but the following error pops up
what do I do to fix this?(the delay doesn't occur and the message gets spammed instantly without any delay)
I've tired to make another variable in which it multiplies but I do not know how variables work in autohotkey
Thank in advance

When using a command that takes a number as the input (like Sleep, you do not need to enclose your numeric variables in parenthesis like %var% (As opposed to a command like Send that takes a text input in which you would need to do so in order to disambiguate it)
As such, you can remove the parenthesis surrounding your Interval variable in Sleep, %Interval% * 1000, so you end up with Sleep, Interval * 1000
Final Code:
#SingleInstance Force
^6::
Gui, Add, Text, W200 +Center,"Message"
Gui, Add, Edit, W200 vTextt
Gui, Add, Text, W200 +Center,"Number Of Messages"
Gui, Add, Edit, W200 vLooop
Gui, Add, Text, W200 +Center,"Interval Between Messages"
Gui, Add, Edit, W200 vInterval
Gui, Add, Button, W200 gStart, Start Auto Spamming
Gui, Show
Return
Start:
Gui, Submit
Sleep, 5000
Loop, %Looop%
{
Send, %Textt%
Sleep, Interval * 1000
Send, {Enter}
}
Gui, Destroy
Return
Esc::Exitapp

Related

qt app that takes in textedit barcode scanned, how to change focus between two fields

So for me the plan is like this:
I scan a barcode, it gets in first textedit;
I scan another barcode, it gets in the second textedit,
in this case i use focus and keyboard event.
my problem is when i scan first code it is fine but when I scan the second code, some of letters go to second texedit some go to first texedit.
I don't understand what is the problem
here is my code
void CWidget::keyPressEvent(QKeyEvent *event)
{
if(focusWidget() == ui->lePath && !ui->lePath->text().isEmpty())
{
ui->leInformation->setFocus(); //leInformation second edit
ui->leInformation->setFocusPolicy(Qt::StrongFocus);
ui->leInformation->KeyPressEvent(event);
}
else
{
ui->lePath->setFocus(); //lePath - first edit text, first code scanned //goes here
ui->lePath->setFocusPolicy(Qt::StrongFocus);
ui->lePath->KeyPressEvent(event);
}
}
like is a strange think cause sometimes works sometimes no, if both codes scanned have digits they work but if the second scanned code has uppercase letters they go from the first uppercase letters they are wrote to first edit. but if they are lowercase they are fine again. I m thinking it is a problem with keyboard event how they deal with uppercase. somehow maybe with shift, and they change between two edits.
if there is someone who has an idea on how i can properly write that keyboard event, please help thanks
here B should have been on the second. I'm being sure on how uppercase are being entered on keyboard event is about shift + letter and shift moves you to the other edit but how i can change this

How can I focus and autofill a text field in Autohotkey?

I'm attempting to write a script to automatically fill a web-field with the current date using an AutoHotkey script. However, I'm not sure how to focus a specific field by its name or id.
My current hacky workaround is to use Send, {Tab 84} to scroll to the specific field, type the date with Send, 6/28/2017, and submit the field manually. While the script works most of the time, it's blatantly apparent there are better methods.
How can I focus autofill specific text-field on a webpage using an AutoHotkey script?
An IE COM object should do the trick, as long as you're comfortable navigating the DOM with some JS of your own.
Here's an example:
F3::
wb := ComObjCreate("InternetExplorer.Application") ; Create a IE instance
wb.Visible := True
wb.Navigate("http://google.com")
Sleep, 5000
SendInput, This is test.{Enter}
Sleep, 5000
wb.document.getElementById("lst-ib").value := "This is another test."
wb.document.getElementById("_fZl").click()
return

PostMessage interferes with user input

I'm trying to send key stroke to an external application in java using jna.
It sends VK_DOWN key, also that application has a shortcut for ctrl+down which makes something very different. My application sends around ~15 down key with 1 sec in between, and if user happens to click CTRL during it while working on a different window, it breaks the application(treats it as ctrl+down).
I checked the keyboard messages via Spy++, compared mine with AutoIt, they are exactly same messages.
ControlSend("window_title", "", "", "{DOWN}")
This AutoIt code works perfect, even if I click ctrl when window is active or inactive, it does not interfere with down key.
My code on the other hand:
User32.INSTANCE.PostMessage(handle, WM_KEYDOWN, wparam, lparamDown);
User32.INSTANCE.PostMessage(handle, WM_KEYUP, wparam, lparamUp);
has exactly same messages, but it doesn't work.
I tried sending control up before sending down key but to no avail.
Spy++ output:
<14335> 00011456 P WM_KEYDOWN nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1 fAltDown:0 fRepeat:0 fUp:0
<14336> 00011456 P WM_KEYUP nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1 fAltDown:0 fRepeat:1 fUp:1
My ctrl clicks are not even on target application so why does it treat it as such? Should I use a hook?

How to show in GNU Screen hardstatus tabs that have an activity?

Each time I have more than 4 tabs, I really like to know in which one there's activity.
Until now, I used to benefit from rxvt tabbing system. It displays a * next to tabs which are not shown, but have an activity. It's really usefull when you're on a IRC channel for example.
How can I do it with zsh/screen ?
Here's my .zshrc :
function precmd {
echo -ne "\033]83;title zsh\007"
}
function preexec {
local foo="$2 "
local bar=${${=foo}[1]}
echo -ne "\033]83;title $bar\007"
}
and my .screenrc
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W} %c %{g}]'
[...]
shell "/usr/bin/zsh"
aclchg :window: -rwx #?
aclchg :window: +x title
This is documented in the manual:
monitor [on|off]
Toggles activity monitoring of windows. When monitoring is
turned on and an affected window is switched into the background,
you will receive the activity notification message in the status
line at the first sign of output and the window will also be
marked with an `#' in the window-status display. Monitoring is
initially off for all windows.
You can manually toggle monitoring for the current window via C-a M, or if you want monitoring on for all windows by default, add defmonitor on to your screenrc. Once on, any windows to the left or right of the current one in your hardstatus line (as expanded by %-Lw and %+Lw respectively in your hardstatus string line) will show an # symbol after the hyphen which follows the window number. You'll also get an alert message which can be configured via the activity command.
On my system, the # doesn't appear until something else in the window changes. This can be fixed by removing hardstatus off from your config file.
Finally, I strongly recommend that you try tmux. Development on GNU screen has mostly stalled, and tmux is an actively maintained and developed replacement which has pretty much a large superset of screen's functionality.

catching change in spinbox - rtcltk

I'm creating a spinbox in R using rtcltk with:
from <- tkwidget(leftFrame, type="spinbox", from=0, to=0.1,
inc=0.001, textvariable=freqFrom,
command = function(){updatePlot()})
This works as intended (updatePlot is called) when I use the arrows of the spinbox, but does not work if I just type something in manually.
How do I catch the "value changed" event?
By default it does not change in this case in case you type in an illegle value (like deleting the last digit), or if the update is time consuming then you would not want it to update between every keystroke when typing in a 3 or 4 digit number.
You can add an update button than calls updatePlot when clicked so that the user would type in the number and when they know they are finished would click the button.
If you really want the update to occur with every keystroke then you can use the tkbind function to call updatePlot (something like tkbind(*spinbox*, "<Key>", updatePlot) where spinbox is the variable pointing to the spinbox).

Resources