How to type WORD vv anywhere, and get the browser to open a link containing WORD in it? I know the script must have
Run, browserpath www.example.com/x/y/z/WORD.html
but I don't know what to do next.
I would use something like this:
:*:vv::
InputBox, UserInput, WORD, Enter a WORD, , 200, 120
if not ErrorLevel
{
; remove first and last white spaces
UserInput := trim(UserInput)
; replace all middle white spaces with +
UserInput := StrReplace(UserInput, A_Space , "+", UserInput)
Run, "browserpath" "www.example.com/x/y/z/%UserInput%.html"
}
return
Examples:
; google with the default browser
Run, https://www.google.com/search?hl=en&q=%UserInput%
; google images with IE
Run, iexplore.exe "https://images.google.com/images?hl=en&##"
; google autohotkey with another browser
Run, "browserpath" "https://www.google.com/search?sitesearch=ahkscript.org&q=%UserInput%"
; autohotkey.com
https://www.autohotkey.com/search/search.php?query_string=%UserInput%
; autohotkey manual
https://www.google.com/search?sitesearch=ahkscript.org&q=%UserInput%
; wikipedia
https://en.wikipedia.org/wiki/Special:Search?search=%UserInput%&go=Go
Related
My requirement is to develop an application in power builder, which receives Scanned barcodes and decodes it
The application should also be able to reveal hidden ASCII codes in the scanned barcodes.
Like:-
ASCII Codes
TAB - 9
BS Backspace - 8
EOT End of Transmission - 4
FF Form Feed - 12
Etc.
When scanned codes arrives at datawindow, rich text input, single line edit it comes as one character at a time
So my logic would be is to take that character before it is written in Datawindow or rich text input and find its ascii value and if it is less the 32 (which means it is a hidden character)
I can give brackets around it and show in display screen. so that hidden characters are not missed out.
Eg Scanned code abcdefgh
Decoded code will be abc[09]def[12]gh
So I tried with EditChanged, itemchanged , KeyDown events but I am unable to get the character before it is written in datawindow. Because once it is been written in datawindow hidden characters will be missed out.
Is there any event in powerbuilder will give me the scannedcode after it has been scanned but before it has been written in data window or rich text control,
Something like PreviewTextInput Event, which will preview the text before writing it into the data window.
Sample barcode Image uploaded
Thanks and regards,
The Event ID pbm_dwnchanging might work for you. Try creating an event on the DataWindow control that uses pbm_dwnchanging - this appears to capture the characters as they're being entered, but before they're put into the edit control (like you would think pbm_dwnkey should).
// "prototype" in the window object's datawindow control declaration:
event onpbmdwnchanging pbm_dwnchanging
Here is the pbm_dwnchanging event extension's code - basically, it calls a method that builds the "representation" of the data being entered and logs it (i.e.: appends a Multi-line Edit control in the window).
event onpbmdwnchanging;
string dataRepresentation
// get the representation of the data
dataRepresentation = getDataRepresentation(data)
// log it to the window's MLE
addLogMessage("onpbmdwnchanging - row: " + string(row) + " data: '" +
dataRepresentation + "'")
return
end event
Lastly, the function that builds the "representation" of the data:
protected function string getDataRepresentation (string as_input);
string dataRep
char dataChars[]
string currentChar
long ll_datalength, ll_index
dataChars = as_input // cast the string into a character array
ll_datalength = upperbound(dataChars)
for ll_index = 1 to ll_datalength
currentChar = dataChars[ll_index]
if Asc(currentChar) < 32 then
// "hidden" character
dataRep += "[" + string(Asc(currentChar)) + "]"
else
dataRep += string(currentChar)
end if
next
return dataRep
end function
note: tested and works in PB 12.6
I have a small problem I cant find the solution to:
On my italian keyboard one key holds the two simbols "<" and ">":
[key] = "<"
[shift]+[key] = ">"
I'd like to remap them so that the result ins inverted as I use > much more than <.
I can't find a way to write this in ahk. I tried with
<::>
+>::<
and
<::>
>::<
The result with the above is that both pressing the key and shift+key returns ">".
I understand what "confuses" ahk but I can't find a workaround.
Any suggestions?
Try
#UseHook ; prevents the Send command from triggering the hotkey itself
<:: Send >
+<:: Send <
Spell Check is a default application in Linux. With the help of that application, can we check the spelling of a text field while users enter data?
Some (or many?) Linux distributions contain a command line utility that is called spell. If you run this with words as parameters, you need to press return a second time, but if you use a file as a paramater, you don't need to press return again. This means that a solution could be:
write the text of a field to a file
run the command line utility from LiveCode's shell function with the file as parameter
parse the result returned by the shell function
Before you try this, open your terminal on Linux and type spell. Press enter to see if the command is recognised. If yes, then the script below should work.
This script writes the text of a field to a file, does a spell check on the file and returns the incorrect words to LiveCode. I haven't tested the script and you may have to tweak it a little.
function spellCheck theText
// works on Linux only
if the platform is "Linux" then
// remove everything that isn't a word
put replaceText(theText,"[^\w]","") into myWords
// write clean data to a temporary file
put the tempName into myTempFile
put myWords into url ("file:" & myTempFile)
// call spell with shell
put "spell" && myTempFile into myShell
// only return the incorrect words
put line 2 to -1 of shell(myShell) into myCorrections
// return the incorrect words to calling handler
return myCorrections
else
// this isn't Linux
return "error"
end if
end spellCheck
//theField is the short name of a field
on checkField theField
// call above function
put spellCheck(the text of fld theField) into myWords
// myWords should now contain the incorrect words
if myWords is not "error" then
lock screen
// parse incorrect words and mark them in the field
repeat with x = 1 to number of words of field theField
if myWord is among the lines of myWords then
// an incorrect word has been found and is marked red
set the textColor of word x of fld theField to red
end if
end repeat
unlock screen
end if
end checkField
Usage: checkField shortNameOfTheField
I was wondering.. How can I assign a variable / text to a key (shortcut)?
This is what I am trying to achieve:
myVar = Hello
#F11 = myVar ;myVar ("hello") is stored / bound to the shortcut: `WINDOWS+F11`.
So, whenever I press WINDOWS + F11, it should paste/write the content of myVar.
Is this even possible? If yes, can I do it with multiply keys?
This is the correct syntax:
SendMode Input
myVar := "Hello"
myOtherVar := "World"
#F10::Send, Hello world!
#F11::Send, %myVar%
#F12::Send, %myOtherVar%
You'll notice that the text is only sent when you release the WIN-key. This is intended, and is a special behavior for the WIN-modifier. You can read more about it here.
In an autohotkey script I was trying to assign a text string to a variable. Can anyone spot why this doesn't work, it looks just like some provided examples? I don't need the variable anymore, but now I'm just curious what I did wrong...
myvar := % "foo" ; creates global variable myvar, but has no contents
I know you could just say myvar = foo
but leaving quotes off a fixed text string just makes me cringe. I even had it working but didnt' save my file before making 'a few harmless cosmetic edits.' I click on the "H" task
icon near the clock, use menu File / show variables to verify the empty contents...
Okay, so we assign a value to a variable:
eval_this:= "harry"
If you do it this way, you just read the contents of the variable:
msgbox %eval_this% ;=harry
Of course, here, the text is not evaluated - "eval_this" is just text to ahk:
msgbox eval_this ;= eval_this
This method is called a "Forced Expression" - which is what you are looking to do. It tries to read the text string as if it were code. It isn't reading the contents of any variable, it is looking at the text and forcing it to become a variable (it's sort of the same thing, but not really)
msgbox % eval_this ;= harry
This also gets us harry, and you can see how we are reading the variable:
test := eval_this
msgbox %test% ;=harry
Same thing, different approach (forcing the text to become a variable):
test = % eval_this
msgbox %test% ;=harry
Consider this, where we force both text strings into their actual values
eval_this := "harry"
this_too := " and bob"
test = % eval_this this_too
msgbox %test% ;= harry and bob
Okay, now that you've got all that, here is a practical application. We will force the value of the text string to be a variable. Since we've actually defined what "alert" is, then the gosub will call that definition. Pop this into a script and run it:
eval_this := "alert"
gosub % eval_this
exit ;we are finished with the demo, so end here
alert:
msgbox harry
return