Тема: AHK: ControlClick вызов скрипта из реестра
Добрый день!
Есть основной скрипт. С ним всё нормально, можно его особо не изучать. Привожу его исходя из того, что возможно, его параметры имеют к моей проблеме какое-то значение:
#InstallKeybdHook
Menu, Tray, Icon, icopy.ico
DetectHiddenWindows, on
SetFormat, Float, 0.1
OnMessage(0x201, "WM_LBUTTONDOWN")
Gui, +hwndhGui
Gui, -Caption +AlwaysOnTop +Lastfound +ToolWindow HwndGUIhWnd
Gui, Margin, 0, 0
Gui, Color, a1a1a1
Gui, Font, w900 cRed s12
Gui, Add, Text, +Center x37 y0 w25 h20
Gui, Add, Text, +Center x75 y0 w25 h20
Gui, Add, Text, +Center x118 y0 w25 h20
Gui, Font, w900 cBlue s14
Gui, Add, Text, +Center x5 y0 w25 h25
Gui, Font, w900 cBlue s7
Gui, Add, Text, +Center x5 y25 w25 h20
Gui, Add, Picture, x30 y0, 0001.png
;Gui, Add, Picture, x40 y20, go.png
Gui, Add, Picture, x40 y20 vFireStatic gCopy, quantity.png
Gui, Show, % "x"A_ScreenWidth-150 "y"A_ScreenHeight-70
curQuantity := 0
curPrice := 0
NcurQuantity := 0
NcurPrice := 0
ifnotexist, xeroxsettings.ini
{
IniWrite, 1, xeroxsettings.ini, trayicon, showicon
IniWrite, -15, xeroxsettings.ini, settings, brightness
IniWrite, 40, xeroxsettings.ini, settings, contrast
IniWrite, 1, xeroxsettings.ini, settings, copies
IniWrite, 7, xeroxsettings.ini, accountsystem, price
}
IniRead, iconvalue, xeroxsettings.ini, trayicon, showicon, 1
IniRead, curBright, xeroxsettings.ini, settings, brightness, -15
IniRead, curContrast, xeroxsettings.ini, settings, contrast, 40
IniRead, curCopies, xeroxsettings.ini, settings, copies, 1
IniRead, curPrice, xeroxsettings.ini, accountsystem, price, 7
ControlSetText, Static1, %curCopies%, % "ahk_id"GUIhWnd
ControlSetText, Static2, %curBright%, % "ahk_id"GUIhWnd
ControlSetText, Static3, %curContrast%, % "ahk_id"GUIhWnd
ControlSetText, Static4, 0, % "ahk_id"GUIhWnd
ControlSetText, Static5, 0, % "ahk_id"GUIhWnd
Return
;################################################################################################################################################
;Начать копирование
Copy:
SetTimer, Reset, Off
GuiControl, Hide, FireStatic
Run, "d:\Documents\PSoft\iCopy\iCopy.exe" /copy /r 300 /nc %curCopies% /b %curBright% /cnt %curContrast% /quality 75 /scaling 98 /printer "Canon LBP2900 Virtual"
;Run, "d:\Documents\PSoft\iCopy\iCopy.exe" /copy /r 300 /nc %curCopies% /b %curBright% /cnt %curContrast% /quality 75 /scaling 98 /printer "Canon LBP2900 3"
WinWait, Загрузка данных, , 6
WinWaitClose, Загрузка данных
GuiControl, Show, FireStatic
WinWait, Идет печать, , 2
IfWinExist, Идет печать
{
NcurQuantity += curQuantity + curCopies
NcurPrice := NcurQuantity * curPrice
ControlSetText, Static4, %NcurQuantity%, % "ahk_id"GUIhWnd
ControlSetText, Static5, %NcurPrice%, % "ahk_id"GUIhWnd
SetTimer, Reset, 600000
}
Return
;################################################################################################################################################
;Сброс счётчика
Reset:
curQuantity := 0
NcurQuantity := 0
ControlSetText, Static4, 0, % "ahk_id"GUIhWnd
ControlSetText, Static5, 0, % "ahk_id"GUIhWnd
SetTimer, Reset, Off
;################################################################################################################################################
;Управление настройками
#If CursorOverControl(hGui)
LButton::
RButton::
MButton::
MouseGetPos,,, hwnd, controlname
if controlname = Static1
{
GuiControl,, Static1, % A_ThisHotkey = "LButton" ? ++curCopies : --curCopies
IniWrite, %curCopies%, xeroxsettings.ini, settings, copies
}
if controlname = Static2
{
GuiControl,, Static2, % A_ThisHotkey = "LButton" ? curBright += 10 : curBright -= 10
IniWrite, %curBright%, xeroxsettings.ini, settings, brightness
}
if controlname = Static3
{
GuiControl,, Static3, % A_ThisHotkey = "LButton" ? curContrast += 10 : curContrast -= 10
IniWrite, %curContrast%, xeroxsettings.ini, settings, contrast
}
if controlname = Static4
{
GuiControl,, Static4, % A_ThisHotkey = "LButton" ? NcurQuantity += 1 : NcurQuantity -= 1
GuiControl,, Static5, % A_ThisHotkey = "LButton" ? NcurPrice += curPrice : NcurPrice -= curPrice
GuiControl,, Static4, % A_ThisHotkey = "MButton" ? NcurQuantity := 0 : NcurQuantity := NcurQuantity
GuiControl,, Static5, % A_ThisHotkey = "MButton" ? NcurPrice := 0 : NcurPrice := NcurPrice
}
Return
#If
CursorOverControl(hGui)
{
MouseGetPos,,, hwnd, controlname
Return hwnd = hGui && controlname ~= "^Static(1|2|3|4)$"
}
;################################################################################################################################################
;Перетасиквание окна
WM_LBUTTONDOWN()
{
If A_Gui
PostMessage, 0xA1, 2
}
Return
;################################################################################################################################################
;Печать пробелом
~SC029 & 1::
ifWinExist, % "ahk_id"GUIhWnd
{
GoSub, Copy
}
Return
Захотел сделать ControlClick по одной из картинок в данной GUI, при нажатии на хардверную кнопку сканера.
Сделал такой скриптик:
IfWinExist, XeroxNew3
{
SetControlDelay -1
ControlClick, x50 y30, XeroxNew3,, Left, 1, NA
SetControlDelay, 0
}
Return
Exit
Сам по себе он работает чётко.
Скомпилировал exe, который так же, при запуске "кликает" в нужном месте.
По мотивам этой: https://habr.com/ru/post/200528/ статьи, повесил на нужную мне кнопку вызов скомпилированного exe-шника. Он успешно вызывается, но не "кликает" в картинку. Пробовал оба способа, указанные в статье по ссылке, результат идентичный.
Что тут можно поделать?
Может быть, есть возможность "перехватывать" нажатие кнопки без реестра?
Спасибо!