Sélectionner une zone dans l'écran

Poser vos questions de programmation en AutoHotkey
bmldfromdtklan
Posts: 2
Joined: 07 Jan 2022, 06:07

Sélectionner une zone dans l'écran

Post by bmldfromdtklan » 09 Jan 2022, 05:10

Bonjour tout le monde j'ai besoin d'aide pour ce code que j'ai crée et que je n'arrive pas à savoir pourquoi le carre de sélection ne s'affiche pas. Si je le fais sans le "Gui,1:" sa marche mais ce n'est pas ce que je veux moi. Merci de m'aider s'il vous plais.

Code: Select all

#SingleInstance, Force

Gui,1:Add,Button,x50 y75 w100 h50 gBtSelectArea, Select Area
Gui,1:+alwaysOnTop
Gui,1:Show, x100 y100 w200 h200, Area selecter
Return

BtSelectArea:
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
Hotkey, Rbutton, SelectArea 
SetTimer, area, 0
Gui, 2:New
    Gui,  2:-Caption Border +AlwaysOnTop
    Gui,  2:Color, 0xD0FFFF
    Gui,  2:+LastFound
    WinSet, Transparent, 100
Return
SelectArea:
SetTimer, area, Off
Gui, 2:Default
MouseGetPos, x1, y1
while GetKeyState("RButton", "P")
{
    ToolTip, %x1%`, %y1%`, %x2%`, %y2%
    MouseGetPos, x2, y2
    x3 := x2 - x1
    y3 := y2 - y1
    Gui, 2:Show, x%x1% y%y1% w%x3% h%y3%
}
Gui, 2:Cancel
MsgBox, %x1%, %y1%, %x2%, %y2%
ToolTip, Area Selected
Sleep, 1000
ToolTip
SetTimer, area, 0
return
End::ExitApp, 
area:
ToolTip, Select un area
Return
Last edited by BoBo on 09 Jan 2022, 13:21, edited 1 time in total.
Reason: Moved to the French section of the forum.

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Sélectionner une zone dans l'écran

Post by mikeyww » 09 Jan 2022, 08:20

Code: Select all

Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, Button, w250 h50 Default, Select Area
Gui, 2:New, +LastFound -Caption +Border +AlwaysOnTop -DPIscale
Gui, 2:Color, 0xD0FFFF
WinSet, Transparent, 100
Gosub, F3

F3::Gui, 1:Show,, Area selector (F3)

GuiEscape:
Gui, Hide
Return

ButtonSelectArea:
Gui, Submit
select := True
ToolTip, Select an area
Return

#If select
RButton::
CoordMode, Mouse
MouseGetPos, x1, y1
Gui, 2:Default
While GetKeyState("RButton", "P")
{
 MouseGetPos, x2, y2
 ToolTip, % ttext := "(" x1 ", " y1 ") to (" x2 ", " y2 ")"
 width := x2 - x1 + 1, height := y2 - y1 + 1
 Gui, Show, x%x1% y%y1% w%width% h%height%
}
select := False
ToolTip
Gui, Hide
MsgBox, 64, Selection, %ttext%
Return
#If

bmldfromdtklan
Posts: 2
Joined: 07 Jan 2022, 06:07

Re: Sélectionner une zone dans l'écran

Post by bmldfromdtklan » 10 Jan 2022, 05:24

Merci mikeyww j'ai implémenter dans mon script maintenant ne carrer de sélection s'affiche mais le transparence ne fonctionne pas

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Sélectionner une zone dans l'écran

Post by mikeyww » 10 Jan 2022, 06:30

It did work here. I would first try this script alone, before incorporating into a different script. I have AHK version 1.1.33.10 on Windows 10. Perhaps you can explain more about what the script should do. Cela a fonctionné ici. J'essaierais d'abord ce script seul, avant de l'intégrer dans un autre script.

image001-20220110_cr.png
Initial run
image001-20220110_cr.png (27.71 KiB) Viewed 1622 times
image002-20220110_cr.png
Selection
image002-20220110_cr.png (22.04 KiB) Viewed 1622 times
image003-20220110_cr.png
Output
image003-20220110_cr.png (5.57 KiB) Viewed 1622 times

Operating system : Microsoft Windows 10 Pro
OS version : 10.0.19043
PC manufacturer : ASUSTeK COMPUTER INC.
PC model : ASUS EXPERTBOOK B9400CEAV_B9450CEA
CPU : Intel64 Family 6 Model 140 Stepping 1
CPU cores : 4
OS bitness : 64
CPU bitness : 64
BIOS manufacturer : ASUSTeK COMPUTER INC.
BIOS name : B9400CEAV.303
Motherboard manufacturer : ASUSTeK COMPUTER INC.
Motherboard product : B9400CEAV
Motherboard version : 1.0
Display : Citrix Indirect Display Adapter
Display width : 1920
Display height : 1080
DPI : 144
AHK version : 1.1.33.10

Post Reply

Return to “J'ai besoin d'aide”