Autohotkey give a change only in specific language - autohotkey

#If !(langID = "EN")
:?:ign::ing
#If
I've tried to make an English filter with AutoHotKey but which is not apply on other languages.
I tested to indicate LangID = 0x0409 / langID = 0000409 but no works, how to make this to work?

Try
#If !(GetKeyboardLanguage(WinActive("A")) = 0x0409) ; English ; "!" means "NOT"
:?:ign::ing
#If
GetKeyboardLanguage(_hWnd=0){
if !_hWnd
ThreadId=0
else
if !ThreadId := DllCall("user32.dll\GetWindowThreadProcessId", "Ptr", _hWnd, "UInt", 0, "UInt")
return false
if !KBLayout := DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
return false
return KBLayout & 0xFFFF
}
https://autohotkey.com/board/topic/116538-detect-which-language-is-currently-on/#entry672236

Related

Total Pages of Active Foxit Window using Autohotkey

I've searched the site to make sure my question wasn’t already answered.
My problem is I'm trying to find the total number of pages that an open PDF file contains.
I'm able to find the total number of pages if I know the file path. So that means, my problem comes down to, me not knowing how to find the file path of an open window of an (active) PDF file.
I'd like to do all this in Autohotkey and my pdf reader is Foxit PhantomPDF. I have been able to do this for Adobe Acrobat in the past, but I guess Foxit Phantom isn't as popular so I wasn't able to find a solution.
Any help would be appreciated.
Here's the code I have so far
Description of code: So if I put the file in a specific place, I can find the total page numbers by pressing F1. (Half of what I need)
F1::
pdfPath := "C:\20yorkcondofin.pdf"
VarSetCapacity(GUID, 16)
DllCall("ole32\CLSIDFromString", "wstr", IID_RandomAccessStream := "{905A0FE1-BC53-11DF-8C49-001E4FC686DA}", "ptr", &GUID)
DllCall("ShCore\CreateRandomAccessStreamOnFile", "wstr", pdfPath, "uint", Read := 0, "ptr", &GUID, "ptr*", IRandomAccessStream)
CreateClass("Windows.Data.Pdf.PdfDocument", IPdfDocumentStatics := "{433A0B5F-C007-4788-90F2-08143D922599}", PdfDocumentStatics)
DllCall(NumGet(NumGet(PdfDocumentStatics+0)+8*A_PtrSize), "ptr", PdfDocumentStatics, "ptr", IRandomAccessStream, "ptr*", PdfDocument) ; LoadFromStreamAsync
WaitForAsync(PdfDocument)
DllCall(NumGet(NumGet(PdfDocument+0)+7*A_PtrSize), "ptr", PdfDocument, "uint*", PageCount) ; get_PageCount
ObjReleaseClose(IRandomAccessStream)
ObjReleaseClose(PdfDocumentStatics)
ObjReleaseClose(PdfDocument)
msgbox % PageCount
return
CreateClass(string, interface := "", ByRef Class := "")
{
CreateHString(string, hString)
if (interface = "")
result := DllCall("Combase.dll\RoActivateInstance", "ptr", hString, "ptr*", Class, "uint")
else
{
VarSetCapacity(GUID, 16)
DllCall("ole32\CLSIDFromString", "wstr", interface, "ptr", &GUID)
result := DllCall("Combase.dll\RoGetActivationFactory", "ptr", hString, "ptr", &GUID, "ptr*", Class, "uint")
}
if (result != 0)
{
if (result = 0x80004002)
msgbox No such interface supported
else if (result = 0x80040154)
msgbox Class not registered
else
msgbox error: %result%
ExitApp
}
DeleteHString(hString)
}
CreateHString(string, ByRef hString)
{
DllCall("Combase.dll\WindowsCreateString", "wstr", string, "uint", StrLen(string), "ptr*", hString)
}
DeleteHString(hString)
{
DllCall("Combase.dll\WindowsDeleteString", "ptr", hString)
}
WaitForAsync(ByRef Object)
{
AsyncInfo := ComObjQuery(Object, IAsyncInfo := "{00000036-0000-0000-C000-000000000046}")
loop
{
DllCall(NumGet(NumGet(AsyncInfo+0)+7*A_PtrSize), "ptr", AsyncInfo, "uint*", status) ; IAsyncInfo.Status
if (status != 0)
{
if (status != 1)
{
DllCall(NumGet(NumGet(AsyncInfo+0)+8*A_PtrSize), "ptr", AsyncInfo, "uint*", ErrorCode) ; IAsyncInfo.ErrorCode
msgbox AsyncInfo status error: %ErrorCode%
ExitApp
}
ObjRelease(AsyncInfo)
break
}
sleep 10
}
DllCall(NumGet(NumGet(Object+0)+8*A_PtrSize), "ptr", Object, "ptr*", ObjectResult) ; GetResults
ObjReleaseClose(Object)
Object := ObjectResult
}
ObjReleaseClose(ByRef Object)
{
if Object
{
if (Close := ComObjQuery(Object, IClosable := "{30D5A829-7FA4-4026-83BB-D75BAE4EA99E}"))
{
DllCall(NumGet(NumGet(Close+0)+6*A_PtrSize), "ptr", Close) ; Close
ObjRelease(Close)
}
ObjRelease(Object)
}
Object := ""
}
return

Why doesn't timer treat global variable correctly?

This continuously sends t:
myVar := true
SetTimer, myLoop, 0
myLoop(){
if (true) {
Send, {t down}
}
}
#Persistent
But this does nothing:
myVar := true
SetTimer, myLoop, 0
myLoop(){
if (myVar) {
Send, {t down}
}
}
#Persistent
Why? myVar and true both evaluate to true so I don't understand why it's different.
myVar := true should be:
global myVar := true
Because a global must explicitly be declared as such.

How to implement a Bit-Flipping attack on AES-CBC?

Performing a task with root-me.org, as I understand from the attack statement, it is necessary to perform a byte shift to receive is_member = true After reading some instructions, I supplement the message with a block and accordingly do xor with the previous one, but when I pass the token, the next decryption output
b'[id=546815648;name=iziziz;is_member=false;mail=blablacar;pad=00]r\xe5\xf2\x1dM\xa5\xcae\xff\x16\xa2\xc6\xbe\xd8~I'
Tell me what I could miss, my code:
var TOKEN =
"IRZjBh6GxjeYI7YZvxwfBHmxjY+Wd7bPr7s73wWwLHKaR+N8fPDIjT8/AlUIDSzniMgqCV9bJArQbec64kPYXQ=="
// [id=546815648;name=iziziz;is_member=false;mail=blablacar;pad=00]
func main() {
//block 16
tokenHex, err := base64.StdEncoding.DecodeString(TOKEN) // lenght 64
if err != nil {
log.Fatal(err)
}
block := 16
for i := 0; i < len(tokenHex); i += block {
fmt.Println(tokenHex[i : i+block])
}
tmp := make([]byte, block)
for i := 0; i < block; i++ {
tmp[i] = byte('a')
}
tokenHex = append(tokenHex,tmp...)
expected := []byte(`;is_member=true]`)
//last block
current := []byte{136 ,200 ,42 ,9 ,95 ,91, 36, 10 ,208 ,109, 231, 58, 226, 67 ,216, 93}
for i := 0; i < 16; i++ {
xor := expected[i] ^ current[i]
tokenHex[64+i] ^= xor
}
fmt.Println(base64.StdEncoding.EncodeToString(tokenHex))
}

How to adjust the index of an array passed as a parameter?

I have rewritten the _Array base object to allow for 0 base arrays but I noticed a bug of sorts that I would appreciate some help with.
The relevant adjustments:
Array(_parameters*) {
r := {}
Loop, % Round(_parameters.Length())
r[A_Index - 1] := _parameters[A_Index]
r.base := _Array
Return (r)
}
Class _Array {
Length[] {
Get {
Return (Round(this.MaxIndex() + 1))
}
}
IsArray[] {
Get {
Return (1)
}
}
Push(_elements*) {
s := this.Length, m := Round(_elements.MaxIndex())
If (m)
this.InsertAt(s, _elements*)
Return (s + m)
}
Concat(_elements*) {
r := this.Clone()
MsgBox, % "222: " . _elements.Length() ;_elements.Length is not acceptable because this special parameter array (A_Args) does not get modified.
MsgBox, % "333: " . (_elements.base.__Class ? "y" : "n") ;No base.
For i, v in _elements {
If (v.IsArray) {
Loop, % v.Length
r.Push(v[A_Index - 1])
}
Else
r.Push(v) ;Catch for objects and string/integer values.
}
Return (r)
}
Join(_separator := ",") {
s := Round(this.MaxIndex())
For i, v in this
r .= (v.IsArray ? "[Array]" : IsObject(v) ? "{Object}" : v) . (i < s ? _separator : "")
Return (r)
}
}
The issue:
F1::
arrays := [[1,2,3]
, [4,5,6]
, [7,8,9]]
MsgBox, % "111: " . arrays.Length
MsgBox, % [].concat(arrays*).Join(", ") ;[4, 5, 6, 7, 8, 9]. Missing [1, 2, 3]
Return
I have confirmed that passing arrays* as a parameter creates an A_Args array but it has no base to manipulate. Is there anything I can do to fix this behaviour?

Autohotkey write text read from a text file

I want my script to read a textfile containing an intiger and to write this number by keyboard with out me actually touching it, but im kinda having trouble understanding the autohotkey since there is no software for it. Having some C# knowledge this is what i have:
FileRead, OutputVar, answertext.txt
sleep, 3000
;MyString = %OutputVar%
MyString = 16807
Loop, Parse, MyString
{
if (%A_LoopField% = -)
{
Send, {SC00C}
}
if (%A_LoopField% = 0)
{
Send, {SC00B}
}
if (%A_LoopField% = 1)
{
Send, {SC002}
}
if (%A_LoopField% = 2)
{
Send, {SC003}
}
if (%A_LoopField% = 3)
{
Send, {SC004}
}
if (%A_LoopField% = 4)
{
Send, {SC005}
}
if (%A_LoopField% = 5)
{
Send, {SC006}
}
if (%A_LoopField% = 6)
{
Send, {SC007}
}
if (%A_LoopField% = 7)
{
Send, {SC008}
}
if (%A_LoopField% = 8)
{
Send, {SC009}
}
if (%A_LoopField% = 9)
{
Send, {SC00A}
}
}
exit
Now this code starts but it always punches in 0 and nothing else, and if MyString = -1234, there is an error.
I will provide here some notes on improving your AutoHotkey script, and an amended version of it.
Your 'if' lines should be like this for most strings, with double quotes, and no percent signs:
if (A_LoopField = "a")
With numbers the double quotes are optional:
if (A_LoopField = "1")
if (A_LoopField = 1)
However fundamentally, your script need only be a few lines long:
FileRead, OutputVar, answertext.txt
sleep, 3000
;MyString = %OutputVar%
MyString = 16807
Send {Raw}%MyString%
You may prefer to include a key delay, to slow down the sending of text:
MyString = 16807
SetKeyDelay, 500
Send {Raw}%MyString%
Other methods for sending the text might be:
Clipboard := MyString
SendInput ^v
Or to insert text into Edit controls such as in Notepad for example without using the clipboard:
Control, EditPaste, %MyString%, Edit1, ahk_class Notepad
Or to set the entire contents of Edit controls, again without using the clipboard:
ControlSetText, Edit1, %vText%, ahk_class Notepad