Page 1 of 1

créer une boite de dialogue où je pourrais sélectionner un élément dans une liste

Posted: 12 Aug 2023, 23:12
by ph512
Bonjour, je souhaiterai créer une fenêtre avec autohotkey qui m'afficherai une liste où je pourrai sélectionner un des éléments. Ce qui me permettrai de lancer une action à partir de cette sélection.

Re: créer une boite de dialogue où je pourrais sélectionner un élément dans une liste

Posted: 13 Aug 2023, 11:18
by garry
une example ... enregistrer les paramètres sélectionnés

Code: Select all

;- Modified=20230813
;- Created =20140412
SplitPath,a_scriptname, name, dir, ext, name_no_ext, drive
F1=%a_scriptdir%\%name_no_ext%.ini
;-----------
I=12                 ;- total checkboxes
src=Gloria Lasso     ;- search for preselect
;-----------
Gui,2: Color,Black, Black
Gui,2: Font, CDefault s14, Lucida Console
Loop,%i%
   {
   IniRead, Ch%A_Index%, %f1%, ss, Cb%A_Index% , 0
    If (Ch%A_Index% = 1)
       Cb%A_Index% = Checked
    Else
       Cb%A_Index% =
   }
Gui,2:  Show, x100 y5 w350 h500, %name_no_ext%
Gui,2: Add, Edit,      x20 y5  w315 h27 cWhite vSearch,%src%
Gui,2:  Add, CheckBox, x20 y40  vCh1  %cb1%   cYellow, Google
Gui,2:  Add, CheckBox, x20 y65  vCh2  %cb2%   cYellow, Google  I``m feeling lucky
Gui,2:  Add, CheckBox, x20 y90  vCh3  %cb3%   cYellow, Bing    Pictures
Gui,2:  Add, CheckBox, x20 y115 vCh4  %cb4%   cYellow, Flickr  Pictures
Gui,2:  Add, CheckBox, x20 y140 vCh5  %cb5%   cYellow, Google  Pictures
Gui,2:  Add, CheckBox, x20 y165 vCh6  %cb6%   cYellow, Google  SEARCH fr
Gui,2:  Add, CheckBox, x20 y190 vCh7  %cb7%   cYellow, Google  NEWS fr
Gui,2:  Add, CheckBox, x20 y215 vCh8  %cb8%   cYellow, Google  PDF
Gui,2:  Add, CheckBox, x20 y240 vCh9  %cb9%   cYellow, Google  Video
Gui,2:  Add, CheckBox, x20 y265 vCh10 %cb10%  cYellow, Youtube Video
Gui,2:  Add, CheckBox, x20 y290 vCh11 %cb11%  cYellow, Wikipedia
Gui,2:  Add, CheckBox, x20 y310 vCh12 %cb12%  cYellow, Charmap


Gui,2:  Add, CheckBox, x20 y400 vCh98 gCheckAll   cYellow, Select All
Gui,2:  Add, CheckBox, x20 y425 vCh99 gUnCheckAll cYellow, De-Select All

Gui,2:  Add, Button,   x10 y465 w100 h26 gAA ,Start
GuiControl,2:Focus,search
return
;--------------------------
CheckAll:
Loop, %i%
    GuiControl,2:, Ch%A_Index%, 1
GuiControl,2:, Ch99, 0
Return
;--------------------------
UnCheckAll:
Loop, %i%
    GuiControl,2:, Ch%A_Index%, 0
GuiControl,2:, Ch98, 0
Return
;--------------------------
AA:
Gui,2: submit, nohide
StringReplace,Search, Search, %A_space%, +, All
search=`%22%search%`%22

  if Ch1
	run,https://www.google.fr/search?q=%search%
  if Ch2
    run,https://www.google.fr/search?btnI=I`%27m+Feeling+Lucky&q=%search%
  if Ch3
    run,https://www.bing.com/images/search?q=%search%&FORM=HDRSC2
  if Ch4
    run,https://www.flickr.com/search/?q=%search%
  if Ch5
    run,https://www.google.fr/search?q=%search%&tbm=isch
  if Ch6
    {
    run,https://www.google.com/search?q=%search%#q=%search%&tbm=nws&hl=fr&gl=FR&ceid=FR:fr
    ;run,https://www.google.com/search?q=%search%#q=%search%&tbm=nws&hl=nl  ;- nederlands
	}
  if Ch7
	run,https://news.google.com/home?hl=fr&gl=FR&ceid=FR:fr
  if Ch8
    {
	run,https://www.google.com/search?q=%search%#q=%search%&tbm=nws&hl=fr&gl=FR&ceid=FR:fr filetype:pdf
	}
  if Ch9
    run,https://www.google.com/search?q=%search%&tbm=vid&hl=fr&gl=FR&ceid=FR:fr
  if Ch10
    run,https://www.youtube.fr/results?search_query=%search%
  if Ch11
     {
     StringReplace,search,search,+,%A_space%, All
     StringUpper,search,search,T
     StringReplace,search,search,%A_space%,_, All
     StringReplace,Search,Search,`%22, , All
     run, https://en.wikipedia.org/wiki/%search%
     }
  if Ch12
     run,charmap                             ;--- open xy program
return
;--------------------------
2GuiClose:
Gui,2:  Submit
Loop,%i%
   {
   e= % ch%a_index%
   IniWrite, %e%, %f1%, ss, Cb%a_index%
   }
ExitApp
;===========================================================================


Re: créer une boite de dialogue où je pourrais sélectionner un élément dans une liste  Topic is solved

Posted: 14 Aug 2023, 14:46
by ph512
Je te remercie bien Garri pour ce super exemple que je vais garder et étudier :bravo: Mais du coup entre temps j'ai fait quelque chose de beaucoup plus simple, ça se voit que je n'ai pas ton niveau ;)

Code: Select all

#NoTrayIcon

Gui, Font, s20,
Gui, Add, Link,, <a href="D:\S\Documents\Choix 1.ahk"> Choix 1 </a>
Gui, Add, Link,, <a href="D:\S\Documents\Choix 2.ahk"> Choix 2 </a>
Gui, Add, Link,, <a href="D:\S\Documents\Choix 3.ahk"> Choix 3 </a>
Gui, Add, Link,, <a href="D:\S\Documents\Choix 4.ahk"> Choix 4 </a>
Gui, Add, Link,, <a href="D:\S\Documents\Choix 5.ahk"> Choix 5 </a>
Gui, Add, Link,, <a href="D:\S\Documents\Choix 6.ahk"> Choix 6 </a>
Gui, Add, Link,, <a href="D:\S\Documents\Choix 7.ahk"> Choix 7 </a>
Gui, Show
return

GuiClose:
GuiEscape:
ExitApp
[Mod edit: + [code][/code] tags.]

Re: créer une boite de dialogue où je pourrais sélectionner un élément dans une liste

Posted: 14 Aug 2023, 15:36
by flyingDman
Tu peux réaliser quelque chose de similaire avec Menu:

Code: Select all

#Requires AutoHotkey v1.1.33
Menu, MyMenu, Add, Item1, MenuHandler
Menu, MyMenu, Add, Item2, MenuHandler
Menu, MyMenu, Add, Item3, MenuHandler
return

MenuHandler:
MsgBox Tu as selectionné %A_ThisMenuItem% du menu %A_ThisMenu%.
return

#F12::Menu, MyMenu, Show
de la tu peut faire:

Code: Select all

arr := {"Google" : "https://google.com"
		, "AHK" : "https://www.autohotkey.com/"
		, "AHK Forum":"https://www.autohotkey.com/boards/"}
for x,y in arr
	Menu, MyMenu, Add, %x%, MenuHandler
return

MenuHandler:
run, % arr[A_ThisMenuItem]
return

#F12::Menu, MyMenu, Show
Menu te permet aussi de créer des sous-menus.