Hi all,
I progress on the creation of my macro with help of this forum.
I have new problem because i would like to improve my job.
In my macro i often use sleep command and after few test i think it can be good if the number after sleep is defined by user. so i want to add after the message box the possibility for the user to type one number in second and this number will be a variable. This variable will be use after sleep.
for exemple : the user type 2 if he want 2 secondes and the variable will be sleep, %var%*1000 (to convert in millisecond)
i'm sure it's possible but i don't find the correct way to do this.
Thanks
Guillaume Durieux
variable on my macro
variable on my macro
- Attachments
-
- macro annotation guillaume durieux janv2016.txt
- (1.39 KiB) Downloaded 47 times
Re: variable on my macro
To do this, you need to use an expression. Your example is close to correct, however in expressions, variables are not wrapped in % symbols. Instead, plain text is interpreted as variables, and literal text must be in quotation marks ("). When you put %var%, this tells AHK to use the value stored in var as the name of variable. So for your example, you would use Sleep, var*1000.
With what you have, AHK is looking at the variable var, seeing that it contains for example "2" and then trying to find a variable named 2, and use the contents of that variable, instead of var.
Hope that makes sense.
With what you have, AHK is looking at the variable var, seeing that it contains for example "2" and then trying to find a variable named 2, and use the contents of that variable, instead of var.
Hope that makes sense.
-
- Posts: 43
- Joined: 14 Nov 2015, 09:58
Re: variable on my macro
Why couldn't you just post your code, why make it so you have to download?
Re: variable on my macro
Hi all,
I progress but it's not working well for the moment.
This is the actual version : Guillaume
I progress but it's not working well for the moment.
This is the actual version : Guillaume
Re: variable on my macro
Code: Select all
MsgBox ,,Lancement de la macro Annotation cree par Guillaume Durieux,La macro est prete a demarrer. Pour son bon fonctionnement il faut obligatoirement qu'aucune application ne soit lancee et qu'une image soit selectionnee. Il faut aussi qu'un document vierge ait été ouvert dans le traitement de texte. Merci de cliquer sur le bouton OK ou alors d'appuyer sur la touche ENTREE de votre clavier.,
InputBox, var_sleep, Definition des temps de pause, Merci de taper un chiffre entre 1 et 10. Plus ton ordinateur est lent et plus le chiffre devra se rapprocher de 10. Essaye d'abord un petit chiffre et si la macro ne fonctionne pas alors il faudra taper un chiffre plus important,,,,,,,, Default]
Send ^c ; copie l'image en mémoire
Sleep, var_sleep*1000
Send !{tab} ; retourne dans le document vierge
Sleep, var_sleep*1000
Send ^v ; colle l'image dans le document vierge
FileRemoveDir, C:\annotation_gdurieux ,1 ; supprime le dossier c:\annotation_gdurieux
FileCreateDir, C:\annotation_gdurieux ; crée le dossier c:\annotation_gdurieux de telle qu'on soit sur qu'il soit vierge
Send ^c!{tab}^v ; realise le copie/coller de l'image concernée
Sleep, var_sleep*1000
Send !{tab}
Sleep, var_sleep*1000
Send ^v
Sleep, var_sleep*1000
Send ^a!f!d ; exécute raccourci ctrl+a puis le raccourci alt+f
Sleep, var_sleep*1000 ; temporise 1 seconde
Send !s ; exécute raccourci alt+s
Sleep, var_sleep*1000 ; temporise 1 seconde
Send !x ; exécute raccourci alt+x
Sleep, var_sleep*1000 ; temporise une seconde
Send c:\annotation_gdurieux\annotation ; indique le nom et le dossier d'enregistrement du fichier pdf
Sleep, var_sleep*1000
Send {Enter}
Sleep, var_sleep*1000
Run c:\annotation_gdurieux\annotation.pdf ; ouvre le fichier pdf precedement crée
If you put your code into your post like I have done, purple will be more inclined to help as they won't have to download a file just to even try! I haven't made any changes to the code, just posted it so people can at least see it without having to download it.
You say it's "not working well" - explain please. What is going wrong? What is happening that shouldn't be, or isn't happening that should be?
Re: variable on my macro
My actual problem is to multiply by 1000 the variable var_sleep.
I try with sleep, var_sleep*1000 but it's not working.
Thank you
Guillaume Durieux
I try with sleep, var_sleep*1000 but it's not working.
Thank you
Guillaume Durieux
Re: variable on my macro
Input box is working and the sleep is working as expected.
Could it be something else that is causing the program to stall somewhere?
Code: Select all
f2::
InputBox, var_sleep, Second to sleep
msgbox, Sleep for %var_sleep% seconds
Sleep, var_sleep*1000
msgbox, done, lets check that again for %var_sleep% seconds
Sleep, var_sleep*1000
msgbox, done
return
Re: variable on my macro
Sorry, i made a mistake, in fact it was working but i forget to change me keybord shortcut so i was launching the the version 2 and not the version 2.1 of the macro.
This is the complete text of the macro :
Thanks for your help
Guillaume Durieux
This is the complete text of the macro :
Code: Select all
MsgBox ,,Lancement de la macro Annotation cree par Guillaume Durieux,La macro est prete a demarrer. Pour son bon fonctionnement il faut obligatoirement qu'aucune application ne soit lancee et qu'une image soit selectionnee. Il faut aussi qu'un document vierge ait été ouvert dans le traitement de texte. Merci de cliquer sur le bouton OK ou alors d'appuyer sur la touche ENTREE de votre clavier.,
InputBox, var_sleep, Definition du temps de pause, Merci de taper un chiffre entre 1 et 10. Plus ton ordinateur est lent et plus le chiffre devra se rapprocher de 10. Essaye d'abord un petit chiffre et si la macro ne fonctionne pas alors il faudra taper un chiffre plus important,,,,,,,,1
Send ^c ; copie l'image en mémoire
Sleep, var_sleep*1000
Send !{tab} ; retourne dans le document vierge
Sleep, var_sleep*1000
Send ^v ; colle l'image dans le document vierge
FileRemoveDir, C:\annotation_gdurieux ,1 ; supprime le dossier c:\annotation_gdurieux
FileCreateDir, C:\annotation_gdurieux ; crée le dossier c:\annotation_gdurieux de telle qu'on soit sur qu'il soit vierge
Send ^c!{tab}^v ; realise le copie/coller de l'image concernée
Sleep, var_sleep*1000
Send !{tab}
Sleep, var_sleep*1000
Send ^v
Sleep, var_sleep*1000
Send ^a!f!d ; exécute raccourci ctrl+a puis le raccourci alt+f
Sleep, var_sleep*1000 ; temporise 1 seconde
Send !s ; exécute raccourci alt+s
Sleep, var_sleep*1000 ; temporise 1 seconde
Send !x ; exécute raccourci alt+x
Sleep, var_sleep*1000 ; temporise une seconde
Send c:\annotation_gdurieux\annotation ; indique le nom et le dossier d'enregistrement du fichier pdf
Sleep, var_sleep*1000
Send {Enter}
Sleep, var_sleep*1000
Run c:\annotation_gdurieux\annotation.pdf ; ouvre le fichier pdf precedement crée
Guillaume Durieux
Who is online
Users browsing this forum: adam86shadow, Chunjee, JKJadan, TAC109 and 277 guests